Skip to content

Commit

Permalink
Add missing attributes to Chat
Browse files Browse the repository at this point in the history
is_banned
banned_until_date
pending_join_request_count
  • Loading branch information
SpEcHiDe committed Aug 2, 2024
1 parent b6fad53 commit cae9fbe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pyrogram/types/user_and_chats/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ class Chat(Object):
is_public (``bool``, *optional*):
True, if this chat is public.
is_banned (``bool``, *optional*):
True, if you are banned in this chat.
dc_id (``int``, *optional*):
The chat assigned DC (data center). Available only in case the chat has a photo.
Note that this information is approximate; it is based on where Telegram stores the current chat photo.
Expand Down Expand Up @@ -209,6 +212,12 @@ class Chat(Object):
is_peak_preview (``bool``, *optional*):
True, if this is a peak preview.
banned_until_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the current user will be unbanned.
pending_join_request_count (``int``, *optional*):
Number of pending join requests in the current chat.
full_name (``str``, *property*):
Full name of the other party in a private chat, for private chats and bots.
Expand All @@ -227,6 +236,8 @@ def __init__(
is_fake: bool = None,
is_support: bool = None,
is_public: bool = None,
is_banned: bool = None,
banned_until_date: datetime = None,
title: str = None,
username: str = None,
first_name: str = None,
Expand Down Expand Up @@ -272,6 +283,7 @@ def __init__(
is_peak_preview: bool = None,
max_reaction_count: int = None,
can_send_paid_media: bool = None,
pending_join_request_count: int = None,
_raw: Union[
"raw.types.ChatInvite",
"raw.types.Channel",
Expand Down Expand Up @@ -326,6 +338,8 @@ def __init__(
self.is_forum = is_forum
self.unrestrict_boost_count = unrestrict_boost_count
self.is_public = is_public
self.is_banned = is_banned
self.banned_until_date = banned_until_date
self.join_by_request = join_by_request
self.is_peak_preview = is_peak_preview
self.personal_chat = personal_chat
Expand All @@ -337,6 +351,7 @@ def __init__(
self.active_usernames = active_usernames
self.max_reaction_count = max_reaction_count
self.can_send_paid_media = can_send_paid_media
self.pending_join_request_count = pending_join_request_count
self._raw = _raw

@staticmethod
Expand Down Expand Up @@ -403,6 +418,7 @@ def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":
type=enums.ChatType.GROUP,
title=chat.title,
client=client,
is_banned=True,
_raw=chat
)

Expand Down Expand Up @@ -430,6 +446,8 @@ def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
type=enums.ChatType.SUPERGROUP if channel.megagroup else enums.ChatType.CHANNEL,
title=channel.title,
client=client,
is_banned=True,
banned_until_date=utils.timestamp_to_datetime(getattr(channel, "until_date", None)),
_raw=channel
)

Expand Down Expand Up @@ -645,6 +663,7 @@ async def _parse_full(client, chat_full: Union[raw.types.messages.ChatFull, raw.
reactions_limit=getattr(full_chat, "reactions_limit", None)
)
parsed_chat.max_reaction_count = getattr(full_chat, "reactions_limit", 11)
parsed_chat.pending_join_request_count = getattr(full_chat, "requests_pending", None)

if getattr(full_chat, "wallpaper", None):
parsed_chat.background = types.ChatBackground._parse(client, full_chat.wallpaper)
Expand Down

1 comment on commit cae9fbe

@KurimuzonAkuma
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢😢😢

Please sign in to comment.