From b45f2f4595a2b21e9d45d4708b88a6514bd4e728 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 17 Mar 2018 19:24:27 +0100 Subject: [PATCH] Add support for sending messages using joinchat links and hashes --- pyrogram/client/client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index ab0d4ab7..a9aa2e9c 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -23,6 +23,7 @@ import math import mimetypes import os import re +import struct import threading import time from collections import namedtuple @@ -916,6 +917,12 @@ class Client: if peer_id in ("self", "me"): 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("@+") try: