Reputation: 9119
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:
How can I get rid of the first "null" string?
Upvotes: 3
Views: 6239
Reputation: 43983
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)
As described in my comment, sending a separate message also requires some text
Upvotes: 3
Reputation: 436
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.
Upvotes: 1