This commit is contained in:
REDNBLACK 2016-11-29 23:25:33 +03:00
parent 236293f513
commit 1fc0c31bf4
2 changed files with 19 additions and 1 deletions

View File

@ -18,6 +18,12 @@ level=INFO
lifetime=28800.0
stickers=BQADAgADGwEAAjbsGwVVGLVNyOWfuwI
[updates]
mode=polling
host=
port=
url=
[redis]
host=
port=

View File

@ -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)))
self.updater.start_polling()
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()