diff --git a/readthedocs/misc/v2-migration-guide.rst b/readthedocs/misc/v2-migration-guide.rst index 51f161b5..514aa8b8 100644 --- a/readthedocs/misc/v2-migration-guide.rst +++ b/readthedocs/misc/v2-migration-guide.rst @@ -195,6 +195,19 @@ Additionally, the ``custom.File.id`` property is gone (which used to provide acc // this should lessen the impact of the removal of this feature +Removal of several utility methods +---------------------------------- + +The following ``utils`` methods no longer exist or have been made private: + +* ``utils.resolve_bot_file_id``. It was half-broken. +* ``utils.pack_bot_file_id``. It was half-broken. +* ``utils.resolve_invite_link``. It has been broken for a while, so this just makes its removal + official (see `issue #1723 `__). + +// TODO provide the new clean utils + + The custom.Message class and the way it is used has changed ----------------------------------------------------------- diff --git a/telethon/_misc/utils.py b/telethon/_misc/utils.py index 8f4667b8..a92aff0b 100644 --- a/telethon/_misc/utils.py +++ b/telethon/_misc/utils.py @@ -1115,43 +1115,6 @@ def _encode_telegram_base64(string): return None # not valid base64, not valid ascii, not a string -def resolve_invite_link(link): - """ - Resolves the given invite link. Returns a tuple of - ``(link creator user id, global chat id, random int)``. - - Note that for broadcast channels or with the newest link format, the link - creator user ID will be zero to protect their identity. Normal chats and - megagroup channels will have such ID. - - Note that the chat ID may not be accurate for chats with a link that were - upgraded to megagroup, since the link can remain the same, but the chat - ID will be correct once a new link is generated. - """ - link_hash, is_link = parse_username(link) - if not is_link: - # Perhaps the user passed the link hash directly - link_hash = link - - # Little known fact, but invite links with a - # hex-string of bytes instead of base64 also works. - if re.match(r'[a-fA-F\d]+', link_hash) and len(link_hash) in (24, 32): - payload = bytes.fromhex(link_hash) - else: - payload = _decode_telegram_base64(link_hash) - - try: - if len(payload) == 12: - return (0, *struct.unpack('>LQ', payload)) - elif len(payload) == 16: - return struct.unpack('>LLQ', payload) - else: - pass - except (struct.error, TypeError): - pass - return None, None, None - - def resolve_inline_message_id(inline_msg_id): """ Resolves an inline message ID. Returns a tuple of diff --git a/telethon/sessions/memory.py b/telethon/sessions/memory.py index 82067101..d3d6e22a 100644 --- a/telethon/sessions/memory.py +++ b/telethon/sessions/memory.py @@ -204,10 +204,6 @@ class MemorySession(Session): username, invite = utils.parse_username(key) if username and not invite: result = self.get_entity_rows_by_username(username) - else: - tup = utils.resolve_invite_link(key)[1] - if tup: - result = self.get_entity_rows_by_id(tup, exact=False) elif isinstance(key, int): result = self.get_entity_rows_by_id(key, exact)