mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1161 from yarreg/feature/invite-link-api
Create_chat_invite_link, edit_chat_invite_link, revoke_chat_invite_link methods
This commit is contained in:
commit
d3998dfadb
@ -1246,6 +1246,46 @@ class TeleBot:
|
|||||||
"""
|
"""
|
||||||
return apihelper.set_chat_permissions(self.token, chat_id, permissions)
|
return apihelper.set_chat_permissions(self.token, chat_id, permissions)
|
||||||
|
|
||||||
|
def create_chat_invite_link(self, chat_id, expire_date=None, member_limit=None):
|
||||||
|
"""
|
||||||
|
Use this method to create an additional invite link for a chat.
|
||||||
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
|
|
||||||
|
:param chat_id: Id: Unique identifier for the target chat or username of the target channel
|
||||||
|
(in the format @channelusername)
|
||||||
|
:expire_date: Point in time (Unix timestamp) when the link will expire
|
||||||
|
:member_limit: Maximum number of users that can be members of the chat simultaneously
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return apihelper.create_chat_invite_link(self.token, chat_id, expire_date, member_limit)
|
||||||
|
|
||||||
|
def edit_chat_invite_link(self, chat_id, invite_link, expire_date=None, member_limit=None):
|
||||||
|
"""
|
||||||
|
Use this method to edit a non-primary invite link created by the bot.
|
||||||
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
|
|
||||||
|
:param chat_id: Id: Unique identifier for the target chat or username of the target channel
|
||||||
|
(in the format @channelusername)
|
||||||
|
:invite_link: The invite link to edit
|
||||||
|
:expire_date: Point in time (Unix timestamp) when the link will expire
|
||||||
|
:member_limit: Maximum number of users that can be members of the chat simultaneously
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return apihelper.edit_chat_invite_link(self.token, chat_id, invite_link, expire_date, member_limit)
|
||||||
|
|
||||||
|
def revoke_chat_invite_link(self, chat_id, invite_link):
|
||||||
|
"""
|
||||||
|
Use this method to revoke an invite link created by the bot.
|
||||||
|
Note: If the primary link is revoked, a new link is automatically generated The bot must be an administrator
|
||||||
|
in the chat for this to work and must have the appropriate admin rights.
|
||||||
|
|
||||||
|
:param chat_id: Id: Unique identifier for the target chat or username of the target channel
|
||||||
|
(in the format @channelusername)
|
||||||
|
:invite_link: The invite link to revoke
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return apihelper.revoke_chat_invite_link(self.token, chat_id, invite_link)
|
||||||
|
|
||||||
def export_chat_invite_link(self, chat_id):
|
def export_chat_invite_link(self, chat_id):
|
||||||
"""
|
"""
|
||||||
Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator
|
Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator
|
||||||
|
@ -843,6 +843,50 @@ def set_chat_permissions(token, chat_id, permissions):
|
|||||||
return _make_request(token, method_url, params=payload, method='post')
|
return _make_request(token, method_url, params=payload, method='post')
|
||||||
|
|
||||||
|
|
||||||
|
def create_chat_invite_link(token, chat_id, expire_date, member_limit):
|
||||||
|
method_url = 'createChatInviteLink'
|
||||||
|
payload = {
|
||||||
|
'chat_id': chat_id
|
||||||
|
}
|
||||||
|
|
||||||
|
if expire_date is not None:
|
||||||
|
payload['expire_date'] = expire_date
|
||||||
|
if isinstance(payload['expire_date'], datetime):
|
||||||
|
payload['expire_date'] = payload['expire_date'].timestamp()
|
||||||
|
|
||||||
|
if member_limit is not None:
|
||||||
|
payload['member_limit'] = member_limit
|
||||||
|
|
||||||
|
return _make_request(token, method_url, params=payload, method='post')
|
||||||
|
|
||||||
|
|
||||||
|
def edit_chat_invite_link(token, chat_id, invite_link, expire_date, member_limit):
|
||||||
|
method_url = 'editChatInviteLink'
|
||||||
|
payload = {
|
||||||
|
'chat_id': chat_id,
|
||||||
|
'invite_link': invite_link
|
||||||
|
}
|
||||||
|
|
||||||
|
if expire_date is not None:
|
||||||
|
payload['expire_date'] = expire_date
|
||||||
|
if isinstance(payload['expire_date'], datetime):
|
||||||
|
payload['expire_date'] = payload['expire_date'].timestamp()
|
||||||
|
|
||||||
|
if member_limit is not None:
|
||||||
|
payload['member_limit'] = member_limit
|
||||||
|
|
||||||
|
return _make_request(token, method_url, params=payload, method='post')
|
||||||
|
|
||||||
|
|
||||||
|
def revoke_chat_invite_link(token, chat_id, invite_link):
|
||||||
|
method_url = 'revokeChatInviteLink'
|
||||||
|
payload = {
|
||||||
|
'chat_id': chat_id,
|
||||||
|
'invite_link': invite_link
|
||||||
|
}
|
||||||
|
return _make_request(token, method_url, params=payload, method='post')
|
||||||
|
|
||||||
|
|
||||||
def export_chat_invite_link(token, chat_id):
|
def export_chat_invite_link(token, chat_id):
|
||||||
method_url = 'exportChatInviteLink'
|
method_url = 'exportChatInviteLink'
|
||||||
payload = {'chat_id': chat_id}
|
payload = {'chat_id': chat_id}
|
||||||
|
Loading…
Reference in New Issue
Block a user