def write(self): if self.callback_data: return KeyboardButtonCallback(self.text, self.callback_data) if self.url: return KeyboardButtonUrl(self.text, self.url) if self.switch_inline_query: return KeyboardButtonSwitchInline(self.text, self.switch_inline_query) if self.switch_inline_query_current_chat: return KeyboardButtonSwitchInline(self.text, self.switch_inline_query_current_chat, same_peer=True)
def write(self): if self.callback_data is not None: return KeyboardButtonCallback(text=self.text, data=self.callback_data) if self.url is not None: return KeyboardButtonUrl(text=self.text, url=self.url) if self.switch_inline_query is not None: return KeyboardButtonSwitchInline(text=self.text, query=self.switch_inline_query) if self.switch_inline_query_current_chat is not None: return KeyboardButtonSwitchInline( text=self.text, query=self.switch_inline_query_current_chat, same_peer=True) if self.callback_game is not None: return KeyboardButtonGame(text=self.text)
def write(self): 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 return KeyboardButtonCallback(text=self.text, data=data) if self.url is not None: return KeyboardButtonUrl(text=self.text, url=self.url) if self.switch_inline_query is not None: return KeyboardButtonSwitchInline(text=self.text, query=self.switch_inline_query) if self.switch_inline_query_current_chat is not None: return KeyboardButtonSwitchInline( text=self.text, query=self.switch_inline_query_current_chat, same_peer=True ) if self.callback_game is not None: return KeyboardButtonGame(text=self.text)