|
43 | 43 | "AutomodSettingsUpdateSubscription", |
44 | 44 | "AutomodTermsUpdateSubscription", |
45 | 45 | "ChannelBanSubscription", |
| 46 | + "ChannelBitsUseSubscription", |
46 | 47 | "ChannelCheerSubscription", |
47 | 48 | "ChannelFollowSubscription", |
48 | 49 | "ChannelModerateSubscription", |
|
115 | 116 | # Short names: Only map names that require shortening... |
116 | 117 | _SUB_MAPPING: dict[str, str] = { |
117 | 118 | "channel.ad_break.begin": "ad_break", |
| 119 | + "channel.bits.use": "bits_use", |
118 | 120 | "channel.chat.clear_user_messages": "chat_clear_user", |
119 | 121 | "channel.chat.message": "message", # Sub events? |
120 | 122 | "channel.chat.message_delete": "message_delete", |
@@ -404,6 +406,51 @@ def condition(self) -> Condition: |
404 | 406 | return {"broadcaster_user_id": self.broadcaster_user_id, "moderator_user_id": self.moderator_user_id} |
405 | 407 |
|
406 | 408 |
|
| 409 | +class ChannelBitsUseSubscription(SubscriptionPayload): |
| 410 | + """The ``channel.bits.use`` subscription type sends a notification whenever Bits are used on a channel. |
| 411 | +
|
| 412 | + This event is designed to be an all-purpose event for when Bits are used in a channel and might be updated in the future as more Twitch features use Bits. |
| 413 | +
|
| 414 | + Currently, this event will be sent when a user: |
| 415 | +
|
| 416 | + - Cheers in a channel |
| 417 | + - Uses a Power-up |
| 418 | + - Will not emit when a streamer uses a Power-up for free in their own channel. |
| 419 | +
|
| 420 | + .. important:: |
| 421 | + Requires a user access token that includes the ``bits:read`` scope. This must be the broadcaster's token. |
| 422 | +
|
| 423 | + Bits transactions via Twitch Extensions are not included in this subscription type. |
| 424 | +
|
| 425 | + One attribute ``.condition`` can be accessed from this class, which returns a mapping of the subscription |
| 426 | + parameters provided. |
| 427 | +
|
| 428 | + Parameters |
| 429 | + ---------- |
| 430 | + broadcaster_user_id: str | PartialUser |
| 431 | + The ID, or PartialUser, of the broadcaster to subscribe to. |
| 432 | +
|
| 433 | + Raises |
| 434 | + ------ |
| 435 | + ValueError |
| 436 | + The parameters "broadcaster_user_id" must be passed. |
| 437 | + """ |
| 438 | + |
| 439 | + type: ClassVar[Literal["channel.bits.use"]] = "channel.bits.use" |
| 440 | + version: ClassVar[Literal["1"]] = "1" |
| 441 | + |
| 442 | + @handle_user_ids() |
| 443 | + def __init__(self, **condition: Unpack[Condition]) -> None: |
| 444 | + self.broadcaster_user_id: str = condition.get("broadcaster_user_id", "") |
| 445 | + |
| 446 | + if not self.broadcaster_user_id: |
| 447 | + raise ValueError('The parameter "broadcaster_user_id" must be passed.') |
| 448 | + |
| 449 | + @property |
| 450 | + def condition(self) -> Condition: |
| 451 | + return {"broadcaster_user_id": self.broadcaster_user_id} |
| 452 | + |
| 453 | + |
407 | 454 | class ChannelUpdateSubscription(SubscriptionPayload): |
408 | 455 | """The ``channel.update`` subscription type sends notifications when a broadcaster updates the category, title, content classification labels, or broadcast language for their channel. |
409 | 456 |
|
|
0 commit comments