2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Add support for sending messages using joinchat links and hashes

This commit is contained in:
Dan 2018-03-17 19:24:27 +01:00
parent 1da39efa2e
commit b45f2f4595

View File

@ -23,6 +23,7 @@ import math
import mimetypes import mimetypes
import os import os
import re import re
import struct
import threading import threading
import time import time
from collections import namedtuple from collections import namedtuple
@ -916,6 +917,12 @@ class Client:
if peer_id in ("self", "me"): if peer_id in ("self", "me"):
return InputPeerSelf() return InputPeerSelf()
match = self.INVITE_LINK_RE.match(peer_id)
if match:
decoded = base64.b64decode(match.group(1) + "=" * (-len(match.group(1)) % 4), altchars="-_")
return self.resolve_peer(struct.unpack(">2iq", decoded)[1])
peer_id = peer_id.lower().strip("@+") peer_id = peer_id.lower().strip("@+")
try: try: