painor / telethon-secret-chat

Secret chat plugin for telethon
MIT License
44 stars 10 forks source link

Lib somehow affects the classic TLSchema that causes problems #11

Closed hikariatama closed 2 years ago

hikariatama commented 2 years ago

Traceback:

File "/home/ftg/.local/lib/python3.8/site-packages/telethon/tl/functions/messages.py", line 1037, in <genexpr>
    b'' if self.entities is None or self.entities is False else b''.join((b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.entities)),b''.join(x._bytes() for x in self.entities))),
  File "/home/ftg/.local/lib/python3.8/site-packages/telethon/tl/tlobject.py", line 206, in _bytes
    raise NotImplementedError
NotImplementedError

Error occured in classic functionality of https://github.com/GeekTG/Friendly-Telegram, to be exact, here: https://github.com/GeekTG/Friendly-Telegram/blob/master/friendly-telegram/dispatcher.py#L142

For more info, read this branch https://t.me/TelethonChat/429512

painor commented 2 years ago

huh that's weird, can you create a small reproducible code maybe I can track it better that way,

hikariatama commented 2 years ago

huh that's weird, can you create a small reproducible code maybe I can track it better that way,

Mh, actually I'm one of the contributors to GeekTG userbot, this bug appeared with my module SecretChat (https://mods.hikariatama.ru/view/secret_chat.py), the Exception was thrown by independent from modules code with simple message.edit. I'll dive in a bit in next few days and comment here about result. As I think, secret_schema somehow affects classic one in the way that when you receive an update from telethon, standard message.entities is replaced with secret_schema entities.

painor commented 2 years ago

The issue is in this line https://github.com/painor/telethon-secret-chat/blob/master/telethon_secret_chat/secret_chat_manager.py#L22

apparently some classes have the same constructor ID in both the normal TL schema and the secret TL schema so they get overridden.

An easy solution would be to update the dict with only constructors that are not in the normal TL schema already, If you think you can do this please open up a PR.

hikariatama commented 2 years ago

The issue is in this line https://github.com/painor/telethon-secret-chat/blob/master/telethon_secret_chat/secret_chat_manager.py#L22

apparently some classes have the same constructor ID in both the normal TL schema and the secret TL schema so they get overridden.

An easy solution would be to update the dict with only constructors that are not in the normal TL schema already, If you think you can do this please open up a PR.

I'm not geek in python actually 😅 I will try to do this, but not sure. If you just remove the constructors, wouldn't it cause the problems?

painor commented 2 years ago

if you only remove the duplicate constructors it wouldn't cause an issue.

We only want to add constructors from this library that are not already in telethon.

hikariatama commented 2 years ago

if you only remove the duplicate constructors it wouldn't cause an issue.

We only want to add constructors from this library that are not already in telethon.

K, I'll try soon. Don't close the issue, please, in case we can chat and/or to update status of update

hikariatama commented 2 years ago

Ig this issue can be closed now, bc the PR with fixes is already in GH.