From 9d7baf5b1839b9df5700550fce4d951e8c81eb9d Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sun, 4 Nov 2018 20:16:21 +0530 Subject: [PATCH] Add support for webhooks. --- bot.py | 8 +++++++- sample.config.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index fe76651..58f4d36 100644 --- a/bot.py +++ b/bot.py @@ -501,4 +501,10 @@ unknown = MessageHandler(Filters.command, lambda x, y: message_handling(x, y, db)) dispatcher.add_handler(unknown) -updater.start_polling() +if config.update_method == "polling": + updater.start_polling() +elif config.update_method == "webhook": + updater.start_webhook(listen=config.webhook["listen"], + url=config.webhook["url_path"], + port=config.webhook["port"]) + updater.set_webhook(webhook_url=config.webhook["url"]) diff --git a/sample.config.py b/sample.config.py index b062cfc..0b08e32 100644 --- a/sample.config.py +++ b/sample.config.py @@ -9,3 +9,17 @@ gifs = [ "https://media.giphy.com/media/1wo19g2Fc6d8rqhSvp/giphy.gif", "https://media.giphy.com/media/l2vAhfuyG9m9lJQnyS/giphy.gif" ] + +# Update method +# Available Modes: "polling", "webhook" +update_method = "polling" + +# Webhook Config +# Check the following urls for more details +# https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks + +webhook = {"listen": "0.0.0.0", + "url": "https://example.com/" + api_key, + "url_path": api_key, + "port": 9999, + }