Finished #22
This commit is contained in:
parent
236293f513
commit
1fc0c31bf4
|
@ -18,6 +18,12 @@ level=INFO
|
|||
lifetime=28800.0
|
||||
stickers=BQADAgADGwEAAjbsGwVVGLVNyOWfuwI
|
||||
|
||||
[updates]
|
||||
mode=polling
|
||||
host=
|
||||
port=
|
||||
url=
|
||||
|
||||
[redis]
|
||||
host=
|
||||
port=
|
||||
|
|
12
src/bot.py
12
src/bot.py
|
@ -29,5 +29,17 @@ class Bot:
|
|||
self.dispatcher.add_handler(CommandHandler())
|
||||
self.dispatcher.add_handler(StatusHandler(chat_purge_queue=ChatPurgeQueue(self.updater.job_queue, redis)))
|
||||
|
||||
if config['updates']['mode'] == 'polling':
|
||||
self.updater.start_polling()
|
||||
elif config['updates']['mode'] == 'webhook':
|
||||
key = open(config['updates']['key'], 'rb') if config['updates']['key'] is not None else None
|
||||
cert = open(config['updates']['cert'], 'rb') if config['updates']['cert'] is not None else None
|
||||
|
||||
self.updater.start_webhook(listen=config['updates']['host'],
|
||||
port=config.getint('updates', 'port'),
|
||||
url_path=config['bot']['token'],
|
||||
key=key,
|
||||
cert=cert,
|
||||
webhook_url=config['updates']['url'])
|
||||
|
||||
self.updater.idle()
|
||||
|
|
Loading…
Reference in New Issue