mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-28 00:56:19 +00:00
Return bool from update_color
This commit is contained in:
parent
c88dd2bcf1
commit
50e2d102b4
@ -21,7 +21,6 @@ from typing import Union
|
|||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram import raw
|
from pyrogram import raw
|
||||||
from pyrogram import enums
|
from pyrogram import enums
|
||||||
from pyrogram import types
|
|
||||||
|
|
||||||
class UpdateColor:
|
class UpdateColor:
|
||||||
async def update_color(
|
async def update_color(
|
||||||
@ -29,7 +28,7 @@ class UpdateColor:
|
|||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
color: Union["enums.ReplyColor", "enums.ProfileColor"],
|
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,32 +39,29 @@ class UpdateColor:
|
|||||||
|
|
||||||
color (:obj:`~pyrogram.enums.ReplyColor` | :obj:`~pyrogram.enums.ProfileColor`):
|
color (:obj:`~pyrogram.enums.ReplyColor` | :obj:`~pyrogram.enums.ProfileColor`):
|
||||||
Color type.
|
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, enums.ProfileColor.RED)
|
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(
|
||||||
for_profile=isinstance(color, enums.ProfileColor),
|
for_profile=isinstance(color, enums.ProfileColor),
|
||||||
color=color.value,
|
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(
|
||||||
@ -74,6 +70,5 @@ class UpdateColor:
|
|||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user