LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.69k stars 1.38k forks source link

send_file with list of links #4262

Open MAKMED1337 opened 9 months ago

MAKMED1337 commented 9 months ago

Code that causes the issue

await bot.send_file(user_id, file=[image_url])

Expected behavior

I was expecting that this will send file normal as

await bot.send_file(user_id, file=image_url)

But it also doesn't work with multiple links

Actual behavior

Throws exception

Traceback

File "/usr/local/lib/python3.11/site-packages/telethon/client/uploads.py", line 389, in send_file
  result += await self._send_album(
            ^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/telethon/client/uploads.py", line 504, in _send_album
  result = await self(request)
           ^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/telethon/client/users.py", line 30, in __call__
  return await self._call(self._sender, request, ordered=ordered)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/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.33.0, 1.32.1

Python version

3.11.0

Operating system (including distribution name and version)

Ubuntu 22.04

Other details

No response

Checklist

balthild commented 4 months ago

I encountered same issue. However, I found that sometimes it works.

Doesn't work:

Works: