Guest User

Untitled

a guest
Feb 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Importando API
  4. source ShellBot.sh
  5.  
  6. # Token do bot
  7. bot_token='<TOKEN_AQUI>'
  8.  
  9. # Inicializando o bot
  10. ShellBot.init --token "$bot_token" --flush --monitor --return map
  11.  
  12. while :
  13. do
  14. # Obtem as atualizações
  15. ShellBot.getUpdates --limit 100 --offset $(ShellBot.OffsetNext) --timeout 30
  16.  
  17. # Lista o índice das atualizações
  18. for id in $(ShellBot.ListUpdates)
  19. do
  20. # Inicio thread
  21. (
  22. # Verifica se a mensagem enviada pelo usuário é um comando válido.
  23. case ${message_text[$id]} in
  24. # Comando.
  25. /cmd)
  26. # Envia pergunta.
  27. ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
  28. --text 'Comando:' \
  29. --reply_markup "$(ShellBot.ForceReply)" # Força resposta.
  30. ;;
  31. esac
  32.  
  33. # Verifica se há resposta.
  34. if [[ ${message_reply_to_message_message_id[$id]} ]]; then
  35. # Se a resposta é referente a pergunta.
  36. if [[ ${message_reply_to_message_text[$id]} == Comando: ]]; then
  37. ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
  38. --text "**Resposta:** ${message_text[$id]}" \
  39. --parse_mode markdown
  40. fi
  41. fi
  42. ) & # Utilize a thread se deseja que o bot responda a várias requisições simultâneas.
  43. done
  44. done
  45. #FIM
Add Comment
Please, Sign In to add comment