From b02a22eaa3637c0b63e49662b0bbed95245bcb3c Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 7 Nov 2020 11:59:56 +0100 Subject: [PATCH] Fix .get_buttons failing for some messages sent by the bot Closes #1619. --- telethon/tl/custom/message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index 019ab3f8..d7203a03 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -1080,7 +1080,8 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC): for row in self.reply_markup.rows: for button in row.buttons: if isinstance(button, types.KeyboardButtonSwitchInline): - if button.same_peer: + # no via_bot_id means the bot sent the message itself (#1619) + if button.same_peer or not self.via_bot_id: bot = self.input_sender if not bot: raise ValueError('No input sender')