Added color and background_emoji_id to User and Chat

This commit is contained in:
KurimuzonAkuma 2023-10-29 12:48:19 +03:00
parent 76a44a8b57
commit 1c172c9f5b
2 changed files with 28 additions and 2 deletions

View File

@ -147,6 +147,12 @@ class Chat(Object):
available_reactions (:obj:`~pyrogram.types.ChatReactions`, *optional*): available_reactions (:obj:`~pyrogram.types.ChatReactions`, *optional*):
Available reactions in the chat. Available reactions in the chat.
Returned only in :meth:`~pyrogram.Client.get_chat`. Returned only in :meth:`~pyrogram.Client.get_chat`.
color (``int``, *optional*)
Chat color.
background_emoji_id (``int``, *optional*)
Chat background emoji id.
""" """
def __init__( def __init__(
@ -185,7 +191,9 @@ class Chat(Object):
distance: int = None, distance: int = None,
linked_chat: "types.Chat" = None, linked_chat: "types.Chat" = None,
send_as_chat: "types.Chat" = None, send_as_chat: "types.Chat" = None,
available_reactions: Optional["types.ChatReactions"] = None available_reactions: Optional["types.ChatReactions"] = None,
color: int = None,
background_emoji_id: int = None
): ):
super().__init__(client) super().__init__(client)
@ -222,6 +230,8 @@ class Chat(Object):
self.linked_chat = linked_chat self.linked_chat = linked_chat
self.send_as_chat = send_as_chat self.send_as_chat = send_as_chat
self.available_reactions = available_reactions self.available_reactions = available_reactions
self.color = color
self.background_emoji_id = background_emoji_id
@staticmethod @staticmethod
def _parse_user_chat(client, user: raw.types.User) -> "Chat": def _parse_user_chat(client, user: raw.types.User) -> "Chat":
@ -242,6 +252,8 @@ class Chat(Object):
photo=types.ChatPhoto._parse(client, user.photo, peer_id, user.access_hash), photo=types.ChatPhoto._parse(client, user.photo, peer_id, user.access_hash),
restrictions=types.List([types.Restriction._parse(r) for r in user.restriction_reason]) or None, restrictions=types.List([types.Restriction._parse(r) for r in user.restriction_reason]) or None,
dc_id=getattr(getattr(user, "photo", None), "dc_id", None), dc_id=getattr(getattr(user, "photo", None), "dc_id", None),
color=getattr(user, "color", None),
background_emoji_id=getattr(user, "background_emoji_id", None),
client=client client=client
) )
@ -291,6 +303,8 @@ class Chat(Object):
members_count=getattr(channel, "participants_count", None), members_count=getattr(channel, "participants_count", None),
dc_id=getattr(getattr(channel, "photo", None), "dc_id", None), dc_id=getattr(getattr(channel, "photo", None), "dc_id", None),
has_protected_content=getattr(channel, "noforwards", None), has_protected_content=getattr(channel, "noforwards", None),
color=getattr(channel, "color", None),
background_emoji_id=getattr(channel, "background_emoji_id", None),
client=client client=client
) )

View File

@ -160,6 +160,12 @@ class User(Object, Update):
You can use ``user.mention()`` to mention the user using their first name (styled using html), or You can use ``user.mention()`` to mention the user using their first name (styled using html), or
``user.mention("another name")`` for a custom name. To choose a different style ``user.mention("another name")`` for a custom name. To choose a different style
("html" or "md"/"markdown") use ``user.mention(style="md")``. ("html" or "md"/"markdown") use ``user.mention(style="md")``.
color (``int``, *optional*)
Chat color.
background_emoji_id (``int``, *optional*)
Chat background emoji id.
""" """
def __init__( def __init__(
@ -193,7 +199,9 @@ class User(Object, Update):
dc_id: int = None, dc_id: int = None,
phone_number: str = None, phone_number: str = None,
photo: "types.ChatPhoto" = None, photo: "types.ChatPhoto" = None,
restrictions: List["types.Restriction"] = None restrictions: List["types.Restriction"] = None,
color: int = None,
background_emoji_id: int = None
): ):
super().__init__(client) super().__init__(client)
@ -225,6 +233,8 @@ class User(Object, Update):
self.phone_number = phone_number self.phone_number = phone_number
self.photo = photo self.photo = photo
self.restrictions = restrictions self.restrictions = restrictions
self.color = color
self.background_emoji_id = background_emoji_id
@property @property
def full_name(self) -> str: def full_name(self) -> str:
@ -270,6 +280,8 @@ class User(Object, Update):
phone_number=user.phone, phone_number=user.phone,
photo=types.ChatPhoto._parse(client, user.photo, user.id, user.access_hash), photo=types.ChatPhoto._parse(client, user.photo, user.id, user.access_hash),
restrictions=types.List([types.Restriction._parse(r) for r in user.restriction_reason]) or None, restrictions=types.List([types.Restriction._parse(r) for r in user.restriction_reason]) or None,
color=getattr(user, "color", None),
background_emoji_id=getattr(user, "background_emoji_id", None),
client=client client=client
) )