Telegram Bot InlineKeyboardButton 全文

Telegram Bot InlineKeyboardButton Full Text

我正在使用 InlineKeyboardButton 在电报机器人中创建按钮,如下所示。

keyboard = [[InlineKeyboardButton("Option 1", callback_data='1'),
             InlineKeyboardButton("Option 2. Long text here. Long text here. Long text here.", callback_data='2'), 
             InlineKeyboardButton("Option 3", callback_data='3')]]

reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Please choose:', reply_markup=reply_markup)

在此示例中,按钮 2 的文本将被截断为类似 "Option 2. Long text here..." 的内容。不知道能不能显示全文

谢谢!

在台式机上,将光标悬停在此类按钮上会在工具提示中显示其全文,在移动设备上按住此类按钮应该做同样的事情。

您还可以使用 answerCallbackQuery 方法将 text 设置为您的全文(不过最多允许 200 个字符)并使用 answerCallbackQuery 方法回复用户show_alerttrue,这将向用户显示弹出消息。

只要让消息在按钮上方的长度与您要在按钮 2 中使用的文本一样长即可。

它拉伸了按钮的长度。