[PyroFork] Add update_color method

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
Yasir Aris M 2023-12-23 14:45:04 +00:00 committed by wulan17
parent 1dcbc6bf59
commit 1329d2ec87
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
4 changed files with 88 additions and 2 deletions

View file

@ -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_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_INCLUDE_EMPTY The filter include is empty
FIRSTNAME_INVALID The first name is invalid
FOLDER_ID_EMPTY The folder you tried to delete was already empty
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_INVALID The provided reply markup is invalid
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
RESULT_ID_DUPLICATE The result contains items with duplicated identifiers
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_VIDEO_NOWEBM A webm video file was expected, but something else was provided
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_REQUIRED The method must be invoked inside a takeout session
TEMP_AUTH_KEY_EMPTY The temporary auth key provided is empty

1 id message
125 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
126 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
127 FILTER_ID_INVALID The specified filter ID is invalid
128 FILTER_INCLUDE_EMPTY The filter include is empty
129 FIRSTNAME_INVALID The first name is invalid
130 FOLDER_ID_EMPTY The folder you tried to delete was already empty
131 FOLDER_ID_INVALID The folder id is invalid
268 REPLY_MARKUP_GAME_EMPTY The provided reply markup for the game is empty
269 REPLY_MARKUP_INVALID The provided reply markup is invalid
270 REPLY_MARKUP_TOO_LONG The reply markup is too long
271 REPLY_MESSAGE_ID_INVALID The reply message id is invalid
272 RESULTS_TOO_MUCH The result contains too many items
273 RESULT_ID_DUPLICATE The result contains items with duplicated identifiers
274 RESULT_ID_EMPTY Result ID empty
311 STICKER_THUMB_PNG_NOPNG A png sticker thumbnail file was expected, but something else was provided
312 STICKER_VIDEO_NOWEBM A webm video file was expected, but something else was provided
313 STORIES_TOO_MUCH Too many stories in the current account
314 STORY_PERIOD_INVALID The story period is invalid
315 TAKEOUT_INVALID The takeout id is invalid
316 TAKEOUT_REQUIRED The method must be invoked inside a takeout session
317 TEMP_AUTH_KEY_EMPTY The temporary auth key provided is empty

View file

@ -68,6 +68,7 @@ from .unarchive_chats import UnarchiveChats
from .unban_chat_member import UnbanChatMember
from .unpin_all_chat_messages import UnpinAllChatMessages
from .unpin_chat_message import UnpinChatMessage
from .update_color import UpdateColor
class Chats(
@ -121,6 +122,7 @@ class Chats(
GetChatOnlineCount,
GetSendAsChats,
SetSendAsChat,
SetChatProtectedContent
SetChatProtectedContent,
UpdateColor
):
pass

View 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)

View file

@ -148,7 +148,8 @@ class Message(Object, Update):
Date the message was last edited.
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*):
The unique identifier of a media message group this message belongs to.