Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telepot
- from telepot.loop import MessageLoop
- import parser
- from math import *
- import random, datetime
- falas = ('Booom Dia', 'É que sou muito sistemático...', 'Está fácil pra quem estudou.')
- falas_prov = ('Está fácil pra quem estudou.', 'O corno está ferrado!', 'Terá tudo o que dei.', 'Rá!')
- bot = telepot.Bot('TOKEN') # Colocar aqui o token do bot do telegram, gerado no BotFather
- def handle(msg):
- print(msg)
- content_type, chat_type, chat_id = telepot.glance(msg)
- if 'gelso' in msg['text'].lower() and '?' not in msg['text']:
- random.seed(datetime.datetime.now())
- bot.sendMessage(chat_id, falas[random.randint(0, 2)], reply_to_message_id=msg['message_id'])
- if msg['text'].lower().startswith('/conta'):
- resp = op_mat(' '.join(msg['text'].split(' ')[1::1]))
- bot.sendMessage(chat_id, resp, reply_to_message_id=msg['message_id'])
- if 'dormir' in msg['text'].lower() or 'sono' in msg['text'].lower():
- bot.sendMessage(chat_id, 'Quer um travesseiro e um suquinho?', reply_to_message_id=msg['message_id'])
- if '?' in msg['text'] and 'gelso' in msg['text'].lower():
- resp = ('sim', 'não')
- random.seed(datetime.datetime.now())
- bot.sendMessage(chat_id, resp[random.randint(0, 1)], reply_to_message_id=msg['message_id'])
- if 'gelso' in msg['text'].lower() and 'fala' in msg['text'] and len(msg['text'].split(' ')) >= 2 and 'prova' not in msg['text']:
- fala = ' '.join(msg['text'].split(' ')[2::])
- bot.sendMessage(chat_id, fala, reply_to_message_id=msg['message_id'])
- if 'gelso' in msg['text'].lower() and 'prova' in msg['text']:
- random.seed(datetime.datetime.now())
- bot.sendMessage(chat_id, falas_prov[random.randint(0, 3)], reply_to_message_id=msg['message_id'])
- def op_mat(op):
- try:
- code = parser.expr(op).compile()
- return str(eval(code))
- except (SyntaxError, TypeError, NameError):
- return 'O corno digitou algo errado.'
- MessageLoop(bot, handle).run_as_thread()
- while 1:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement