Skip to content

Instantly share code, notes, and snippets.

@shellscriptx
Last active September 19, 2018 21:21
Show Gist options
  • Save shellscriptx/bfb060e8910e21f152b0b1f79e3a0c12 to your computer and use it in GitHub Desktop.
Save shellscriptx/bfb060e8910e21f152b0b1f79e3a0c12 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 
# Requer: ShellBot v5.9
#
# Importando API
source ShellBot.sh

# script
source plot_bot.sh

# Token do bot
bot_token='<TOKEN_AQUI>'

# Inicializando o bot
ShellBot.init --token "$bot_token" --monitor

# regra
ShellBot.setMessageRules    --name 'regra1'                                         \
                            --entitie_type bot_command                              \
                            --command '/grafico'                                    \
                            --chat_type 'private'                                   \
                            --username 'usuario1,usuario2,gestor1,gestor2,gestor3'  \
                            --action 'tvm_plot_lines'

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment