LonamiWebs / Telethon

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

Self destructing photo, dont download. #4391

Open vanylav opened 2 weeks ago

vanylav commented 2 weeks ago

Code that causes the issue

...
if message.media:
                path = ""
                try:
                    print(message)
                    save = await self.client.get_entity(-4222209239)
                    path = await self.client.download_media(message)
                    await self.client.send_file(save, path, caption=f"Save: {user.first_name}")
                    os.remove(path)
                except Exception as er:
                    await self.client.send_message('me', 'Error: '+str(er))
                    try:
                        await self.client.send_file('me', path, caption=f"Save: {user.first_name}")
                        os.remove(path)
                    except:
                        pass
...

Expected behavior

A self-destructing photo arrives (to be viewed once), the code downloads the image and sends it to another channel.

Actual behavior

A self-destructing photo arrives (to be viewed once), the code gives an error that the media type is not supported.

Traceback

Message(id=1541508, peer_id=PeerUser(user_id=6758782663), date=datetime.datetime(2024, 6, 16, 8, 34, 40, tzinfo=datetime.timezone.utc), message='', out=False, mentioned=False, media_unread=True, silent=False, post=False, from_scheduled=False, legacy=False, edit_hide=False, pinned=False, noforwards=False, from_id=None, fwd_from=None, via_bot_id=None, reply_to=None, media=MessageMediaUnsupported(), reply_markup=None, entities=[], views=None, forwards=None, replies=None, edit_date=None, post_author=None, grouped_id=None, reactions=None, restriction_reason=[], ttl_period=None)

Telethon version

1.27.0

Python version

3.10.12

Operating system (including distribution name and version)

Ubuntu 22.04

Other details

No response

Checklist

vanylav commented 2 weeks ago

Forgot to add, the code works fine for self-destructing photos with a 3s, 10s, 30s delay.

Lonami commented 2 weeks ago

Telethon version 1.27.0

Only the latest version is supported.

vanylav commented 2 weeks ago

I also tried it on 1.36.0. UPD: Should I create a new issue?

Lonami commented 2 weeks ago

Stil unlikely there's anything the library can do for media unsupported until an update.

drizzo0 commented 6 days ago

Use v2

Lonami commented 5 days ago

v2 is not ready for use (and the library version doesn't matter, only the layer used).