-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathapp.py
More file actions
24 lines (17 loc) · 777 Bytes
/
app.py
File metadata and controls
24 lines (17 loc) · 777 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
from flask import Flask, request, jsonify
from telegram_bot import TelegramBot
from config import TELEGRAM_INIT_WEBHOOK_URL
app = Flask(__name__)
TelegramBot.init_webhook(TELEGRAM_INIT_WEBHOOK_URL)
@app.route('/webhook', methods=['POST'])
def index():
req = request.get_json()
bot = TelegramBot()
bot.parse_webhook_data(req)
success = bot.action()
return jsonify(success=success) # TODO: Success should reflect the success of the reply
if __name__ == '__main__':
app.run(port=5000)
# https://telegram.me
# check bot initialization: https://api.telegram.org/bot<822448732:AAGUNRBnPPHjVhOqySQZk_QzP_VaZhgx9i0>/getme
# check webhook url: https://api.telegram.org/bot822448732:AAGUNRBnPPHjVhOqySQZk_QzP_VaZhgx9i0/getWebhookInfo