我在 python 上使用 telebot 库作为我的电报机器人。我需要在单击
InlineKeyboardButton
中的第一个按钮 (markup
) 时,应显示另一个带有几个按钮 (InlineKeyboardMarkup
) 的标记。
import telebot
from telebot import types
#BOT CONNECT
bot = telebot.TeleBot('token')
#markups
markup = types.InlineKeyboardMarkup()
markup.add(types.InlineKeyboardButton("Почати ", ))
markup.add(types.InlineKeyboardButton("Show guide",url=""))
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(
message.chat.id, "Бот буде надсилати вам вибірку найголовніших новин на вибрану вами тему у вибраний час", reply_markup=markup)
# RUN
bot.infinity_polling()
keyboard.add(types.InlineKeyboardButton("Почати", callback_data="test"))
或
keyboard.add(types.InlineKeyboardButton(text="Почати", callback_data="test"))
和
@bot.callback_query_handler(func=lambda call: True)
def testing(call):
if call.data == "test":
bot.send_message(call.chat_id, "send text")
else:
pass
像这样打开按钮并像这样检查不要忘记放置decarator