This repository was archived by the owner on Dec 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed
Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -166,15 +166,27 @@ def pack_inline_message_id(msg_id: "raw.base.InputBotInlineMessageID"):
166166 return base64 .urlsafe_b64encode (inline_message_id_packed ).decode ().rstrip ("=" )
167167
168168
169- def unpack_inline_message_id (inline_message_id : str ) -> "raw.types.InputBotInlineMessageID" :
170- r = inline_message_id + "=" * (- len (inline_message_id ) % 4 )
171- r = struct .unpack ("<iqq" , base64 .b64decode (r , altchars = b"-_" ))
172-
173- return raw .types .InputBotInlineMessageID (
174- dc_id = r [0 ],
175- id = r [1 ],
176- access_hash = r [2 ]
177- )
169+ def unpack_inline_message_id (inline_message_id : str ) -> "raw.base.InputBotInlineMessageID" :
170+ padded = inline_message_id + "=" * (- len (inline_message_id ) % 4 )
171+ decoded = base64 .urlsafe_b64decode (padded )
172+
173+ if len (decoded ) == 20 :
174+ unpacked = struct .unpack ("<iqq" , decoded )
175+
176+ return raw .types .InputBotInlineMessageID (
177+ dc_id = unpacked [0 ],
178+ id = unpacked [1 ],
179+ access_hash = unpacked [2 ]
180+ )
181+ else :
182+ unpacked = struct .unpack ("<iqiq" , decoded )
183+
184+ return raw .types .InputBotInlineMessageID64 (
185+ dc_id = unpacked [0 ],
186+ owner_id = unpacked [1 ],
187+ id = unpacked [2 ],
188+ access_hash = unpacked [3 ]
189+ )
178190
179191
180192MIN_CHANNEL_ID = - 1002147483647
You can’t perform that action at this time.
0 commit comments