From c8688154a5de90441fa9d3abdf9a8c731ad3fe50 Mon Sep 17 00:00:00 2001 From: KurimuzonAkuma Date: Wed, 29 Nov 2023 18:53:52 +0300 Subject: [PATCH] Add ProfileColor enum --- pyrogram/enums/__init__.py | 2 ++ pyrogram/enums/profile_color.py | 47 ++++++++++++++++++++++++++ pyrogram/methods/chats/update_color.py | 7 ++-- pyrogram/types/user_and_chats/chat.py | 10 +++--- pyrogram/types/user_and_chats/user.py | 10 +++--- 5 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 pyrogram/enums/profile_color.py diff --git a/pyrogram/enums/__init__.py b/pyrogram/enums/__init__.py index d25b821c..a55f7a33 100644 --- a/pyrogram/enums/__init__.py +++ b/pyrogram/enums/__init__.py @@ -28,6 +28,7 @@ from .messages_filter import MessagesFilter from .next_code_type import NextCodeType from .parse_mode import ParseMode from .poll_type import PollType +from .profile_color import ProfileColor from .sent_code_type import SentCodeType from .stories_privacy_rules import StoriesPrivacyRules from .user_status import UserStatus @@ -45,6 +46,7 @@ __all__ = [ 'NextCodeType', 'ParseMode', 'PollType', + 'ProfileColor', 'SentCodeType', 'StoriesPrivacyRules', 'UserStatus' diff --git a/pyrogram/enums/profile_color.py b/pyrogram/enums/profile_color.py new file mode 100644 index 00000000..07e23ea9 --- /dev/null +++ b/pyrogram/enums/profile_color.py @@ -0,0 +1,47 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-present Dan +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram 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 General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from .auto_name import AutoName + + +class ProfileColor(AutoName): + """Profile color enumeration used in :obj:`~pyrogram.method.UpdateColor`.""" + + RED = 0 + ORANGE = 1 + VIOLET = 2 + GREEN = 3 + CYAN = 4 + BLUE = 5 + PINK = 6 + + RED_DARK_RED = 7 + ORANGE_DARK_ORANGE = 8 + VIOLET_DARK_VIOLET = 9 + GREEN_DARK_GREEN = 10 + CYAN_DARK_CYAN = 11 + BLUE_DARK_BLUE = 12 + PINK_DARK_PINK = 13 + + BLUE_WHITE_RED = 14 + ORANGE_WHITE_GREEN = 15 + GREEN_WHITE_RED = 16 + BLUE_WHITE_GREEN = 17 + BLUE_WHITE_PINK = 18 + VIOLET_WHITE_ORANGE = 19 + BLUE_WHITE_ORANGE = 20 diff --git a/pyrogram/methods/chats/update_color.py b/pyrogram/methods/chats/update_color.py index 8fb57dc1..b52d0daf 100644 --- a/pyrogram/methods/chats/update_color.py +++ b/pyrogram/methods/chats/update_color.py @@ -20,13 +20,14 @@ from typing import Union import pyrogram from pyrogram import raw +from pyrogram import enums from pyrogram import types class UpdateColor: async def update_color( self: "pyrogram.Client", chat_id: Union[int, str], - color: int, + color: "enums.ProfileColor", background_emoji_id: int = None ) -> "types.Chat": """Update color @@ -37,8 +38,8 @@ class UpdateColor: chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of the target chat. - color (``int``): - Numeric color identifier. + color (:obj:`~pyrogram.enums.ProfileColor`): + Color type. background_emoji_id (``int``, *optional*): Unique identifier of the custom emoji. diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index 0f600549..4f1500c9 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -154,8 +154,8 @@ class Chat(Object): Available reactions in the chat. Returned only in :meth:`~pyrogram.Client.get_chat`. - color (``int``, *optional*) - Chat color. + color (:obj:`~pyrogram.enums.ProfileColor`, *optional*) + Chat reply color. background_emoji_id (``int``, *optional*) Chat background emoji id. @@ -200,7 +200,7 @@ class Chat(Object): linked_chat: "types.Chat" = None, send_as_chat: "types.Chat" = None, available_reactions: Optional["types.ChatReactions"] = None, - color: int = None, + color: "enums.ProfileColor" = None, background_emoji_id: int = None ): super().__init__(client) @@ -262,7 +262,7 @@ 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), + color=enums.ProfileColor(user.color) if getattr(user, "color", None) else None, background_emoji_id=getattr(user, "background_emoji_id", None), client=client ) @@ -318,7 +318,7 @@ 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), + color=enums.ProfileColor(channel.color) if getattr(channel, "color", None) else 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 42af2ae7..e5b8e98f 100644 --- a/pyrogram/types/user_and_chats/user.py +++ b/pyrogram/types/user_and_chats/user.py @@ -161,11 +161,11 @@ class User(Object, Update): ``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. + color (:obj:`~pyrogram.enums.ProfileColor`, *optional*) + User's reply color. background_emoji_id (``int``, *optional*) - Chat background emoji id. + User's background emoji id. """ def __init__( @@ -200,7 +200,7 @@ class User(Object, Update): phone_number: str = None, photo: "types.ChatPhoto" = None, restrictions: List["types.Restriction"] = None, - color: int = None, + color: "enums.ProfileColor" = None, background_emoji_id: int = None ): super().__init__(client) @@ -280,7 +280,7 @@ 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), + color=enums.ProfileColor(user.color) if getattr(user, "color", None) else None, background_emoji_id=getattr(user, "background_emoji_id", None), client=client )