skip to Main Content

I have such replying keyboard:

keyboard = [
        [
            InlineKeyboardButton("Play with a bot", callback_data=str(ONE)),
            InlineKeyboardButton("Results", callback_data=str(TWO)),
        ]
    ]
    reply_markup = InlineKeyboardMarkup(keyboard)

    update.message.reply_text(None, reply_markup=reply_markup)

It gives me such a result:

enter image description here

How can I get rid of the first "null" string?

2

Answers


  1. You’re passing None as the Title, resulting in null, you should pass a message as it’s required for the send_message and reply_text method:

    text (str) – Text of the message to be sent. Max 4096 characters after entities parsing. Also found as telegram.constants.MAX_MESSAGE_LENGTH.

    So, since you’re required to add some text, pass it as the a extra argument to the function:

    keyboard = [
        [
            InlineKeyboardButton("Play with a bot", callback_data='a'),
            InlineKeyboardButton("Results", callback_data='b'),
        ]
    ]
    reply_markup = InlineKeyboardMarkup(keyboard)
    update.message.reply_text('How can I help?', reply_markup=reply_markup)
    

    enter image description here


    As described in my comment, sending a separate message also requires some text

    Login or Signup to reply.
  2. You cannot send an inline keyboard without text or any type of media supported by Telegram (photos, videos, audios etc). If instead you only want to update the inline keyboard without changing the message content, use the editMessageReplyMarkup method. This will update the inline keyboard leaving the original message intact.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search