I am using pyTelegramBotApi and Flask on PythonAnywhere. The bot works fine, however i need to use an InlineKeyboard with it. How do I do this? Everywhere I look, people use a function, but that doesn't work with Flask. My current code is:
from flask import Flask, request
import telebot
from telebot import types
import urllib3
import datetime
TELEGRAM_TOKEN = 'token'
secret = "secret"
bot = telebot.TeleBot(TELEGRAM_TOKEN)
bot.remove_webhook()
bot.set_webhook(url="https://blockchainbot.pythonanywhere.com/{}".format(secret))
app = Flask(__name__)
@app.route('/{}'.format(secret), methods=["POST"])
def telegram_webhook():
update = request.get_json()
if "message" in update:
text = update["message"]["text"]
chat_id = update["message"]["chat"]["id"]
if text == "/start":
bot.send_message(chat_id, ".....", reply_markup=types.ReplyKeyboardMarkup())
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("option1")
item2 = types.KeyboardButton("option2")
markup.add(item1, item2)
bot.send_message(chat_id, ".....", reply_markup=markup)
elif text == "Каждый день":
bot.send_message(chat_id, ".....")
markup = types.InlineKeyboardMarkup()
markup.row_width = 2
markup.add(types.InlineKeyboardButton("Yes", callback_data="cb_yes"),
types.InlineKeyboardButton("No", callback_data="cb_no"))
bot.send_message(chat_id, "test", reply_markup=markup)
return "ok"
I want to know how to get callback data from the button the user presses. How do I do that with this code?