-
Notifications
You must be signed in to change notification settings - Fork 0
/
botillo.py
70 lines (51 loc) · 1.73 KB
/
botillo.py
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
69
70
import os
import time
import sys
import logging
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from credentials import TOKEN
from restricted_wrap import restricted
from filter_question import filter_question
# Python logging configurations
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
@restricted
def start(bot, update):
update.message.reply_text('eae')
@restricted
def restart(bot, update):
update.message.reply_text("Restarting...")
time.sleep(0.2)
os.execl(sys.executable, sys.executable, *sys.argv)
@restricted
def caps(bot, update, args):
text_caps = ' '.join(args).upper()
update.message.reply_text(text_caps)
@restricted
def question(bot, update):
update.message.chat.send_action('typing')
update.message.reply_text("perae")
def error(bot, update, error):
logger.warn('Update "%s" caused error "%s"' % (update, error))
def main():
# Connect to Telegram API
updater = Updater(token=TOKEN)
dp = updater.dispatcher
# Add message handlers
dp.add_handler(CommandHandler('start', start))
dp.add_handler(CommandHandler('r', restart))
dp.add_handler(CommandHandler('caps', caps, pass_args=True))
dp.add_handler(MessageHandler(filter_question, question))
# Log errors
dp.add_error_handler(error)
# Start the bot
updater.start_polling()
logger.info("Starting...")
# Block until the you presses Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT. This should be used most of the time, since
# start_polling() is non-blocking and will stop the bot gracefully.
updater.idle()
if __name__ == '__main__':
main()