-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
68 lines (51 loc) · 2.07 KB
/
Copy pathbot.py
File metadata and controls
68 lines (51 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# coding: utf-8
# In[ ]:
from RandomSentence import random_sentence, random_verse
from RealSentence import real_sentence
from CunadoSentence import cunado_sentence
from config import TOKEN
from telegram.ext import Updater, MessageHandler, CommandHandler, Filters
import logging
logging.basicConfig(format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level = logging.INFO)
#Token:
updater = Updater(token = TOKEN)
#dispatcher
dispatcher = updater.dispatcher
#Mensajes de información del programa
help_file = './data/help.txt'
help_txt = open(help_file).read()
info_file = './data/info.txt'
info_txt = open(info_file).read()
##Comandos:
def help(bot, update):
bot.send_message(chat_id = update.message.chat_id, text = help_txt)
help_handler = CommandHandler('help', help)
dispatcher.add_handler(help_handler)
def start(bot, update):
help(bot, update)
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
def info(bot, update):
bot.send_message(chat_id = update.message.chat_id, text = info_txt)
info_handler = CommandHandler('info', info)
dispatcher.add_handler(info_handler)
def frase(bot, update, args):
bot.send_message(chat_id = update.message.chat_id, text = random_sentence(' '.join(args)))
frase_handler = CommandHandler('frase', frase, pass_args = True)
dispatcher.add_handler(frase_handler)
def estrofa(bot, update, args):
bot.send_message(chat_id = update.message.chat_id, text = random_verse(' '.join(args)))
estrofa_handler = CommandHandler('estrofa', estrofa, pass_args = True)
dispatcher.add_handler(estrofa_handler)
def real(bot, update):
bot.send_message(chat_id = update.message.chat_id, text = real_sentence())
real_handler = CommandHandler('real', real)
dispatcher.add_handler(real_handler)
def cunado(bot, update, args):
bot.send_message(chat_id = update.message.chat_id, text = cunado_sentence(' '.join(args)))
cunado_handler = CommandHandler('cunado', cunado, pass_args = True)
dispatcher.add_handler(cunado_handler)
#Poner en funcionamiento el programa
updater.start_polling()
updater.idle()