[Python] Send gif animation by telethon?

Discussão em 'Python' iniciado por Stack, Janeiro 31, 2025.

  1. Stack

    Stack Membro Participativo

    I use the telethon library to send media files. Videos and images work fine through

    async def send_media(self, chat_id: int):
    async with self._get_client() as client:
    chat = await client.get_entity(chat_id)
    files = ["/my_path/1.mov", "/my_path/2.png"]
    msg = await client.send_file(
    chat,
    file=files,
    caption="<b>Bold</b>",
    parse_mode="html",
    allow_cache=True
    )


    Well, if I try to send a gif animation

    files = ["/my_path/3.gif"]


    , I get an error.

    telethon.errors.rpcerrorlist.MediaInvalidError: Media invalid (caused by UploadMediaRequest)


    Maybe there is a separate way to send an animation? I couldn't find anything in the documentation.

    I would like to get the same result as from aiogram bot.send_animation()

    Continue reading...

Compartilhe esta Página