Advertisement
YoungC0DE

Bot para o telegram

Mar 24th, 2020
1,834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from amanobot.loop import MessageLoop
  2. from amanobot import glance,Bot
  3. from time import sleep
  4. from random import randint
  5. from pprint import pprint
  6.  
  7. bot=Bot("meu token")
  8.  
  9. id = 'meu id' #eu  
  10. def receber(msg):
  11.     content_type, chat_type, chatID = glance(msg)
  12.     #pprint(msg)
  13.     arquivo = frases()
  14.     if msg['text'] == '/start':
  15.         bot.sendMessage(chatID,"Bem vindo. Fique atento para novas postagens!")
  16.     elif msg['text'] == '/sobre':
  17.         bot.sendMessage(chatID,"Basicamente eu tenho um banco de dados contendo diversas frases e informações, e eu as envio de forma aleatoria!")
  18.     else:
  19.         mID = msg['message_id']
  20.         bot.sendMessage(id, arquivo,reply_to_message_id=mID)
  21.        
  22.    
  23. def frases():
  24.     frase=[]
  25.     with open('texto.txt','r',encoding='UTF-8') as txt:
  26.         txt.seek(0)
  27.         for i in txt.readlines():
  28.             frase.append(i)
  29.         lista = list(map(lambda l: l.replace('\n', ''), frase))
  30.     return lista
  31.  
  32. MessageLoop(bot, receber).run_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement