Search code examples
botstelegram-botchatbotpython-telegram-bot

Telegram Bot InlineKeyboardButton Full Text


I am using InlineKeyboardButton to create buttons in telegram bot, like the following.

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)

In this example, Button 2 text will be truncated to something like "Option 2. Long text here...". I wonder if it's possible to show full text.

Thanks!


Solution

  • On desktops hovering a cursor over such button will display it's full text in tooltip, on mobile pressing and holding such button should do the same.

    You could also reply to the user on this specific callback data with answerCallbackQuery method with text set to your full text (maximum of 200 characters allowed though) and show_alert to true, that will display a popup message to the user.