Skip to content

Commit c888666

Browse files
committed
FEATURE: Setting for switching between polling/webhook
Can be set via the config file
1 parent 9a9e1f3 commit c888666

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from telegram.inline.inlinekeyboardmarkup import InlineKeyboardMarkup
1313

1414
import own_filters
15-
from config import BOT_TOKEN
15+
from config import BOT_TOKEN, USE_WEBHOOK, WEBHOOK_PORT, WEBHOOK_URL, CERTPATH
1616
from database.db_wrapper import DBwrapper
1717
from database.statistics import get_user_stats
1818
from game.blackJackGame import BlackJackGame
@@ -477,6 +477,11 @@ def restart(bot, update):
477477

478478
dispatcher.add_error_handler(error)
479479

480-
updater.start_polling()
480+
if USE_WEBHOOK:
481+
updater.start_webhook(listen="127.0.0.1", port=WEBHOOK_PORT, url_path=BOT_TOKEN, cert=CERTPATH, webhook_url=WEBHOOK_URL)
482+
updater.bot.set_webhook(WEBHOOK_URL)
483+
else:
484+
updater.start_polling()
485+
481486
logger.info("Bot started as @{}".format(updater.bot.username))
482487
updater.idle()

0 commit comments

Comments
 (0)