forked from lukaville/create-event-bot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbot.py
46 lines (28 loc) · 933 Bytes
/
bot.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Create calendar events inline bot
import logging
import os
from telegram.ext import Updater
from modules.commands import CommandsModule
from modules.inline import InlineModule
from config import params
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def error(bot, update, err):
logger.warn('Update "%s" caused error "%s"' % (update, err))
def load_modules(dispatcher, modules):
for module in modules:
for handler in module.get_handlers():
dispatcher.add_handler(handler)
def main():
updater = Updater(params['token'])
dp = updater.dispatcher
load_modules(dp, [CommandsModule(), InlineModule()])
dp.add_error_handler(error)
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()