Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, request
- import requests
- import json
- token = ''
- app = Flask(__name__)
- def send_message(chat_id, text):
- method = 'sendMessage'
- token = ''
- url = f"https://api.telegram.org/bot{token}/{method}"
- data = {"chat_id": chat_id, "text": text}
- requests.post(url, data=data)
- def send_pay_button(chat_id, text):
- method = "sendMessage"
- token = ''
- url = f"https://api.telegram.org/bot{token}/{method}"
- data = {"chat_id": chat_id, "text": text, "reply_markup": json.dumps({"inline_keyboard": [
- [{
- 'text': 'one',
- 'callback_data': '1'
- },
- {'text': 'two',
- 'callback_data': '2'},
- ],
- [
- {'text': 'three',
- 'callback_data': '3'},
- ]],
- },
- )}
- requests.post(url, data=data)
- @app.route('/', methods=["POST", "GET"])
- def index():
- chat_id = request.json['message']["chat"]["id"]
- send_pay_button(chat_id, text="Привет")
- return {"message": True}
- if __name__ == '__main__':
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment