Skip to content

Commit b01caf1

Browse files
committed
Rename default_permissions to just permissions
1 parent 6d03964 commit b01caf1

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • pyrogram/client/types/user_and_chats

pyrogram/client/types/user_and_chats/chat.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
from typing import Union
20+
1921
import pyrogram
2022
from pyrogram.api import types
2123
from .chat_permissions import ChatPermissions
@@ -73,6 +75,9 @@ class Chat(PyrogramType):
7375
7476
restriction_reason (``str``, *optional*):
7577
The reason why this chat might be unavailable to some users.
78+
79+
permissions (:obj:`ChatPermissions <pyrogram.ChatPermissions>` *optional*):
80+
Information about the chat default permissions.
7681
"""
7782

7883
def __init__(self,
@@ -92,7 +97,7 @@ def __init__(self,
9297
can_set_sticker_set: bool = None,
9398
members_count: int = None,
9499
restriction_reason: str = None,
95-
default_permissions: "pyrogram.ChatPermissions" = None):
100+
permissions: "pyrogram.ChatPermissions" = None):
96101
super().__init__(client)
97102

98103
self.id = id
@@ -109,7 +114,7 @@ def __init__(self,
109114
self.can_set_sticker_set = can_set_sticker_set
110115
self.members_count = members_count
111116
self.restriction_reason = restriction_reason
112-
self.default_permissions = default_permissions
117+
self.permissions = permissions
113118

114119
@staticmethod
115120
def _parse_user_chat(client, user: types.User) -> "Chat":
@@ -131,7 +136,7 @@ def _parse_chat_chat(client, chat: types.Chat) -> "Chat":
131136
type="group",
132137
title=chat.title,
133138
photo=ChatPhoto._parse(client, getattr(chat, "photo", None)),
134-
default_permissions=ChatPermissions._parse(chat.default_banned_rights),
139+
permissions=ChatPermissions._parse(chat.default_banned_rights),
135140
client=client
136141
)
137142

@@ -144,7 +149,7 @@ def _parse_channel_chat(client, channel: types.Channel) -> "Chat":
144149
username=getattr(channel, "username", None),
145150
photo=ChatPhoto._parse(client, getattr(channel, "photo", None)),
146151
restriction_reason=getattr(channel, "restriction_reason", None),
147-
default_permissions=ChatPermissions._parse(channel.default_banned_rights),
152+
permissions=ChatPermissions._parse(channel.default_banned_rights),
148153
client=client
149154
)
150155

@@ -205,9 +210,7 @@ def _parse_full(client, chat_full: types.messages.ChatFull or types.UserFull) ->
205210
return parsed_chat
206211

207212
@staticmethod
208-
def _parse_chat(client, chat):
209-
# A wrapper around each entity parser: User, Chat and Channel.
210-
# Currently unused, might become useful in future.
213+
def _parse_chat(client, chat: Union[types.Chat, types.User, types.Channel]) -> "Chat":
211214
if isinstance(chat, types.Chat):
212215
return Chat._parse_chat_chat(client, chat)
213216
elif isinstance(chat, types.User):

0 commit comments

Comments
 (0)