Skip to content

Commit

Permalink
pyrofork: subscription_period and subscription_price to export_chat_i…
Browse files Browse the repository at this point in the history
…nvite and Chat.export_invite_link

Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Aug 18, 2024
1 parent 7ce0a87 commit c3b2d5d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
15 changes: 14 additions & 1 deletion pyrogram/methods/invite_links/export_chat_invite_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
import pyrogram
from pyrogram import raw
from pyrogram import types
from pyrogram import utils


class ExportChatInviteLink:
async def export_chat_invite_link(
self: "pyrogram.Client",
chat_id: Union[int, str],
subscription_period: int = None,
subscription_price: int = None
) -> "types.ChatInviteLink":
"""Generate a new primary invite link for a chat; any previously generated primary link is revoked.
Expand All @@ -48,6 +51,12 @@ async def export_chat_invite_link(
(in the format @username).
You can also use chat public link in form of *t.me/<username>* (str).
subscription_period (``int``, *optional*):
Date when the subscription will expire.
subscription_price (``int``, *optional*):
Subscription price (stars).
Returns:
``str``: On success, the new invite link as string is returned.
Expand All @@ -60,7 +69,11 @@ async def export_chat_invite_link(
r = await self.invoke(
raw.functions.messages.ExportChatInvite(
peer=await self.resolve_peer(chat_id),
legacy_revoke_permanent=True
legacy_revoke_permanent=True,
subscription_pricing=raw.types.StarsSubscriptionPricing(
period=subscription_period,
amount=subscription_price
)
)
)

Expand Down
19 changes: 17 additions & 2 deletions pyrogram/types/user_and_chats/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,11 @@ async def leave(self):

return await self._client.leave_chat(self.id)

async def export_invite_link(self):
async def export_invite_link(
self,
subscription_period: int = None,
subscription_price: int = None
):
"""Bound method *export_invite_link* of :obj:`~pyrogram.types.Chat`.
Use as a shortcut for:
Expand All @@ -1085,14 +1089,25 @@ async def export_invite_link(self):
chat.export_invite_link()
Parameters:
subscription_period (``int``, *optional*):
Channel members only. Date when the subscription expires.
subscription_price (``int``, *optional*):
Channel members only. Price of the subscription in the smallest units of the currency.
Returns:
``str``: On success, the exported invite link is returned.
Raises:
ValueError: In case the chat_id belongs to a user.
"""

return await self._client.export_chat_invite_link(self.id)
return await self._client.export_chat_invite_link(
self.id,
subscription_period=subscription_period,
subscription_price=subscription_price
)

async def get_member(
self,
Expand Down

0 comments on commit c3b2d5d

Please sign in to comment.