Skip to content

Commit

Permalink
pyrofork: Add subscription_period and subscription_price parameters t…
Browse files Browse the repository at this point in the history
…o export_chat_invite and Chat.export_invite_link

Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Aug 18, 2024
1 parent 7ce0a87 commit 66818e9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
16 changes: 15 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,13 @@ 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.
for now, only 30 days is supported (30*24*60*60).
subscription_price (``int``, *optional*):
Subscription price (stars).
Returns:
``str``: On success, the new invite link as string is returned.
Expand All @@ -60,7 +70,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
20 changes: 18 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,26 @@ async def export_invite_link(self):
chat.export_invite_link()
Parameters:
subscription_period (``int``, *optional*):
Channel members only. Date when the subscription expires.
for now, only 30 days is supported (30*24*60*60).
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 66818e9

Please sign in to comment.