mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Update unpack_inline_message_id
This commit is contained in:
parent
6087c2a974
commit
2ad53ec00b
@ -166,14 +166,26 @@ def pack_inline_message_id(msg_id: "raw.base.InputBotInlineMessageID"):
|
|||||||
return base64.urlsafe_b64encode(inline_message_id_packed).decode().rstrip("=")
|
return base64.urlsafe_b64encode(inline_message_id_packed).decode().rstrip("=")
|
||||||
|
|
||||||
|
|
||||||
def unpack_inline_message_id(inline_message_id: str) -> "raw.types.InputBotInlineMessageID":
|
def unpack_inline_message_id(inline_message_id: str) -> "raw.base.InputBotInlineMessageID":
|
||||||
r = inline_message_id + "=" * (-len(inline_message_id) % 4)
|
padded = inline_message_id + "=" * (-len(inline_message_id) % 4)
|
||||||
r = struct.unpack("<iqq", base64.b64decode(r, altchars=b"-_"))
|
decoded = base64.urlsafe_b64decode(padded)
|
||||||
|
|
||||||
|
if len(decoded) == 20:
|
||||||
|
unpacked = struct.unpack("<iqq", decoded)
|
||||||
|
|
||||||
return raw.types.InputBotInlineMessageID(
|
return raw.types.InputBotInlineMessageID(
|
||||||
dc_id=r[0],
|
dc_id=unpacked[0],
|
||||||
id=r[1],
|
id=unpacked[1],
|
||||||
access_hash=r[2]
|
access_hash=unpacked[2]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
unpacked = struct.unpack("<iqiq", decoded)
|
||||||
|
|
||||||
|
return raw.types.InputBotInlineMessageID64(
|
||||||
|
dc_id=unpacked[0],
|
||||||
|
owner_id=unpacked[1],
|
||||||
|
id=unpacked[2],
|
||||||
|
access_hash=unpacked[3]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user