From 1579e558f26bc2d1d0e93847bee7a4fc40d0e630 Mon Sep 17 00:00:00 2001 From: Ian Andwati Date: Sun, 15 May 2022 18:56:51 +0300 Subject: [PATCH] modified webhook --- src/bot.py | 5 ++++- src/server.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bot.py b/src/bot.py index 22e5be7..1ff003e 100644 --- a/src/bot.py +++ b/src/bot.py @@ -8,9 +8,12 @@ load_dotenv() bot = telebot.TeleBot(os.getenv("TELEGRAM_TOKEN")) +# remove previous webhook +bot.remove_webhook() + # configure the webhook for the bot bot.set_webhook( - "https://{}.herokuapp.com/{}".format( + "https://{}.herokuapp.com/{}/".format( os.getenv("PROJECT_NAME"), os.getenv("TELEGRAM_TOKEN") ) ) diff --git a/src/server.py b/src/server.py index 21c3f21..9cfcf81 100644 --- a/src/server.py +++ b/src/server.py @@ -10,12 +10,12 @@ app = flask.Flask(__name__) WEBHOOK_URL_PATH = "/{}".format(bot.token) -@app.route("/") +@app.route("/", methods=["GET"]) def index(): return "

Index page

" -@app.route(WEBHOOK_URL_PATH, methods=["GET"]) +@app.route(WEBHOOK_URL_PATH, methods=["POST"]) def webhook(): """ sets the bot webhook