如何解决python电报bot api inlinekeyboardbutton没有得到callback_data
python telegram bot api inlinekeyboardbutton 未获取 callback_data,
我正在使用远程机器人库,
这就是我创建按钮的方式
markup = types.ReplyKeyboardMarkup(row_width=2)
b1 = types.InlineKeyboardButton("button 1",callback_data='1')
b2 = types.InlineKeyboardButton('Button 2',callback_data='2')
markup.add(b1,b2)
bot.send_message(cid,'message',reply_markup=markup)
按钮出现,我可以按下它们但没有返回到我的 callback_query_handler
@bot.callback_query_handler(func=lambda call: True)
def callback_button(call):
try:
if call.message:
cid = message.chat.id
if call.data == '1':
pass
elif call.data == '2':
pass
except:
pass
解决方法
事实证明,InlineKeyboardButton
对象不会将回调作为 ReplyKeyboardButton
对象返回。
InlineKeyboardButton
作为消息发送,它们将出现在 message_handler 中
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。