Skip to content

Commit 50e2d10

Browse files
Return bool from update_color
1 parent c88dd2b commit 50e2d10

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

pyrogram/methods/chats/update_color.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
import pyrogram
2222
from pyrogram import raw
2323
from pyrogram import enums
24-
from pyrogram import types
2524

2625
class UpdateColor:
2726
async def update_color(
2827
self: "pyrogram.Client",
2928
chat_id: Union[int, str],
3029
color: Union["enums.ReplyColor", "enums.ProfileColor"],
3130
background_emoji_id: int = None
32-
) -> "types.Chat":
31+
) -> bool:
3332
"""Update color
3433
3534
.. include:: /_includes/usable-by/users.rst
@@ -40,32 +39,29 @@ async def update_color(
4039
4140
color (:obj:`~pyrogram.enums.ReplyColor` | :obj:`~pyrogram.enums.ProfileColor`):
4241
Color type.
42+
Profile color can only be set for the user.
4343
4444
background_emoji_id (``int``, *optional*):
4545
Unique identifier of the custom emoji.
4646
4747
Returns:
48-
:obj:`~pyrogram.types.Chat`: On success, a chat object is returned.
48+
``bool``: On success, in case the passed-in session is authorized, True is returned.
4949
5050
Example:
5151
.. code-block:: python
5252
53-
await app.update_color(chat_id, enums.ProfileColor.RED)
53+
await app.update_color(chat_id, enums.ReplyColor.RED)
5454
"""
55-
5655
peer = await self.resolve_peer(chat_id)
5756

5857
if isinstance(peer, raw.types.InputPeerSelf):
59-
await self.invoke(
58+
r = await self.invoke(
6059
raw.functions.account.UpdateColor(
6160
for_profile=isinstance(color, enums.ProfileColor),
6261
color=color.value,
6362
background_emoji_id=background_emoji_id
6463
)
6564
)
66-
67-
r = await self.invoke(raw.functions.users.GetUsers(id=[raw.types.InputPeerSelf()]))
68-
chat = r[0]
6965
else:
7066
r = await self.invoke(
7167
raw.functions.channels.UpdateColor(
@@ -74,6 +70,5 @@ async def update_color(
7470
background_emoji_id=background_emoji_id
7571
)
7672
)
77-
chat = r.chats[0]
7873

79-
return types.Chat._parse_chat(self, chat)
74+
return bool(r)

0 commit comments

Comments
 (0)