Created
October 15, 2019 16:44
-
-
Save ohld/b9f1e2b6dd6750c5cffa93a1956019d7 to your computer and use it in GitHub Desktop.
Now sh (Zeit co) simple Serverless Telegram echo bot (in Python)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import logging | |
| import telegram | |
| from flask import Flask, jsonify, request | |
| app = Flask(__name__) | |
| @app.route('/api', methods=['POST']) | |
| def api(): | |
| bot = telegram.Bot(token=os.getenv("TELEGRAM_TOKEN")) | |
| update = telegram.Update.de_json(request.get_json(force=True), bot) | |
| chat_id = update.message.chat.id | |
| # Reply with the same message | |
| bot.sendMessage(chat_id=chat_id, text=update.message.text) | |
| return jsonify({"status": "ok"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment