mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-04 22:34:52 +00:00
[PyroFork] Add update_color method
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
1dcbc6bf59
commit
1329d2ec87
4 changed files with 88 additions and 2 deletions
|
|
@ -125,6 +125,7 @@ FILE_REFERENCE_EMPTY The file id contains an empty file reference, you must obta
|
||||||
FILE_REFERENCE_EXPIRED The file id contains an expired file reference, you must obtain a valid one by fetching the message from the origin context
|
FILE_REFERENCE_EXPIRED The file id contains an expired file reference, you must obtain a valid one by fetching the message from the origin context
|
||||||
FILE_REFERENCE_INVALID The file id contains an invalid file reference, you must obtain a valid one by fetching the message from the origin context
|
FILE_REFERENCE_INVALID The file id contains an invalid file reference, you must obtain a valid one by fetching the message from the origin context
|
||||||
FILTER_ID_INVALID The specified filter ID is invalid
|
FILTER_ID_INVALID The specified filter ID is invalid
|
||||||
|
FILTER_INCLUDE_EMPTY The filter include is empty
|
||||||
FIRSTNAME_INVALID The first name is invalid
|
FIRSTNAME_INVALID The first name is invalid
|
||||||
FOLDER_ID_EMPTY The folder you tried to delete was already empty
|
FOLDER_ID_EMPTY The folder you tried to delete was already empty
|
||||||
FOLDER_ID_INVALID The folder id is invalid
|
FOLDER_ID_INVALID The folder id is invalid
|
||||||
|
|
@ -267,6 +268,7 @@ REPLY_MARKUP_BUY_EMPTY Reply markup for buy button empty
|
||||||
REPLY_MARKUP_GAME_EMPTY The provided reply markup for the game is empty
|
REPLY_MARKUP_GAME_EMPTY The provided reply markup for the game is empty
|
||||||
REPLY_MARKUP_INVALID The provided reply markup is invalid
|
REPLY_MARKUP_INVALID The provided reply markup is invalid
|
||||||
REPLY_MARKUP_TOO_LONG The reply markup is too long
|
REPLY_MARKUP_TOO_LONG The reply markup is too long
|
||||||
|
REPLY_MESSAGE_ID_INVALID The reply message id is invalid
|
||||||
RESULTS_TOO_MUCH The result contains too many items
|
RESULTS_TOO_MUCH The result contains too many items
|
||||||
RESULT_ID_DUPLICATE The result contains items with duplicated identifiers
|
RESULT_ID_DUPLICATE The result contains items with duplicated identifiers
|
||||||
RESULT_ID_EMPTY Result ID empty
|
RESULT_ID_EMPTY Result ID empty
|
||||||
|
|
@ -309,6 +311,7 @@ STICKER_TGS_NOTGS A tgs sticker file was expected, but something else was provid
|
||||||
STICKER_THUMB_PNG_NOPNG A png sticker thumbnail file was expected, but something else was provided
|
STICKER_THUMB_PNG_NOPNG A png sticker thumbnail file was expected, but something else was provided
|
||||||
STICKER_VIDEO_NOWEBM A webm video file was expected, but something else was provided
|
STICKER_VIDEO_NOWEBM A webm video file was expected, but something else was provided
|
||||||
STORIES_TOO_MUCH Too many stories in the current account
|
STORIES_TOO_MUCH Too many stories in the current account
|
||||||
|
STORY_PERIOD_INVALID The story period is invalid
|
||||||
TAKEOUT_INVALID The takeout id is invalid
|
TAKEOUT_INVALID The takeout id is invalid
|
||||||
TAKEOUT_REQUIRED The method must be invoked inside a takeout session
|
TAKEOUT_REQUIRED The method must be invoked inside a takeout session
|
||||||
TEMP_AUTH_KEY_EMPTY The temporary auth key provided is empty
|
TEMP_AUTH_KEY_EMPTY The temporary auth key provided is empty
|
||||||
|
|
|
||||||
|
|
|
@ -68,6 +68,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(
|
||||||
|
|
@ -121,6 +122,7 @@ class Chats(
|
||||||
GetChatOnlineCount,
|
GetChatOnlineCount,
|
||||||
GetSendAsChats,
|
GetSendAsChats,
|
||||||
SetSendAsChat,
|
SetSendAsChat,
|
||||||
SetChatProtectedContent
|
SetChatProtectedContent,
|
||||||
|
UpdateColor
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
80
pyrogram/methods/chats/update_color.py
Normal file
80
pyrogram/methods/chats/update_color.py
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
# 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 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.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
chat_id (``int`` | ``str``):
|
||||||
|
Unique identifier (int) or username (str) of the target chat.
|
||||||
|
|
||||||
|
color (``int``):
|
||||||
|
Numeric color identifier.
|
||||||
|
|
||||||
|
background_emoji_id (``int``, *optional*):
|
||||||
|
Unique identifier of the custom emoji.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~pyrogram.types.Chat`: On success, a chat object is returned.
|
||||||
|
|
||||||
|
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()]))
|
||||||
|
chat = r[0]
|
||||||
|
else:
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.channels.UpdateColor(
|
||||||
|
channel=peer,
|
||||||
|
color=color,
|
||||||
|
background_emoji_id=background_emoji_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
chat = r.chats[0]
|
||||||
|
|
||||||
|
return types.Chat._parse_chat(self, chat)
|
||||||
|
|
@ -148,7 +148,8 @@ class Message(Object, Update):
|
||||||
Date the message was last edited.
|
Date the message was last edited.
|
||||||
|
|
||||||
edit_hide (``bool``, *optional*):
|
edit_hide (``bool``, *optional*):
|
||||||
True, if the message is edited by react.
|
The message shown as not modified.
|
||||||
|
A message can be not modified in case it has received a reaction.
|
||||||
|
|
||||||
media_group_id (``str``, *optional*):
|
media_group_id (``str``, *optional*):
|
||||||
The unique identifier of a media message group this message belongs to.
|
The unique identifier of a media message group this message belongs to.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue