From 1d55eaa1ba6e39eca7883a829aba802c0a8f362b Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 21 Mar 2021 18:57:06 +0100 Subject: [PATCH] Fix inline keyboard buttons with empty values --- .../bots_and_keyboards/inline_keyboard_button.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py b/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py index 444eb5da..84d70642 100644 --- a/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py +++ b/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py @@ -129,7 +129,7 @@ class InlineKeyboardButton(Object): ) async def write(self, client: "pyrogram.Client"): - if self.callback_data: + if self.callback_data is not None: # Telegram only wants bytes, but we are allowed to pass strings too, for convenience. data = bytes(self.callback_data, "utf-8") if isinstance(self.callback_data, str) else self.callback_data @@ -138,32 +138,32 @@ class InlineKeyboardButton(Object): data=data ) - if self.url: + if self.url is not None: return raw.types.KeyboardButtonUrl( text=self.text, url=self.url ) - if self.login_url: + if self.login_url is not None: return self.login_url.write( text=self.text, bot=await client.resolve_peer(self.login_url.bot_username) ) - if self.switch_inline_query: + if self.switch_inline_query is not None: return raw.types.KeyboardButtonSwitchInline( text=self.text, query=self.switch_inline_query ) - if self.switch_inline_query_current_chat: + if self.switch_inline_query_current_chat is not None: return raw.types.KeyboardButtonSwitchInline( text=self.text, query=self.switch_inline_query_current_chat, same_peer=True ) - if self.callback_game: + if self.callback_game is not None: return raw.types.KeyboardButtonGame( text=self.text )