@@ -261,6 +261,24 @@ def _subscribe_with_broadcaster(
261261 broadcaster = str (broadcaster )
262262 sub = _Subscription (event , {"broadcaster_user_id" : broadcaster }, token )
263263 self ._assign_subscription (sub )
264+
265+ def _subscribe_with_broadcaster_moderator (
266+ self ,
267+ event : Tuple [str , int , Type [models ._DataType ]],
268+ broadcaster : Union [PartialUser , str , int ],
269+ moderator : Union [PartialUser , str , int ],
270+ token : str
271+ ):
272+ if isinstance (broadcaster , PartialUser ):
273+ broadcaster = broadcaster .id
274+ if isinstance (moderator , PartialUser ):
275+ moderator = moderator .id
276+
277+ broadcaster = str (broadcaster )
278+ moderator = str (moderator )
279+ sub = _Subscription (event , {"broadcaster_user_id" : broadcaster , "moderator_user_id" : moderator }, token )
280+ self ._assign_subscription (sub )
281+
264282
265283 def subscribe_channel_bans (self , broadcaster : Union [PartialUser , str , int ], token : str ):
266284 return self ._subscribe_with_broadcaster (models .SubscriptionTypes .ban , broadcaster , token )
@@ -287,7 +305,12 @@ def subscribe_channel_update(self, broadcaster: Union[PartialUser, str, int], to
287305 return self ._subscribe_with_broadcaster (models .SubscriptionTypes .channel_update , broadcaster , token )
288306
289307 def subscribe_channel_follows (self , broadcaster : Union [PartialUser , str , int ], token : str ):
290- return self ._subscribe_with_broadcaster (models .SubscriptionTypes .follow , broadcaster , token )
308+ raise RuntimeError ("This subscription has been removed by twitch, please use subscribe_channel_follows_v2" )
309+
310+ def subscribe_channel_follows_v2 (
311+ self , broadcaster : Union [PartialUser , str , int ], moderator : Union [PartialUser , str , int ], token : str
312+ ):
313+ return self ._subscribe_with_broadcaster_moderator (models .SubscriptionTypes .followV2 , broadcaster , moderator , token )
291314
292315 def subscribe_channel_moderators_add (self , broadcaster : Union [PartialUser , str , int ], token : str ):
293316 return self ._subscribe_with_broadcaster (models .SubscriptionTypes .channel_moderator_add , broadcaster , token )
@@ -365,10 +388,31 @@ def subscribe_channel_prediction_lock(self, broadcaster: Union[PartialUser, str,
365388 def subscribe_channel_prediction_end (self , broadcaster : Union [PartialUser , str , int ], token : str ):
366389 return self ._subscribe_with_broadcaster (models .SubscriptionTypes .prediction_end , broadcaster , token )
367390
368- def subscribe_user_authorization_granted (self , token : str ):
369- sub = _Subscription (models .SubscriptionTypes .user_authorization_grant , {"client_id" : self .client ._http .client_id }, token )
370- self ._assign_subscription (sub )
391+
392+ def subscribe_channel_shield_mode_begin (
393+ self , broadcaster : Union [PartialUser , str , int ], moderator : Union [PartialUser , str , int ], token : str
394+ ):
395+ return self ._subscribe_with_broadcaster_moderator (
396+ models .SubscriptionTypes .channel_shield_mode_begin , broadcaster , moderator , token
397+ )
371398
372- async def subscribe_user_authorization_revoked (self , token : str ):
373- sub = _Subscription (models .SubscriptionTypes .user_authorization_revoke , {"client_id" : self .client ._http .client_id }, token )
374- self ._assign_subscription (sub )
399+ def subscribe_channel_shield_mode_end (
400+ self , broadcaster : Union [PartialUser , str , int ], moderator : Union [PartialUser , str , int ], token : str
401+ ):
402+ return self ._subscribe_with_broadcaster_moderator (
403+ models .SubscriptionTypes .channel_shield_mode_end , broadcaster , moderator , token
404+ )
405+
406+ def subscribe_channel_shoutout_create (
407+ self , broadcaster : Union [PartialUser , str , int ], moderator : Union [PartialUser , str , int ], token : str
408+ ):
409+ return self ._subscribe_with_broadcaster_moderator (
410+ models .SubscriptionTypes .channel_shoutout_create , broadcaster , moderator , token
411+ )
412+
413+ def subscribe_channel_shoutout_receive (
414+ self , broadcaster : Union [PartialUser , str , int ], moderator : Union [PartialUser , str , int ], token : str
415+ ):
416+ return self ._subscribe_with_broadcaster_moderator (
417+ models .SubscriptionTypes .channel_shoutout_receive , broadcaster , moderator , token
418+ )
0 commit comments