2323"""
2424
2525import datetime
26- from typing import TYPE_CHECKING , Union
26+ from typing import TYPE_CHECKING , Union , Optional
2727
2828if TYPE_CHECKING :
2929 from .channel import Channel
3030 from .chatter import Chatter , PartialChatter
3131
32+ class HypeChatData :
33+ """
34+ Represents information about hype chats.
35+
36+ Attributes
37+ -----------
38+ amount: :class:`int`
39+ The amount paid.
40+ canonical_amount: :class:`int`
41+ The canonical amount paid(?) # FIXME: figure this out before next version release
42+ currency: :class:`str`
43+ The currency paid in, in standard form (eg. USD, EUR, GBP).
44+ is_system_message: :class:`bool`
45+ Whether this Hype Chat originated from a user or Twitch.
46+ level: :class:`str`
47+ The level this Hype Chat reached. For some reason this is a spelled out number (ex ``TWO``).
48+ """
49+
50+ def __init__ (self , tags : dict ) -> None :
51+ self .amount : int = int (tags ["pinned-chat-paid-amount" ])
52+ self .canonical_amount : int = int (tags ["pinned-chat-paid-canonical-amount" ])
53+ self .currency : str = tags ["pinned-chat-paid-currency" ]
54+ self .is_system_message : bool = tags ["pinned-chat-paid-is-system-message" ] == "1"
55+ self .level : str = tags ["pinned-chat-paid-level" ]
3256
3357class Message :
3458 """
@@ -40,12 +64,14 @@ class Message:
4064 Boolean representing if this is a self-message or not.
4165 first: :class:`bool`
4266 Boolean representing whether it's a first message or not.
43-
67+ hype_chat_data: Optional[:class:`HypeChatData`]
68+ Any hype chat information associated with the message. This will be ``None`` when the message is not a hype chat.
4469 """
4570
4671 __slots__ = (
4772 "_raw_data" ,
4873 "content" ,
74+ "hype_chat_data" ,
4975 "_author" ,
5076 "echo" ,
5177 "first" ,
@@ -76,6 +102,11 @@ def __init__(self, **kwargs):
76102 self ._id = None
77103 self ._timestamp = datetime .datetime .now ().timestamp () * 1000
78104
105+ if "pinned-chat-paid-amount" in self ._tags :
106+ self .hype_chat_data : Optional [HypeChatData ] = HypeChatData (self ._tags )
107+ else :
108+ self .hype_chat_data : Optional [HypeChatData ] = None
109+
79110 @property
80111 def id (self ) -> str :
81112 """The Message ID."""
0 commit comments