You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bot should be able to send message with image from url.
Actual behavior
telethon.errors.rpcerrorlist.MediaInvalidError: Media invalid (caused by SendMultiMediaRequest)
I think the reason is that there is a space and round brackets in my image url. I've tried to use "from urllib.parse import quote" but just received another error: ValueError: Failed to convert quoted_url to media. Not an existing file, an HTTP URL or a valid bot-API-like file ID
Traceback
Traceback (most recent call last):
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\updates.py", line 570, in _dispatch_update
await callback(event)
File "C:\Users\user\tg_bot\main.py", line 70, in handle_start_command
await client.send_file(chat_id, urls, caption=message_text)
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\uploads.py", line 389, in send_file
result += await self._send_album(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\uploads.py", line 504, in _send_album
result = await self(request)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\users.py", line 30, in call
return await self._call(self._sender, request, ordered=ordered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\users.py", line 87, in _call
result = await future
^^^^^^^^^^^^
telethon.errors.rpcerrorlist.MediaInvalidError: Media invalid (caused by SendMultiMediaRequest)
Telethon version
1.36.0
Python version
3.12.6
Operating system (including distribution name and version)
Windows 11
Other details
message_text, urls = shop_check.get_upcoming_data()
This method shares string in message_text and list of urls in urls. One of urls happened to have space and round brackets in it.
Checklist
The error is in the library's code, and not in my own.
I have searched for this issue before posting it and there isn't an open duplicate.
I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.
The text was updated successfully, but these errors were encountered:
I don't plan to look into this any time soon. Though, the URL doesn't have an extension, so perhaps the library simply fails to send the proper information.
You can try appending something like #a.jpg or ?a.jpg. The server shouldn't care, but the library would know the type.
Or you can construct the correct input media directly (don't remember exactly how, but it's somewhere in the code).
Code that causes the issue
async def handle_start_command(event):
message_text, urls = shop_check.get_upcoming_data()
chat_id = event.message.peer_id
if isinstance(chat_id, (PeerUser, PeerChat, PeerChannel)):
await client.send_file(chat_id, urls, caption=message_text)
Expected behavior
Bot should be able to send message with image from url.
Actual behavior
telethon.errors.rpcerrorlist.MediaInvalidError: Media invalid (caused by SendMultiMediaRequest)
I think the reason is that there is a space and round brackets in my image url. I've tried to use "from urllib.parse import quote" but just received another error:
ValueError: Failed to convert quoted_url to media. Not an existing file, an HTTP URL or a valid bot-API-like file ID
Traceback
Traceback (most recent call last):
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\updates.py", line 570, in _dispatch_update
await callback(event)
File "C:\Users\user\tg_bot\main.py", line 70, in handle_start_command
await client.send_file(chat_id, urls, caption=message_text)
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\uploads.py", line 389, in send_file
result += await self._send_album(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\uploads.py", line 504, in _send_album
result = await self(request)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\users.py", line 30, in call
return await self._call(self._sender, request, ordered=ordered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\tg_bot\tg_bot_venv\Lib\site-packages\telethon\client\users.py", line 87, in _call
result = await future
^^^^^^^^^^^^
telethon.errors.rpcerrorlist.MediaInvalidError: Media invalid (caused by SendMultiMediaRequest)
Telethon version
1.36.0
Python version
3.12.6
Operating system (including distribution name and version)
Windows 11
Other details
message_text, urls = shop_check.get_upcoming_data()
This method shares string in message_text and list of urls in urls. One of urls happened to have space and round brackets in it.
Checklist
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip
and triggered the bug in the latest version.The text was updated successfully, but these errors were encountered: