From 3b6999c5e247c44a2d66f61a2b6400c0e30fd3af Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Sat, 23 Dec 2023 04:30:59 +0000 Subject: [PATCH] [Pyrofork] Added color and background_emoji_id to User and Chat Signed-off-by: wulan17 --- compiler/errors/source/400_BAD_REQUEST.tsv | 4 ++-- pyrogram/types/user_and_chats/chat.py | 16 +++++++++++++++- pyrogram/types/user_and_chats/user.py | 14 +++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/compiler/errors/source/400_BAD_REQUEST.tsv b/compiler/errors/source/400_BAD_REQUEST.tsv index e1ef8cd4..288525ed 100644 --- a/compiler/errors/source/400_BAD_REQUEST.tsv +++ b/compiler/errors/source/400_BAD_REQUEST.tsv @@ -372,6 +372,6 @@ WEBPAGE_MEDIA_EMPTY The URL doesn't contain any valid media YOU_BLOCKED_USER You blocked this user STORIES_NEVER_CREATED You have never created any stories MEDIA_FILE_INVALID The provided media file is invalid -CHANNEL_FORUM_MISSING -TTL_PERIOD_INVALID TTL_PERIOD_INVALID +CHANNEL_FORUM_MISSING The channel forum is missing +TTL_PERIOD_INVALID The provided TTL period is invalid BOOSTS_REQUIRED Channel required more boost to upload a story diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index 892a3c90..e0f29746 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -143,6 +143,12 @@ class Chat(Object): usernames (List of :obj:`~pyrogram.types.Username`, *optional*): List of all chat (fragment) usernames; for private chats, supergroups and channels. Returned only in :meth:`~pyrogram.Client.get_chat`. + + color (``int``, *optional*) + Chat color. + + background_emoji_id (``int``, *optional*) + Chat background emoji id. """ def __init__( @@ -179,7 +185,9 @@ class Chat(Object): linked_chat: "types.Chat" = None, send_as_chat: "types.Chat" = None, available_reactions: Optional["types.ChatReactions"] = None, - usernames: List["types.Username"] = None + usernames: List["types.Username"] = None, + color: int = None, + background_emoji_id: int = None ): super().__init__(client) @@ -214,6 +222,8 @@ class Chat(Object): self.send_as_chat = send_as_chat self.available_reactions = available_reactions self.usernames = usernames + self.color = color + self.background_emoji_id = background_emoji_id @property def full_name(self) -> str: @@ -237,6 +247,8 @@ class Chat(Object): 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, 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 ) @@ -298,6 +310,8 @@ class Chat(Object): members_count=getattr(channel, "participants_count", None), dc_id=getattr(getattr(channel, "photo", None), "dc_id", None), has_protected_content=getattr(channel, "noforwards", None), + color=getattr(channel, "color", None), + background_emoji_id=getattr(channel, "background_emoji_id", None), client=client ) diff --git a/pyrogram/types/user_and_chats/user.py b/pyrogram/types/user_and_chats/user.py index c8135543..d75c4be9 100644 --- a/pyrogram/types/user_and_chats/user.py +++ b/pyrogram/types/user_and_chats/user.py @@ -153,6 +153,12 @@ class User(Object, Update): 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 ("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__( @@ -183,7 +189,9 @@ class User(Object, Update): dc_id: int = None, phone_number: str = 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) @@ -212,6 +220,8 @@ class User(Object, Update): self.phone_number = phone_number self.photo = photo self.restrictions = restrictions + self.color = color + self.background_emoji_id = background_emoji_id @property def full_name(self) -> str: @@ -264,6 +274,8 @@ class User(Object, Update): phone_number=user.phone, 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, + color=getattr(user, "color", None), + background_emoji_id=getattr(user, "background_emoji_id", None), client=client )