Add reply color, profile color and some known error, and add support multiple reaction

Signed-off-by: Yasir Aris M <git@yasirdev.my.id>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
KurimuzonAkuma 2023-11-29 18:53:52 +03:00 committed by wulan17
parent 726a622892
commit 2543c0f9f4
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
13 changed files with 300 additions and 49 deletions

View file

@ -443,6 +443,7 @@ def pyrogram_api():
PeerUser PeerUser
PeerChannel PeerChannel
BotInfo BotInfo
ChatColor
""", """,
messages_media=""" messages_media="""
Messages & Media Messages & Media

View file

@ -70,6 +70,7 @@ CHAT_TOO_BIG The chat is too big for this action
CODE_EMPTY The provided code is empty CODE_EMPTY The provided code is empty
CODE_HASH_INVALID The provided code hash invalid CODE_HASH_INVALID The provided code hash invalid
CODE_INVALID The provided code is invalid (i.e. from email) CODE_INVALID The provided code is invalid (i.e. from email)
COLOR_INVALID The provided color is invalid
CONNECTION_API_ID_INVALID The provided API id is invalid CONNECTION_API_ID_INVALID The provided API id is invalid
CONNECTION_APP_VERSION_EMPTY App version is empty CONNECTION_APP_VERSION_EMPTY App version is empty
CONNECTION_DEVICE_MODEL_EMPTY The device model is empty CONNECTION_DEVICE_MODEL_EMPTY The device model is empty
@ -136,7 +137,8 @@ GAME_BOT_INVALID You cannot send that game with the current bot
GEO_POINT_INVALID Invalid geo point provided GEO_POINT_INVALID Invalid geo point provided
GIF_CONTENT_TYPE_INVALID GIF content-type invalid GIF_CONTENT_TYPE_INVALID GIF content-type invalid
GIF_ID_INVALID The provided gif/animation id is invalid GIF_ID_INVALID The provided gif/animation id is invalid
GRAPH_INVALID_RELOAD Invalid graph token provided, please reload the stats and provide the updated token GIFT_SLUG_EXPIRED The gift slug is expired
GRAPH_INVALID_RELOAD Invalid graph token provided,
GRAPH_OUTDATED_RELOAD The graph data is outdated GRAPH_OUTDATED_RELOAD The graph data is outdated
GROUPCALL_SSRC_DUPLICATE_MUCH Too many group call synchronization source duplicates GROUPCALL_SSRC_DUPLICATE_MUCH Too many group call synchronization source duplicates
GROUPED_MEDIA_INVALID The album contains invalid media GROUPED_MEDIA_INVALID The album contains invalid media

1 id message
70 CODE_EMPTY The provided code is empty
71 CODE_HASH_INVALID The provided code hash invalid
72 CODE_INVALID The provided code is invalid (i.e. from email)
73 COLOR_INVALID The provided color is invalid
74 CONNECTION_API_ID_INVALID The provided API id is invalid
75 CONNECTION_APP_VERSION_EMPTY App version is empty
76 CONNECTION_DEVICE_MODEL_EMPTY The device model is empty
137 GEO_POINT_INVALID Invalid geo point provided
138 GIF_CONTENT_TYPE_INVALID GIF content-type invalid
139 GIF_ID_INVALID The provided gif/animation id is invalid
140 GRAPH_INVALID_RELOAD GIFT_SLUG_EXPIRED Invalid graph token provided, please reload the stats and provide the updated token The gift slug is expired
141 GRAPH_INVALID_RELOAD Invalid graph token provided,
142 GRAPH_OUTDATED_RELOAD The graph data is outdated
143 GROUPCALL_SSRC_DUPLICATE_MUCH Too many group call synchronization source duplicates
144 GROUPED_MEDIA_INVALID The album contains invalid media

View file

@ -4,6 +4,7 @@ CHANNEL_PUBLIC_GROUP_NA The channel/supergroup is not available
CHAT_ADMIN_INVITE_REQUIRED You don't have rights to invite other users CHAT_ADMIN_INVITE_REQUIRED You don't have rights to invite other users
CHAT_ADMIN_REQUIRED The method requires chat admin privileges CHAT_ADMIN_REQUIRED The method requires chat admin privileges
CHAT_FORBIDDEN You cannot write in this chat CHAT_FORBIDDEN You cannot write in this chat
CHAT_GUEST_SEND_FORBIDDEN You need to join the discussion group before commentingr
EDIT_BOT_INVITE_FORBIDDEN Bots' chat invite links can't be edited EDIT_BOT_INVITE_FORBIDDEN Bots' chat invite links can't be edited
INLINE_BOT_REQUIRED The action must be performed through an inline bot callback INLINE_BOT_REQUIRED The action must be performed through an inline bot callback
MESSAGE_AUTHOR_REQUIRED You are not the author of this message MESSAGE_AUTHOR_REQUIRED You are not the author of this message

1 id message
4 CHAT_ADMIN_INVITE_REQUIRED You don't have rights to invite other users
5 CHAT_ADMIN_REQUIRED The method requires chat admin privileges
6 CHAT_FORBIDDEN You cannot write in this chat
7 CHAT_GUEST_SEND_FORBIDDEN You need to join the discussion group before commentingr
8 EDIT_BOT_INVITE_FORBIDDEN Bots' chat invite links can't be edited
9 INLINE_BOT_REQUIRED The action must be performed through an inline bot callback
10 MESSAGE_AUTHOR_REQUIRED You are not the author of this message

View file

@ -1,10 +1,12 @@
id message id message
AUTH_KEY_DUPLICATED The same authorization key (session file) was used in more than one place simultaneously. You must delete your session file and log in again with your phone number or bot token AUTH_KEY_DUPLICATED The same authorization key (session file) was used in more than one place simultaneously. You must delete your session file and log in again with your phone number or bot token
CHANNEL_PRIVATE The channel/supergroup is not accessible CHANNEL_PRIVATE The channel/supergroup is not accessible
CHANNEL_TOO_LARGE Сhannel is too large to be deleted. Contact support for removal
FILEREF_UPGRADE_NEEDED The file reference has expired and you must use a refreshed one by obtaining the original media message FILEREF_UPGRADE_NEEDED The file reference has expired and you must use a refreshed one by obtaining the original media message
FRESH_CHANGE_ADMINS_FORBIDDEN You were just elected admin, you can't add or modify other admins yet FRESH_CHANGE_ADMINS_FORBIDDEN You were just elected admin, you can't add or modify other admins yet
FRESH_CHANGE_PHONE_FORBIDDEN You can't change your phone number because your session was logged-in recently FRESH_CHANGE_PHONE_FORBIDDEN You can't change your phone number because your session was logged-in recently
FRESH_RESET_AUTHORISATION_FORBIDDEN You can't terminate other authorized sessions because the current was logged-in recently FRESH_RESET_AUTHORISATION_FORBIDDEN You can't terminate other authorized sessions because the current was logged-in recently
GIFTCODE_NOT_ALLOWED Giftcode not allowed
PHONE_NUMBER_INVALID The phone number is invalid PHONE_NUMBER_INVALID The phone number is invalid
PHONE_PASSWORD_FLOOD You have tried to log-in too many times PHONE_PASSWORD_FLOOD You have tried to log-in too many times
STICKERSET_INVALID The sticker set is invalid STICKERSET_INVALID The sticker set is invalid

1 id message
2 AUTH_KEY_DUPLICATED The same authorization key (session file) was used in more than one place simultaneously. You must delete your session file and log in again with your phone number or bot token
3 CHANNEL_PRIVATE The channel/supergroup is not accessible
4 CHANNEL_TOO_LARGE Сhannel is too large to be deleted. Contact support for removal
5 FILEREF_UPGRADE_NEEDED The file reference has expired and you must use a refreshed one by obtaining the original media message
6 FRESH_CHANGE_ADMINS_FORBIDDEN You were just elected admin, you can't add or modify other admins yet
7 FRESH_CHANGE_PHONE_FORBIDDEN You can't change your phone number because your session was logged-in recently
8 FRESH_RESET_AUTHORISATION_FORBIDDEN You can't terminate other authorized sessions because the current was logged-in recently
9 GIFTCODE_NOT_ALLOWED Giftcode not allowed
10 PHONE_NUMBER_INVALID The phone number is invalid
11 PHONE_PASSWORD_FLOOD You have tried to log-in too many times
12 STICKERSET_INVALID The sticker set is invalid

View file

@ -29,6 +29,8 @@ from .messages_filter import MessagesFilter
from .next_code_type import NextCodeType from .next_code_type import NextCodeType
from .parse_mode import ParseMode from .parse_mode import ParseMode
from .poll_type import PollType from .poll_type import PollType
from .profile_color import ProfileColor
from .reply_color import ReplyColor
from .sent_code_type import SentCodeType from .sent_code_type import SentCodeType
from .stories_privacy_rules import StoriesPrivacyRules from .stories_privacy_rules import StoriesPrivacyRules
from .story_privacy import StoryPrivacy from .story_privacy import StoryPrivacy
@ -48,6 +50,8 @@ __all__ = [
'NextCodeType', 'NextCodeType',
'ParseMode', 'ParseMode',
'PollType', 'PollType',
'ProfileColor',
'ReplyColor',
'SentCodeType', 'SentCodeType',
"StoriesPrivacyRules", "StoriesPrivacyRules",
"StoryPrivacy", "StoryPrivacy",

View file

@ -0,0 +1,72 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork 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.
#
# Pyrofork 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 Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from .auto_name import AutoName
class ProfileColor(AutoName):
"""Profile color enumeration used in :meth:`~pyrogram.Client.update_color` and :obj:`~pyrogram.types.ChatColor`."""
RED = 0
"Red color."
ORANGE = 1
"Orange color."
VIOLET = 2
"Violet color."
GREEN = 3
"Green color."
CYAN = 4
"Cyan color."
BLUE = 5
"Blue color."
PINK = 6
"Pink color."
GRAY = 7
"Gray color."
RED_LIGHT_RED = 8
"Red color with light red gradient."
ORANGE_LIGHT_ORANGE = 9
"Orange color with light red gradient."
VIOLET_LIGHT_VIOLET = 10
"Violet color with light violet gradient."
GREEN_LIGHT_GREEN = 11
"Green color with light green gradien."
CYAN_LIGHT_CYAN = 12
"Cyan color with light cyan gradient."
BLUE_LIGHT_BLUE = 13
"Blue color with light blue gradient."
PINK_LIGHT_PINK = 14
"Pink color with light pink gradient."
GRAY_LIGHT_GRAY = 15
"Gray color with light gray gradient."

View file

@ -0,0 +1,94 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork 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.
#
# Pyrofork 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 Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from .auto_name import AutoName
class ReplyColor(AutoName):
"""Reply color enumeration used in :meth:`~pyrogram.Client.update_color` and :obj:`~pyrogram.types.ChatColor`."""
RED = 0
"Red color."
ORANGE = 1
"Orange color."
VIOLET = 2
"Violet color."
GREEN = 3
"Green color."
CYAN = 4
"Cyan color."
BLUE = 5
"Blue color."
PINK = 6
"Pink color."
RED_DARK_RED = 7
"Red color with dark red stripes."
ORANGE_DARK_ORANGE = 8
"Orange color with dark orange stripes."
VIOLET_DARK_VIOLET = 9
"Violet color with dark violet stripes."
GREEN_DARK_GREEN = 10
"Green color with dark green stripes."
CYAN_DARK_CYAN = 11
"Cyan color with dark cyan stripes."
BLUE_DARK_BLUE = 12
"Blue color with dark blue stripes."
PINK_DARK_PINK = 13
"Pink color with dark pink stripes."
BLUE_WHITE_RED = 14
"Blue color with white and red stripes."
ORANGE_WHITE_GREEN = 15
"Orange color with white and green stripes."
GREEN_WHITE_RED = 16
"Green color with white and red stripes."
CYAN_WHITE_GREEN = 17
"Cyan color with white and red green."
CYAN_YELLOW_PINK = 18
"Cyan color with yellow and pink stripes."
VIOLET_YELLOW_ORANGE = 19
"Violet color with yellow and orange stripes."
BLUE_WHITE_ORANGE = 20
"Blue color with white and orange stripes."
DYNAMIC = 21
"""Secret color that cannot be set.
For now:
Red - If you use Telegram desktop.
Blue - If you are using Telegram android/ios.
"""

View file

@ -20,18 +20,15 @@ from typing import Union
import pyrogram import pyrogram
from pyrogram import raw from pyrogram import raw
from pyrogram import types from pyrogram import enums
# account.updateColor flags: color:int background_emoji_id:flags.0?long = Bool;
# channels.updateColor flags: channel:InputChannel color:int background_emoji_id:flags.0?long = Updates;
class UpdateColor: class UpdateColor:
async def update_color( async def update_color(
self: "pyrogram.Client", self: "pyrogram.Client",
chat_id: Union[int, str], chat_id: Union[int, str],
color: int, color: Union["enums.ReplyColor", "enums.ProfileColor"],
background_emoji_id: int = None, background_emoji_id: int = None
) -> "types.Chat": ) -> bool:
"""Update color """Update color
.. include:: /_includes/usable-by/users.rst .. include:: /_includes/usable-by/users.rst
@ -40,41 +37,38 @@ class UpdateColor:
chat_id (``int`` | ``str``): chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat. Unique identifier (int) or username (str) of the target chat.
color (``int``): color (:obj:`~pyrogram.enums.ReplyColor` | :obj:`~pyrogram.enums.ProfileColor`):
Numeric color identifier. Color type.
Profile color can only be set for the user.
background_emoji_id (``int``, *optional*): background_emoji_id (``int``, *optional*):
Unique identifier of the custom emoji. Unique identifier of the custom emoji.
Returns: Returns:
:obj:`~pyrogram.types.Chat`: On success, a chat object is returned. ``bool``: On success, in case the passed-in session is authorized, True is returned.
Example: Example:
.. code-block:: python .. code-block:: python
await app.update_color(chat_id, 1) await app.update_color(chat_id, enums.ReplyColor.RED)
""" """
peer = await self.resolve_peer(chat_id) peer = await self.resolve_peer(chat_id)
if isinstance(peer, raw.types.InputPeerSelf): if isinstance(peer, raw.types.InputPeerSelf):
await self.invoke( r = await self.invoke(
raw.functions.account.UpdateColor( raw.functions.account.UpdateColor(
color=color, for_profile=isinstance(color, enums.ProfileColor),
color=color.value,
background_emoji_id=background_emoji_id background_emoji_id=background_emoji_id
) )
) )
r = await self.invoke(raw.functions.users.GetUsers(id=[raw.types.InputPeerSelf()]))
chat = r[0]
else: else:
r = await self.invoke( r = await self.invoke(
raw.functions.channels.UpdateColor( raw.functions.channels.UpdateColor(
channel=peer, channel=peer,
color=color, color=color.value,
background_emoji_id=background_emoji_id background_emoji_id=background_emoji_id
) )
) )
chat = r.chats[0]
return types.Chat._parse_chat(self, chat) return bool(r)

View file

@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import Union from typing import Union, List
import pyrogram import pyrogram
from pyrogram import raw from pyrogram import raw
@ -28,7 +28,7 @@ class SendReaction:
chat_id: Union[int, str], chat_id: Union[int, str],
message_id: int = None, message_id: int = None,
story_id: int = None, story_id: int = None,
emoji: str = "", emoji: Union[int, str, List[Union[int, str]]] = None,
big: bool = False big: bool = False
) -> bool: ) -> bool:
"""Send a reaction to a message. """Send a reaction to a message.
@ -45,9 +45,10 @@ class SendReaction:
story_id (``int``, *optional*): story_id (``int``, *optional*):
Identifier of the story. Identifier of the story.
emoji (``str``, *optional*): emoji (``int`` | ``str`` | List of ``int`` | ``str``, *optional*):
Reaction emoji. Reaction emoji.
Pass "" as emoji (default) to retract the reaction. Pass None as emoji (default) to retract the reaction.
Pass list of int or str to react multiple emojis.
big (``bool``, *optional*): big (``bool``, *optional*):
Pass True to show a bigger and longer reaction. Pass True to show a bigger and longer reaction.
@ -64,16 +65,31 @@ class SendReaction:
await app.send_reaction(chat_id, message_id=message_id, emoji="🔥") await app.send_reaction(chat_id, message_id=message_id, emoji="🔥")
await app.send_reaction(chat_id, story_id=story_id, emoji="🔥") await app.send_reaction(chat_id, story_id=story_id, emoji="🔥")
# Send a multiple reactions
await app.send_reaction(chat_id, message_id=message_id, emoji=["🔥", "❤️"])
# Retract a reaction # Retract a reaction
await app.send_reaction(chat_id, message_id=message_id) await app.send_reaction(chat_id, message_id=message_id)
await app.send_reaction(chat_id, story_id=story_id) await app.send_reaction(chat_id, story_id=story_id)
""" """
if isinstance(emoji, list):
emoji = [
raw.types.ReactionCustomEmoji(document_id=i)
if isinstance(i, int)
else raw.types.ReactionEmoji(emoticon=i)
for i in emoji
] if emoji else None
else:
if isinstance(emoji, int):
emoji = [raw.types.ReactionCustomEmoji(document_id=emoji)]
else:
emoji = [raw.types.ReactionEmoji(emoticon=emoji)] if emoji else None
if message_id is not None: if message_id is not None:
await self.invoke( await self.invoke(
raw.functions.messages.SendReaction( raw.functions.messages.SendReaction(
peer=await self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
msg_id=message_id, msg_id=message_id,
reaction=[raw.types.ReactionEmoji(emoticon=emoji)] if emoji else None, reaction=emoji,
big=big big=big
) )
) )

View file

@ -19,6 +19,7 @@
from .chat import Chat from .chat import Chat
from .chat_admin_with_invite_links import ChatAdminWithInviteLinks from .chat_admin_with_invite_links import ChatAdminWithInviteLinks
from .chat_color import ChatColor
from .chat_event import ChatEvent from .chat_event import ChatEvent
from .chat_event_filter import ChatEventFilter from .chat_event_filter import ChatEventFilter
from .chat_invite_link import ChatInviteLink from .chat_invite_link import ChatInviteLink
@ -67,6 +68,7 @@ __all__ = [
"ChatInviteLink", "ChatInviteLink",
"InviteLinkImporter", "InviteLinkImporter",
"ChatAdminWithInviteLinks", "ChatAdminWithInviteLinks",
"ChatColor",
"ForumTopic", "ForumTopic",
"ForumTopicCreated", "ForumTopicCreated",
"ForumTopicClosed", "ForumTopicClosed",

View file

@ -144,11 +144,11 @@ class Chat(Object):
List of all chat (fragment) usernames; for private chats, supergroups and channels. List of all chat (fragment) usernames; for private chats, supergroups and channels.
Returned only in :meth:`~pyrogram.Client.get_chat`. Returned only in :meth:`~pyrogram.Client.get_chat`.
color (``int``, *optional*) reply_color (:obj:`~pyrogram.types.ChatColor`, *optional*)
Chat color. Chat reply color.
background_emoji_id (``int``, *optional*) profile_color (:obj:`~pyrogram.types.ChatColor`, *optional*)
Chat background emoji id. Chat profile color.
""" """
def __init__( def __init__(
@ -186,8 +186,8 @@ class Chat(Object):
send_as_chat: "types.Chat" = None, send_as_chat: "types.Chat" = None,
available_reactions: Optional["types.ChatReactions"] = None, available_reactions: Optional["types.ChatReactions"] = None,
usernames: List["types.Username"] = None, usernames: List["types.Username"] = None,
color: int = None, reply_color: "types.ChatColor" = None,
background_emoji_id: int = None profile_color: "types.ChatColor" = None
): ):
super().__init__(client) super().__init__(client)
@ -222,8 +222,8 @@ class Chat(Object):
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.usernames = usernames self.usernames = usernames
self.color = color self.reply_color = reply_color
self.background_emoji_id = background_emoji_id self.profile_color = profile_color
@property @property
def full_name(self) -> str: def full_name(self) -> str:
@ -247,8 +247,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), reply_color=types.ChatColor._parse(getattr(user, "color", None)),
background_emoji_id=getattr(user, "background_emoji_id", None), profile_color=types.ChatColor._parse_profile_color(getattr(user, "profile_color", None)),
client=client client=client
) )
@ -310,8 +310,7 @@ 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), reply_color=types.ChatColor._parse(getattr(channel, "color", None)),
background_emoji_id=getattr(channel, "background_emoji_id", None),
client=client client=client
) )

View file

@ -0,0 +1,64 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork 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.
#
# Pyrofork 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 Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from typing import Optional, Union
from pyrogram import raw
from pyrogram import enums
from ..object import Object
class ChatColor(Object):
"""Reply or profile color status.
Parameters:
color (:obj:`~pyrogram.enums.ReplyColor` | :obj:`~pyrogram.enums.ProfileColor`, *optional*):
Color type.
background_emoji_id (``int``, *optional*):
Unique identifier of the custom emoji.
"""
def __init__(
self,
*,
color: Union["enums.ReplyColor", "enums.ProfileColor"] = None,
background_emoji_id: int = None
):
self.color = color
self.background_emoji_id = background_emoji_id
@staticmethod
def _parse(color: "raw.types.PeerColor" = None) -> Optional["ChatColor"]:
if not color:
return None
return ChatColor(
color=enums.ReplyColor(color.color) if getattr(color, "color", None) else None,
background_emoji_id=getattr(color, "background_emoji_id", None)
)
@staticmethod
def _parse_profile_color(color: "raw.types.PeerColor" = None) -> Optional["ChatColor"]:
if not color:
return None
return ChatColor(
color=enums.ProfileColor(color.color) if getattr(color, "color", None) else None,
background_emoji_id=getattr(color, "background_emoji_id", None)
)

View file

@ -154,11 +154,11 @@ class User(Object, Update):
``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*) reply_color (:obj:`~pyrogram.types.ChatColor`, *optional*)
Chat color. Chat reply color.
background_emoji_id (``int``, *optional*) profile_color (:obj:`~pyrogram.types.ChatColor`, *optional*)
Chat background emoji id. Chat profile color.
""" """
def __init__( def __init__(
@ -190,8 +190,8 @@ class User(Object, Update):
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, reply_color: "types.ChatColor" = None,
background_emoji_id: int = None profile_color: "types.ChatColor" = None
): ):
super().__init__(client) super().__init__(client)
@ -220,8 +220,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.reply_color = reply_color
self.background_emoji_id = background_emoji_id self.profile_color = profile_color
@property @property
def full_name(self) -> str: def full_name(self) -> str:
@ -274,8 +274,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), reply_color=types.ChatColor._parse(getattr(user, "color", None)),
background_emoji_id=getattr(user, "background_emoji_id", None), profile_color=types.ChatColor._parse_profile_color(getattr(user, "profile_color", None)),
client=client client=client
) )