Skip to content

Commit 1d55eaa

Browse files
committed
Fix inline keyboard buttons with empty values
1 parent a47e079 commit 1d55eaa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pyrogram/types/bots_and_keyboards/inline_keyboard_button.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def read(b: "raw.base.KeyboardButton"):
129129
)
130130

131131
async def write(self, client: "pyrogram.Client"):
132-
if self.callback_data:
132+
if self.callback_data is not None:
133133
# Telegram only wants bytes, but we are allowed to pass strings too, for convenience.
134134
data = bytes(self.callback_data, "utf-8") if isinstance(self.callback_data, str) else self.callback_data
135135

@@ -138,32 +138,32 @@ async def write(self, client: "pyrogram.Client"):
138138
data=data
139139
)
140140

141-
if self.url:
141+
if self.url is not None:
142142
return raw.types.KeyboardButtonUrl(
143143
text=self.text,
144144
url=self.url
145145
)
146146

147-
if self.login_url:
147+
if self.login_url is not None:
148148
return self.login_url.write(
149149
text=self.text,
150150
bot=await client.resolve_peer(self.login_url.bot_username)
151151
)
152152

153-
if self.switch_inline_query:
153+
if self.switch_inline_query is not None:
154154
return raw.types.KeyboardButtonSwitchInline(
155155
text=self.text,
156156
query=self.switch_inline_query
157157
)
158158

159-
if self.switch_inline_query_current_chat:
159+
if self.switch_inline_query_current_chat is not None:
160160
return raw.types.KeyboardButtonSwitchInline(
161161
text=self.text,
162162
query=self.switch_inline_query_current_chat,
163163
same_peer=True
164164
)
165165

166-
if self.callback_game:
166+
if self.callback_game is not None:
167167
return raw.types.KeyboardButtonGame(
168168
text=self.text
169169
)

0 commit comments

Comments
 (0)