mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-30 17:43:32 +00:00
Add update_color method
This commit is contained in:
parent
d342f762e4
commit
1c804ff434
@ -61,6 +61,7 @@ from .unarchive_chats import UnarchiveChats
|
|||||||
from .unban_chat_member import UnbanChatMember
|
from .unban_chat_member import UnbanChatMember
|
||||||
from .unpin_all_chat_messages import UnpinAllChatMessages
|
from .unpin_all_chat_messages import UnpinAllChatMessages
|
||||||
from .unpin_chat_message import UnpinChatMessage
|
from .unpin_chat_message import UnpinChatMessage
|
||||||
|
from .update_color import UpdateColor
|
||||||
|
|
||||||
|
|
||||||
class Chats(
|
class Chats(
|
||||||
@ -79,6 +80,7 @@ class Chats(
|
|||||||
SetChatDescription,
|
SetChatDescription,
|
||||||
PinChatMessage,
|
PinChatMessage,
|
||||||
UnpinChatMessage,
|
UnpinChatMessage,
|
||||||
|
UpdateColor,
|
||||||
GetDialogs,
|
GetDialogs,
|
||||||
GetChatMembersCount,
|
GetChatMembersCount,
|
||||||
SetChatUsername,
|
SetChatUsername,
|
||||||
|
79
pyrogram/methods/chats/update_color.py
Normal file
79
pyrogram/methods/chats/update_color.py
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
from pyrogram import types
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
async def update_color(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
chat_id: Union[int, str],
|
||||||
|
color: int,
|
||||||
|
background_emoji_id: int = None,
|
||||||
|
) -> "types.Chat":
|
||||||
|
"""Update color
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users-bots.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
chat_id (``int`` | ``str``):
|
||||||
|
Unique identifier (int) or username (str) of the target chat.
|
||||||
|
|
||||||
|
color (``int``):
|
||||||
|
Color
|
||||||
|
|
||||||
|
background_emoji_id (``int``, *optional*):
|
||||||
|
Background emoji
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
``bool``: True on success.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
await app.update_color(chat_id, 1)
|
||||||
|
"""
|
||||||
|
|
||||||
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
|
if isinstance(peer, raw.types.InputPeerSelf):
|
||||||
|
await self.invoke(
|
||||||
|
raw.functions.account.UpdateColor(
|
||||||
|
color=color,
|
||||||
|
background_emoji_id=background_emoji_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
r = await self.invoke(raw.functions.users.GetUsers(id=[raw.types.InputPeerSelf()]))
|
||||||
|
return types.Chat._parse_user_chat(self, r)
|
||||||
|
else:
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.channels.UpdateColor(
|
||||||
|
channel=peer,
|
||||||
|
color=color,
|
||||||
|
background_emoji_id=background_emoji_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return types.Chat._parse_channel_chat(self, r.chats[0])
|
Loading…
Reference in New Issue
Block a user