- Notifications
You must be signed in to change notification settings - Fork5.7k
API 4.4 changes#1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
API 4.4 changes#1464
Changes fromall commits
Commits
Show all changes
22 commits Select commitHold shift + click to select a range
93a3b03
API 4.4 changes
5002fbb
Adjust existing tests
c97a772
Add test for ChatPermissions
0b8e95e
Fix ChatPermissions, Add convenience method in Chat & test set_chat_p…
b48b8ce
Add can_send_polss to ChatMember and update tests
6572169
Allow for nested MessageEntities in Message._parse_markdown/html, adj…
5d971ec
remove testing relict
Bibo-Joshieb6dc1c
Merge remote-tracking branch 'origin/master' into api-4.4
tsnoam0087ad3
Chat no longer lists all_members_are_administrators in the documentation
tsnoam9499f0d
Use MessageEntitys new equality check (#1465)
Bibo-Joshid34cfb5
Fix unittests
Bibo-Joshi9fc5bd5
Remove unused variable
Bibo-Joshi9d7cf88
Remove deprecation warning for all_members_are_administrators
Bibo-Joshi36879a6
Correct use of Optional in chatpermissions doc string
Bibo-Joshic4538e5
Remove all_members_are_administrators from test_official
Bibo-Joshi7c2378a
Revert "Remove unused variable"
Bibo-Joshic62fbe7
Revert "Use MessageEntitys new equality check (#1465)"
Bibo-Joshib23798d
Revert "remove testing relict"
Bibo-Joshif7c5d60
Revert "Allow for nested MessageEntities in Message._parse_markdown/h…
Bibo-Joshi2581fb0
chat.py: import what we can at the top of the file
tsnoama4f6ad9
chatpermissions: no need to implement to_dict() it does nothing but c…
tsnoamadbac74
Revert "Remove all_members_are_administrators from test_official"
tsnoamFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletionsdocs/source/telegram.chatpermissions.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
telegram.ChatPermissions | ||
======================== | ||
.. autoclass:: telegram.ChatPermissions | ||
:members: | ||
:show-inheritance: |
1 change: 1 addition & 0 deletionsdocs/source/telegram.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletionstelegram/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
70 changes: 46 additions & 24 deletionstelegram/bot.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2685,14 +2685,18 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok, | ||
return result | ||
@log | ||
def restrict_chat_member(self, chat_id, user_id, permissions, until_date=None, | ||
timeout=None, **kwargs): | ||
""" | ||
Use this method to restrict a user in a supergroup. The bot must be an administrator in | ||
the supergroup for this to work and must have the appropriate admin rights. Pass True for | ||
all boolean parameters to lift restrictions from a user. | ||
Note: | ||
Since Bot API 4.4, :attr:`restrict_chat_member` takes the new user permissions in a | ||
single argument of type :class:`telegram.ChatPermissions`. The old way of passing | ||
parameters will not keep working forever. | ||
Args: | ||
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username | ||
of the target supergroup (in the format @supergroupusername). | ||
@@ -2701,15 +2705,7 @@ def restrict_chat_member(self, chat_id, user_id, until_date=None, can_send_messa | ||
will be lifted for the user, unix time. If user is restricted for more than 366 | ||
days or less than 30 seconds from the current time, they are considered to be | ||
restricted forever. | ||
permissions (:class:`telegram.ChatPermissions`): New user permissions. | ||
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as | ||
the read timeout from the server (instead of the one specified during creation of | ||
the connection pool). | ||
@@ -2720,24 +2716,15 @@ def restrict_chat_member(self, chat_id, user_id, until_date=None, can_send_messa | ||
Raises: | ||
:class:`telegram.TelegramError` | ||
""" | ||
url = '{0}/restrictChatMember'.format(self.base_url) | ||
data = {'chat_id': chat_id, 'user_id': user_id, 'permissions': permissions.to_dict()} | ||
Eldinnie marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if until_date is not None: | ||
if isinstance(until_date, datetime): | ||
until_date = to_timestamp(until_date) | ||
data['until_date'] = until_date | ||
data.update(kwargs) | ||
result = self._request.post(url, data, timeout=timeout) | ||
@@ -2815,6 +2802,38 @@ def promote_chat_member(self, chat_id, user_id, can_change_info=None, | ||
return result | ||
@log | ||
def set_chat_permissions(self, chat_id, permissions, timeout=None, **kwargs): | ||
""" | ||
Use this method to set default chat permissions for all members. The bot must be an | ||
administrator in the group or a supergroup for this to work and must have the | ||
:attr:`can_restrict_members` admin rights. Returns True on success. | ||
Args: | ||
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username of | ||
the target supergroup (in the format `@supergroupusername`). | ||
permissions (:class:`telegram.ChatPermissions`): New default chat permissions. | ||
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as | ||
the read timeout from the server (instead of the one specified during creation of | ||
the connection pool). | ||
**kwargs (:obj:`dict`): Arbitrary keyword arguments | ||
Returns: | ||
:obj:`bool`: Returns True on success. | ||
Raises: | ||
:class:`telegram.TelegramError` | ||
""" | ||
url = '{0}/setChatPermissions'.format(self.base_url) | ||
data = {'chat_id': chat_id, 'permissions': permissions.to_dict()} | ||
data.update(kwargs) | ||
result = self._request.post(url, data, timeout=timeout) | ||
return result | ||
@log | ||
def export_chat_invite_link(self, chat_id, timeout=None, **kwargs): | ||
""" | ||
@@ -2958,8 +2977,9 @@ def set_chat_title(self, chat_id, title, timeout=None, **kwargs): | ||
@log | ||
def set_chat_description(self, chat_id, description, timeout=None, **kwargs): | ||
""" | ||
Use this method to change the description of a group, a supergroup or a channel. The bot | ||
must be an administrator in the chat for this to work and must have the appropriate admin | ||
rights. | ||
Args: | ||
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username | ||
@@ -3526,6 +3546,8 @@ def __reduce__(self): | ||
"""Alias for :attr:`restrict_chat_member`""" | ||
promoteChatMember = promote_chat_member | ||
"""Alias for :attr:`promote_chat_member`""" | ||
setChatPermissions = set_chat_permissions | ||
"""Alias for :attr:`set_chat_permissions`""" | ||
exportChatInviteLink = export_chat_invite_link | ||
"""Alias for :attr:`export_chat_invite_link`""" | ||
setChatPhoto = set_chat_photo | ||
25 changes: 20 additions & 5 deletionstelegram/chat.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
28 changes: 16 additions & 12 deletionstelegram/chatmember.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.