Skip to content

Commit c868815

Browse files
Add ProfileColor enum
1 parent 5802ed8 commit c868815

5 files changed

Lines changed: 63 additions & 13 deletions

File tree

pyrogram/enums/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from .next_code_type import NextCodeType
2929
from .parse_mode import ParseMode
3030
from .poll_type import PollType
31+
from .profile_color import ProfileColor
3132
from .sent_code_type import SentCodeType
3233
from .stories_privacy_rules import StoriesPrivacyRules
3334
from .user_status import UserStatus
@@ -45,6 +46,7 @@
4546
'NextCodeType',
4647
'ParseMode',
4748
'PollType',
49+
'ProfileColor',
4850
'SentCodeType',
4951
'StoriesPrivacyRules',
5052
'UserStatus'

pyrogram/enums/profile_color.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from .auto_name import AutoName
20+
21+
22+
class ProfileColor(AutoName):
23+
"""Profile color enumeration used in :obj:`~pyrogram.method.UpdateColor`."""
24+
25+
RED = 0
26+
ORANGE = 1
27+
VIOLET = 2
28+
GREEN = 3
29+
CYAN = 4
30+
BLUE = 5
31+
PINK = 6
32+
33+
RED_DARK_RED = 7
34+
ORANGE_DARK_ORANGE = 8
35+
VIOLET_DARK_VIOLET = 9
36+
GREEN_DARK_GREEN = 10
37+
CYAN_DARK_CYAN = 11
38+
BLUE_DARK_BLUE = 12
39+
PINK_DARK_PINK = 13
40+
41+
BLUE_WHITE_RED = 14
42+
ORANGE_WHITE_GREEN = 15
43+
GREEN_WHITE_RED = 16
44+
BLUE_WHITE_GREEN = 17
45+
BLUE_WHITE_PINK = 18
46+
VIOLET_WHITE_ORANGE = 19
47+
BLUE_WHITE_ORANGE = 20

pyrogram/methods/chats/update_color.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020

2121
import pyrogram
2222
from pyrogram import raw
23+
from pyrogram import enums
2324
from pyrogram import types
2425

2526
class UpdateColor:
2627
async def update_color(
2728
self: "pyrogram.Client",
2829
chat_id: Union[int, str],
29-
color: int,
30+
color: "enums.ProfileColor",
3031
background_emoji_id: int = None
3132
) -> "types.Chat":
3233
"""Update color
@@ -37,8 +38,8 @@ async def update_color(
3738
chat_id (``int`` | ``str``):
3839
Unique identifier (int) or username (str) of the target chat.
3940
40-
color (``int``):
41-
Numeric color identifier.
41+
color (:obj:`~pyrogram.enums.ProfileColor`):
42+
Color type.
4243
4344
background_emoji_id (``int``, *optional*):
4445
Unique identifier of the custom emoji.

pyrogram/types/user_and_chats/chat.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ class Chat(Object):
154154
Available reactions in the chat.
155155
Returned only in :meth:`~pyrogram.Client.get_chat`.
156156
157-
color (``int``, *optional*)
158-
Chat color.
157+
color (:obj:`~pyrogram.enums.ProfileColor`, *optional*)
158+
Chat reply color.
159159
160160
background_emoji_id (``int``, *optional*)
161161
Chat background emoji id.
@@ -200,7 +200,7 @@ def __init__(
200200
linked_chat: "types.Chat" = None,
201201
send_as_chat: "types.Chat" = None,
202202
available_reactions: Optional["types.ChatReactions"] = None,
203-
color: int = None,
203+
color: "enums.ProfileColor" = None,
204204
background_emoji_id: int = None
205205
):
206206
super().__init__(client)
@@ -262,7 +262,7 @@ def _parse_user_chat(client, user: raw.types.User) -> "Chat":
262262
photo=types.ChatPhoto._parse(client, user.photo, peer_id, user.access_hash),
263263
restrictions=types.List([types.Restriction._parse(r) for r in user.restriction_reason]) or None,
264264
dc_id=getattr(getattr(user, "photo", None), "dc_id", None),
265-
color=getattr(user, "color", None),
265+
color=enums.ProfileColor(user.color) if getattr(user, "color", None) else None,
266266
background_emoji_id=getattr(user, "background_emoji_id", None),
267267
client=client
268268
)
@@ -318,7 +318,7 @@ def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
318318
members_count=getattr(channel, "participants_count", None),
319319
dc_id=getattr(getattr(channel, "photo", None), "dc_id", None),
320320
has_protected_content=getattr(channel, "noforwards", None),
321-
color=getattr(channel, "color", None),
321+
color=enums.ProfileColor(channel.color) if getattr(channel, "color", None) else None,
322322
background_emoji_id=getattr(channel, "background_emoji_id", None),
323323
client=client
324324
)

pyrogram/types/user_and_chats/user.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ class User(Object, Update):
161161
``user.mention("another name")`` for a custom name. To choose a different style
162162
("html" or "md"/"markdown") use ``user.mention(style="md")``.
163163
164-
color (``int``, *optional*)
165-
Chat color.
164+
color (:obj:`~pyrogram.enums.ProfileColor`, *optional*)
165+
User's reply color.
166166
167167
background_emoji_id (``int``, *optional*)
168-
Chat background emoji id.
168+
User's background emoji id.
169169
"""
170170

171171
def __init__(
@@ -200,7 +200,7 @@ def __init__(
200200
phone_number: str = None,
201201
photo: "types.ChatPhoto" = None,
202202
restrictions: List["types.Restriction"] = None,
203-
color: int = None,
203+
color: "enums.ProfileColor" = None,
204204
background_emoji_id: int = None
205205
):
206206
super().__init__(client)
@@ -280,7 +280,7 @@ def _parse(client, user: "raw.base.User") -> Optional["User"]:
280280
phone_number=user.phone,
281281
photo=types.ChatPhoto._parse(client, user.photo, user.id, user.access_hash),
282282
restrictions=types.List([types.Restriction._parse(r) for r in user.restriction_reason]) or None,
283-
color=getattr(user, "color", None),
283+
color=enums.ProfileColor(user.color) if getattr(user, "color", None) else None,
284284
background_emoji_id=getattr(user, "background_emoji_id", None),
285285
client=client
286286
)

0 commit comments

Comments
 (0)