mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-07 05:30:20 +03:00
Make resolve_inline_message_id more convenient
This commit is contained in:
parent
f2f5409dcb
commit
01d3cbd705
|
@ -939,15 +939,20 @@ def resolve_invite_link(link):
|
||||||
def resolve_inline_message_id(inline_msg_id):
|
def resolve_inline_message_id(inline_msg_id):
|
||||||
"""
|
"""
|
||||||
Resolves an inline message ID. Returns a tuple of
|
Resolves an inline message ID. Returns a tuple of
|
||||||
``(dc id, message id, group id, access hash)``
|
``(message id, peer, dc id, access hash)``
|
||||||
|
|
||||||
Note that ``group_id`` is negated if the message originated from a channel
|
The ``peer`` may either be a :tl:`PeerUser` referencing
|
||||||
otherwise it's the (positive) ID of the sender
|
the user who sent the message via the bot in a private
|
||||||
|
conversation or small group chat, or a :tl:`PeerChannel`
|
||||||
|
if the message was sent in a channel.
|
||||||
|
|
||||||
The ``access_hash`` isn't particularly useful, but it's unpacked nevertheless
|
The ``access_hash`` does not have any use yet.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return struct.unpack('<iiiq', _decode_telegram_base64(inline_msg_id))
|
dc_id, message_id, pid, access_hash = \
|
||||||
|
struct.unpack('<iiiq', _decode_telegram_base64(inline_msg_id))
|
||||||
|
peer = types.PeerChannel(-pid) if pid < 0 else types.PeerUser(pid)
|
||||||
|
return message_id, peer, dc_id, access_hash
|
||||||
except (struct.error, TypeError):
|
except (struct.error, TypeError):
|
||||||
return None, None, None, None
|
return None, None, None, None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user