mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Add chat_reactions.py
This commit is contained in:
parent
fe7fcf3448
commit
9eb7589a7f
@ -29,6 +29,7 @@ from .chat_permissions import ChatPermissions
|
|||||||
from .chat_photo import ChatPhoto
|
from .chat_photo import ChatPhoto
|
||||||
from .chat_preview import ChatPreview
|
from .chat_preview import ChatPreview
|
||||||
from .chat_privileges import ChatPrivileges
|
from .chat_privileges import ChatPrivileges
|
||||||
|
from .chat_reactions import ChatReactions
|
||||||
from .dialog import Dialog
|
from .dialog import Dialog
|
||||||
from .emoji_status import EmojiStatus
|
from .emoji_status import EmojiStatus
|
||||||
from .invite_link_importer import InviteLinkImporter
|
from .invite_link_importer import InviteLinkImporter
|
||||||
@ -61,5 +62,6 @@ __all__ = [
|
|||||||
"ChatJoinRequest",
|
"ChatJoinRequest",
|
||||||
"ChatPrivileges",
|
"ChatPrivileges",
|
||||||
"ChatJoiner",
|
"ChatJoiner",
|
||||||
"EmojiStatus"
|
"EmojiStatus",
|
||||||
|
"ChatReactions"
|
||||||
]
|
]
|
||||||
|
@ -126,7 +126,7 @@ class Chat(Object):
|
|||||||
The default "send_as" chat.
|
The default "send_as" chat.
|
||||||
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||||
|
|
||||||
available_reactions (List of ``str``, *optional*):
|
available_reactions (List of :obj:`~pyrogram.types.Reaction`, *optional*):
|
||||||
Available reactions in the chat.
|
Available reactions in the chat.
|
||||||
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||||
"""
|
"""
|
||||||
@ -162,7 +162,7 @@ class Chat(Object):
|
|||||||
distance: int = None,
|
distance: int = None,
|
||||||
linked_chat: "types.Chat" = None,
|
linked_chat: "types.Chat" = None,
|
||||||
send_as_chat: "types.Chat" = None,
|
send_as_chat: "types.Chat" = None,
|
||||||
available_reactions: List[str] = None
|
available_reactions: Optional[List["types.Reaction"]] = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ class Chat(Object):
|
|||||||
if isinstance(full_chat.exported_invite, raw.types.ChatInviteExported):
|
if isinstance(full_chat.exported_invite, raw.types.ChatInviteExported):
|
||||||
parsed_chat.invite_link = full_chat.exported_invite.link
|
parsed_chat.invite_link = full_chat.exported_invite.link
|
||||||
|
|
||||||
parsed_chat.available_reactions = full_chat.available_reactions or None
|
parsed_chat.available_reactions = types.ChatReactions._parse(client, full_chat.available_reactions)
|
||||||
|
|
||||||
return parsed_chat
|
return parsed_chat
|
||||||
|
|
||||||
|
69
pyrogram/types/user_and_chats/chat_reactions.py
Normal file
69
pyrogram/types/user_and_chats/chat_reactions.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# 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 Optional, List
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw, types
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class ChatReactions(Object):
|
||||||
|
"""A chat reactions
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
all_are_enabled (``bool``, *optional*)
|
||||||
|
|
||||||
|
allow_custom_emoji (``bool``, *optional*):
|
||||||
|
Whether custom emoji are allowed or not.
|
||||||
|
|
||||||
|
reactions (List of :obj:`~pyrogram.types.Reaction`, *optional*):
|
||||||
|
Reactions available.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
client: "pyrogram.Client" = None,
|
||||||
|
all_are_enabled: Optional[bool] = None,
|
||||||
|
allow_custom_emoji: Optional[bool] = None,
|
||||||
|
reactions: Optional[List["types.Reaction"]] = None,
|
||||||
|
):
|
||||||
|
super().__init__(client)
|
||||||
|
|
||||||
|
self.all_are_enabled = all_are_enabled
|
||||||
|
self.allow_custom_emoji = allow_custom_emoji
|
||||||
|
self.reactions = reactions
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(client, chat_reactions: "raw.base.ChatReactions") -> Optional["ChatReactions"]:
|
||||||
|
if isinstance(chat_reactions, raw.types.ChatReactionsAll):
|
||||||
|
return ChatReactions(
|
||||||
|
client=client,
|
||||||
|
all_are_enabled=True,
|
||||||
|
allow_custom_emoji=chat_reactions.allow_custom
|
||||||
|
)
|
||||||
|
|
||||||
|
if isinstance(chat_reactions, raw.types.ChatReactionsSome):
|
||||||
|
return ChatReactions(
|
||||||
|
client=client,
|
||||||
|
reactions=[types.Reaction._parse(client, reaction)
|
||||||
|
for reaction in chat_reactions.reactions]
|
||||||
|
)
|
||||||
|
|
||||||
|
return None
|
Loading…
x
Reference in New Issue
Block a user