Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import telepot, sys
- reload(sys)
- sys.setdefaultencoding('utf8')
- bot = telepot.Bot('491145488:AAE17Hyw1Zk_9UFhTrkRqTiTF1L5ZHqcQoM')
- def handle(msg):
- # Parametros do bot.
- chat_id = msg['chat']['id']
- texto = msg['text']
- first_name = msg['from']['first_name']
- if 'username' not in msg['from']:
- user = 'None'
- else:
- user = '@' + msg['from']['username']
- # Mostrar as informações recebidas.
- print ('Comando enviado:' + texto)
- print ('Enviado por:' + user)
- print ('ID:' + str(chat_id))
- print (' ')
- # Comandos do bot.
- if texto == '/start':
- bot.sendMessage(chat_id, '👋 Bem-vindo {}.'.format (first_name))
- elif texto[0] == '~' and chat_id == 390562343:
- bot.sendMessage(chat_id, '{}'.format(texto[1::]))
- else:
- bot.sendMessage (chat_id, '❌ Comando invalido')
- # Loop de execução.
- print('Em execução...')
- bot.message_loop(handle)
- while 1:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement