1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from flask import Flask, request from telegram import Bot CHAT_ID = '...' app = Flask('tbot') bot = Bot('TOKEN') @app.route('/send-text', methods=['POST']) def send_message(): """ You should always use a POST when your action does something. Only use GET when retrieving a value. """ msg = 'Testing API call' try: data = request.get_json(force=True) msg = data['message'] except: pass bot.send_message(chat_id=CHAT_ID, text=msg) return '', 204 |