Skip to content

Instantly share code, notes, and snippets.

@shellscriptx
Last active February 4, 2019 20:02
Show Gist options
  • Save shellscriptx/ac5375a6c050ecd57c6eddb599225679 to your computer and use it in GitHub Desktop.
Save shellscriptx/ac5375a6c050ecd57c6eddb599225679 to your computer and use it in GitHub Desktop.
bot_service_regras
#!/bin/bash
# Importando API
source ShellBot.sh
# Token do bot
bot_token='<TOKEN_AQUI>'
# Inicializando o bot
ShellBot.init --token "$bot_token" --monitor --flush
# Carregando regras.
source root_rules.sh
source user_rules.sh
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
(
# Gerenciar regras
ShellBot.manageRules --update_id $id
) & # Utilize a thread se deseja que o bot responda a várias requisições simultâneas.
done
done
#FIM
#!/bin/bash
# Regras
ShellBot.setMessageRules --name 'root_rule1' ...
ShellBot.setMessageRules --name 'root_rule2' ...
# FIM
```
#!/bin/bash
# Regras
ShellBot.setMessageRules --name 'user_rule1' ...
ShellBot.setMessageRules --name 'user_rule2' ...
# FIM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment