-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.py
More file actions
25 lines (19 loc) · 655 Bytes
/
main.py
File metadata and controls
25 lines (19 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Main module for the bot.
Run this module uses webhooks to run the bot and cannot be run in local development.
Run bot.py to run the bot in local development.
"""
from flask import Flask, request, abort
from bot import bot
from telebot import types
app = Flask(__name__)
@app.route("/")
def main():
return "<h1>Flask App</h1>"
@app.route("/bot", methods=['POST'])
def webhook():
if request.headers.get('content-type') == 'application/json':
json_string = request.get_data().decode('utf-8')
update = types.Update.de_json(json_string)
bot.process_new_updates([update])
return "working"
abort(403)