mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Update reaction.py
This commit is contained in:
parent
1fb04b7616
commit
fe7fcf3448
@ -16,7 +16,10 @@
|
||||
# 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
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
@ -24,26 +27,53 @@ class Reaction(Object):
|
||||
"""Contains information about a reaction.
|
||||
|
||||
Parameters:
|
||||
emoji (``str``):
|
||||
emoji (``str``, *optional*):
|
||||
Reaction emoji.
|
||||
|
||||
count (``int``):
|
||||
Reaction count.
|
||||
custom_emoji_id (``int``, *optional*):
|
||||
Custom emoji id.
|
||||
|
||||
chosen (``bool``):
|
||||
Whether this is the chosen reaction.
|
||||
count (``int``, *optional*):
|
||||
Reaction count.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
client: "pyrogram.Client" = None,
|
||||
emoji: str,
|
||||
count: int,
|
||||
chosen: bool
|
||||
emoji: Optional[str] = None,
|
||||
custom_emoji_id: Optional[int] = None,
|
||||
count: Optional[int] = None
|
||||
):
|
||||
super().__init__(client)
|
||||
|
||||
self.emoji = emoji
|
||||
self.custom_emoji_id = custom_emoji_id
|
||||
self.count = count
|
||||
self.chosen = chosen
|
||||
|
||||
@staticmethod
|
||||
def _parse(
|
||||
client: "pyrogram.Client",
|
||||
reaction: "raw.base.Reaction"
|
||||
) -> "Reaction":
|
||||
if isinstance(reaction, raw.types.ReactionEmoji):
|
||||
return Reaction(
|
||||
client=client,
|
||||
emoji=reaction.emoticon
|
||||
)
|
||||
|
||||
if isinstance(reaction, raw.types.ReactionCustomEmoji):
|
||||
return Reaction(
|
||||
client=client,
|
||||
custom_emoji_id=reaction.document_id
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _parse_count(
|
||||
client: "pyrogram.Client",
|
||||
reaction_count: "raw.base.ReactionCount"
|
||||
) -> "Reaction":
|
||||
reaction = Reaction._parse(client, reaction_count.reaction)
|
||||
reaction.count = reaction_count.count
|
||||
|
||||
return reaction
|
||||
|
Loading…
x
Reference in New Issue
Block a user