@@ -237,6 +237,77 @@ def __init__(self, client: EventSubClient, data: dict):
237237 self .is_gift : bool = data ["is_gift" ]
238238
239239
240+ class ChannelSubscriptionGiftData (EventData ):
241+ """
242+ A Subscription Gift event
243+ Explicitly, the act of giving another user a Subscription.
244+ Receiving a gift-subscription uses ChannelSubscribeData above, with is_gift is ``True``
245+
246+ Attributes
247+ -----------
248+ is_anonymous: :class:`bool`
249+ Whether the gift sub was anonymous
250+ user: Optional[:class:`twitchio.PartialUser`]
251+ The user that gifted subs. Will be ``None`` if ``is_anonymous`` is ``True``
252+ broadcaster: :class:`twitchio.PartialUser`
253+ The channel that was subscribed to
254+ tier: :class:`int`
255+ The tier of the subscription
256+ total: :class:`int`
257+ The total number of subs gifted by a user at once
258+ cumulative_total: Optional[:class:`int`]
259+ The total number of subs gifted by a user overall. Will be ``None`` if ``is_anonymous`` is ``True``
260+ """
261+
262+ __slots__ = "is_anonymous" , "user" , "broadcaster" , "tier" , "total" , "cumulative"
263+
264+ def __init__ (self , client : EventSubClient , data : dict ):
265+ self .is_anonymous : bool = data ["is_anonymous" ]
266+ self .user : Optional [PartialUser ] = _transform_user (client , data , "user" ) if not self .is_anonymous else None
267+ self .broadcaster : Optional [PartialUser ] = _transform_user (client , data , "broadcaster_user" )
268+ self .tier = int (data ["tier" ])
269+ self .total = int (data ["total" ])
270+ self .cumulative_total : Optional [int ] = int (data ["cumulative_total" ]) if not self .is_anonymous else None
271+
272+
273+ class ChannelSubscriptionMessageData (EventData ):
274+ """
275+ A Subscription Message event.
276+ A combination of resubscriptions + the messages users type as part of the resub.
277+
278+ Attributes
279+ -----------
280+ user: :class:`twitchio.PartialUser`
281+ The user who subscribed
282+ broadcaster: :class:`twitchio.PartialUser`
283+ The channel that was subscribed to
284+ tier: :class:`int`
285+ The tier of the subscription
286+ message: :class:`str`
287+ The user's resubscription message
288+ emote_data: :class:`list`
289+ emote data within the user's resubscription message. Not the emotes themselves
290+ cumulative_months: :class:`int`
291+ The total number of months a user has subscribed to the channel
292+ streak: Optional[:class:`int`]
293+ The total number of months subscribed in a row. ``None`` if the user declines to share it.
294+ duration: :class:`int`
295+ The length of the subscription. Typically 1, but some users may buy subscriptions for several months.
296+ """
297+
298+ __slots__ = "user" , "broadcaster" , "tier" , "message" , "emote_data" , "cumulative" , "streak" , "duration"
299+
300+ def __init__ (self , client : EventSubClient , data : dict ):
301+ self .user = _transform_user (client , data , "user" )
302+ self .broadcaster = _transform_user (client , data , "broadcaster_user" )
303+ self .tier = int (data ["tier" ])
304+ self .message : str = data ["message" ]["text" ]
305+ self .emote_data : List [Dict ] = data ["message" ].get ("emotes" , [])
306+ self .cumulative_months : int = data ["cumulative_months" ]
307+ self .streak : Optional [int ] = data ["streak_months" ]
308+ self .duration : int = data ["duration_months" ]
309+
310+
240311class ChannelCheerData (EventData ):
241312 """
242313 A Cheer event
@@ -1092,6 +1163,8 @@ def __init__(self, client: EventSubClient, data: dict):
10921163 ChannelBanData ,
10931164 ChannelUnbanData ,
10941165 ChannelSubscribeData ,
1166+ ChannelSubscriptionGiftData ,
1167+ ChannelSubscriptionMessageData ,
10951168 ChannelCheerData ,
10961169 ChannelUpdateData ,
10971170 ChannelFollowData ,
@@ -1126,6 +1199,8 @@ class _SubscriptionTypes(metaclass=_SubTypesMeta):
11261199
11271200 follow = "channel.follow" , 1 , ChannelFollowData
11281201 subscription = "channel.subscribe" , 1 , ChannelSubscribeData
1202+ subscription_gift = "channel.subscription.gift" , 1 , ChannelSubscriptionGiftData
1203+ subscription_message = "channel.subscription.message" , 1 , ChannelSubscriptionMessageData
11291204 cheer = "channel.cheer" , 1 , ChannelCheerData
11301205 raid = "channel.raid" , 1 , ChannelRaidData
11311206 ban = "channel.ban" , 1 , ChannelBanData
0 commit comments