mirror of
https://github.com/andwati/unsplash-bot.git
synced 2026-10-21 20:14:26 +00:00
completed bot logic
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import flask
|
||||
import telebot
|
||||
|
||||
from bot import bot
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
WEBHOOK_URL_PATH = "/{}".format(bot.token)
|
||||
|
||||
|
||||
@app.route(WEBHOOK_URL_PATH, methods=["POST"])
|
||||
def webhook():
|
||||
if flask.request.headers.get("content-type") == "application/json":
|
||||
json_string = flask.request.get_data().decode("utf-8")
|
||||
update = telebot.types.Update.de_json(json_string)
|
||||
|
||||
bot.process_new_updates([update])
|
||||
return ""
|
||||
else:
|
||||
flask.abort(403)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
||||
Reference in New Issue
Block a user