Skip to content

Commit 54ad043

Browse files
committed
Add get_chat_invite_link method
1 parent a85ca8c commit 54ad043

3 files changed

Lines changed: 60 additions & 3 deletions

File tree

compiler/docs/compiler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,11 @@ def get_title_list(s: str) -> list:
245245
revoke_chat_invite_link
246246
delete_chat_invite_link
247247
delete_all_chat_invite_links
248-
get_chat_invite_links
249-
get_chat_invite_links_count
248+
get_chat_invite_link
250249
get_chat_invite_link_members
251250
get_chat_invite_link_members_count
251+
get_chat_invite_links
252+
get_chat_invite_links_count
252253
get_chat_admins_with_invite_links
253254
""",
254255
contacts="""

pyrogram/methods/invite_links/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .edit_chat_invite_link import EditChatInviteLink
2424
from .export_chat_invite_link import ExportChatInviteLink
2525
from .get_chat_admins_with_invite_links import GetChatAdminsWithInviteLinks
26+
from .get_chat_invite_link import GetChatInviteLink
2627
from .get_chat_invite_link_members import GetChatInviteLinkMembers
2728
from .get_chat_invite_link_members_count import GetChatInviteLinkMembersCount
2829
from .get_chat_invite_links import GetChatInviteLinks
@@ -41,6 +42,7 @@ class InviteLinks(
4142
ExportChatInviteLink,
4243
DeleteAllChatInviteLinks,
4344
GetChatInviteLinksCount,
44-
GetChatAdminsWithInviteLinks
45+
GetChatAdminsWithInviteLinks,
46+
GetChatInviteLink
4547
):
4648
pass
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-2021 Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from typing import Union
20+
21+
from pyrogram import raw
22+
from pyrogram import types
23+
from pyrogram.scaffold import Scaffold
24+
25+
26+
class GetChatInviteLink(Scaffold):
27+
async def get_chat_invite_link(
28+
self,
29+
chat_id: Union[int, str],
30+
invite_link: str,
31+
) -> "types.ChatInviteLink":
32+
"""Get detailed information about a chat invite link.
33+
34+
Parameters:
35+
chat_id (``int`` | ``str``):
36+
Unique identifier for the target chat or username of the target channel/supergroup
37+
(in the format @username).
38+
39+
invite_link (str):
40+
The invite link.
41+
42+
Returns:
43+
:obj:`~pyrogram.types.ChatInviteLink`: On success, the invite link is returned.
44+
"""
45+
r = await self.send(
46+
raw.functions.messages.GetExportedChatInvite(
47+
peer=await self.resolve_peer(chat_id),
48+
link=invite_link
49+
)
50+
)
51+
52+
users = {i.id: i for i in r.users}
53+
54+
return types.ChatInviteLink._parse(self, r.invite, users)

0 commit comments

Comments
 (0)