Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Importando API
- source ShellBot.sh
- # Token do bot
- bot_token='<TOKEN_AQUI>'
- # Inicializando o bot
- ShellBot.init --token "$bot_token" --flush --monitor --return map
- while :
- do
- # Obtem as atualizações
- ShellBot.getUpdates --limit 100 --offset $(ShellBot.OffsetNext) --timeout 30
- # Lista o índice das atualizações
- for id in $(ShellBot.ListUpdates)
- do
- # Inicio thread
- (
- # Verifica se a mensagem enviada pelo usuário é um comando válido.
- case ${message_text[$id]} in
- # Comando.
- /cmd)
- # Envia pergunta.
- ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
- --text 'Comando:' \
- --reply_markup "$(ShellBot.ForceReply)" # Força resposta.
- ;;
- esac
- # Verifica se há resposta.
- if [[ ${message_reply_to_message_message_id[$id]} ]]; then
- # Se a resposta é referente a pergunta.
- if [[ ${message_reply_to_message_text[$id]} == Comando: ]]; then
- ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
- --text "**Resposta:** ${message_text[$id]}" \
- --parse_mode markdown
- fi
- fi
- ) & # Utilize a thread se deseja que o bot responda a várias requisições simultâneas.
- done
- done
- #FIM
Add Comment
Please, Sign In to add comment