[QUESTION] AttributeError: '_io.BufferedReader' object has no attribute 'parse_mode' on Bot.edit_message_media #2405
-
Code example: from time import sleep
from telegram import Bot
token = "xxxxxxx:yyyyyyyyyyyyyyy"
tgid = 0
path1 = "1.png"
path2 = "2.png"
message = Bot(token).send_photo(tgid, open(path1, "rb"))
sleep(2)
Bot(token).edit_message_media(tgid, message.message_id, media=open(path2, "rb")) Bot should send first picture, and after 2 secconds change it to seccond
ConfigurationOperating System: Windows 10
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi. As you can see in the docs of bot = Bot(token)
message = bot.send_photo(…)
bot.edit_message_media or better yet, just call |
Beta Was this translation helpful? Give feedback.
-
But doesn't InputMediaPhoto inherit from InputMedia? Even if I use message.edit_media it shows me same exceprion bot = Bot(token)
message = bot.send_photo(tgid, open(path1, "rb"))
sleep(2)
message.edit_media(media=open(path2, "rb"))
|
Beta Was this translation helpful? Give feedback.
-
yes. that's the point ;)
As per the docs I pointed you to,
because you still pass an open file instead of an |
Beta Was this translation helpful? Give feedback.
yes. that's the point ;)
As per the docs I pointed you to,
message.edit_media(**kwargs)
is equivalent tobot.edit_message_media(chat_id=message.chat_id, message_id=message.message_id, **kwargs)
because you still pass an open file instead of an
InputMediaPhoto
instance ;)