-
Notifications
You must be signed in to change notification settings - Fork 5.9k
API 5.0 WP 3 (Working with Groups) #2185
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d4a96a9
Add ChatLocation class
Bibo-Joshi 6bee6b0
New parameter for unban_chat_member
Bibo-Joshi 5ff28f6
New attributes for Chat
Bibo-Joshi 3722e48
fix docs
Bibo-Joshi 1f98eee
Merge branch 'api-5.0-master' into wp3
Bibo-Joshi 46ffd6f
Merge branch 'api-5.0-master' into wp3
Bibo-Joshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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.ChatLocation | ||
| ===================== | ||
|
|
||
| .. autoclass:: telegram.ChatLocation | ||
| :members: | ||
| :show-inheritance: |
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
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
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
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,70 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # A library that provides a Python interface to the Telegram Bot API | ||
| # Copyright (C) 2015-2020 | ||
| # Leandro Toledo de Souza <devs@python-telegram-bot.org> | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser Public License | ||
| # along with this program. If not, see [http://www.gnu.org/licenses/]. | ||
| """This module contains an object that represents a location to which a chat is connected.""" | ||
|
|
||
| from typing import TYPE_CHECKING, Any, Optional | ||
|
|
||
| from telegram import TelegramObject | ||
| from telegram.utils.types import JSONDict | ||
|
|
||
| from .files.location import Location | ||
|
|
||
| if TYPE_CHECKING: | ||
| from telegram import Bot | ||
|
|
||
|
|
||
| class ChatLocation(TelegramObject): | ||
| """This object represents a location to which a chat is connected. | ||
|
|
||
| Objects of this class are comparable in terms of equality. Two objects of this class are | ||
| considered equal, if their :attr:`location` is equal. | ||
|
|
||
| Attributes: | ||
| location (:class:`telegram.Location`): The location to which the supergroup is connected. | ||
| address (:obj:`str`): Location address, as defined by the chat owner | ||
|
|
||
| Args: | ||
| location (:class:`telegram.Location`): The location to which the supergroup is connected. | ||
| Can't be a live location. | ||
| address (:obj:`str`): Location address; 1-64 characters, as defined by the chat owner | ||
| **kwargs (:obj:`dict`): Arbitrary keyword arguments. | ||
|
|
||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| location: Location, | ||
| address: str, | ||
| **_kwargs: Any, | ||
| ): | ||
| self.location = location | ||
| self.address = address | ||
|
|
||
| self._id_attrs = (self.location,) | ||
|
|
||
| @classmethod | ||
| def de_json(cls, data: Optional[JSONDict], bot: 'Bot') -> Optional['ChatLocation']: | ||
| data = cls.parse_data(data) | ||
|
|
||
| if not data: | ||
| return None | ||
|
|
||
| data['location'] = Location.de_json(data.get('location'), bot) | ||
|
|
||
| return cls(bot=bot, **data) |
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
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
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,69 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # A library that provides a Python interface to the Telegram Bot API | ||
| # Copyright (C) 2015-2020 | ||
| # Leandro Toledo de Souza <devs@python-telegram-bot.org> | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser Public License | ||
| # along with this program. If not, see [http://www.gnu.org/licenses/]. | ||
|
|
||
| import pytest | ||
|
|
||
| from telegram import Location, ChatLocation, User | ||
|
|
||
|
|
||
| @pytest.fixture(scope='class') | ||
| def chat_location(bot): | ||
| return ChatLocation(TestChatLocation.location, TestChatLocation.address) | ||
|
|
||
|
|
||
| class TestChatLocation: | ||
| location = Location(123, 456) | ||
| address = 'The Shire' | ||
|
|
||
| def test_de_json(self, bot): | ||
| json_dict = { | ||
| 'location': self.location.to_dict(), | ||
| 'address': self.address, | ||
| } | ||
| chat_location = ChatLocation.de_json(json_dict, bot) | ||
|
|
||
| assert chat_location.location == self.location | ||
| assert chat_location.address == self.address | ||
|
|
||
| def test_to_dict(self, chat_location): | ||
| chat_location_dict = chat_location.to_dict() | ||
|
|
||
| assert isinstance(chat_location_dict, dict) | ||
| assert chat_location_dict['location'] == chat_location.location.to_dict() | ||
| assert chat_location_dict['address'] == chat_location.address | ||
|
|
||
| def test_equality(self, chat_location): | ||
| a = chat_location | ||
| b = ChatLocation(self.location, self.address) | ||
| c = ChatLocation(self.location, 'Mordor') | ||
| d = ChatLocation(Location(456, 132), self.address) | ||
| e = User(456, '', False) | ||
|
|
||
| assert a == b | ||
| assert hash(a) == hash(b) | ||
| assert a is not b | ||
|
|
||
| assert a == c | ||
| assert hash(a) == hash(c) | ||
|
|
||
| assert a != d | ||
| assert hash(a) != hash(d) | ||
|
|
||
| assert a != e | ||
| assert hash(a) != hash(e) |
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.
Uh oh!
There was an error while loading. Please reload this page.