From 2a17329ba61da9815abf22450fe9f7f0e3f756f9 Mon Sep 17 00:00:00 2001 From: chillymosh <86857777+chillymosh@users.noreply.github.com> Date: Tue, 31 Dec 2024 08:49:04 +0000 Subject: [PATCH] Update tiers to be Literal instead of string. --- twitchio/models/eventsub_.py | 16 ++++++++-------- twitchio/types_/eventsub.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/twitchio/models/eventsub_.py b/twitchio/models/eventsub_.py index 08d6f79d..ce695c52 100644 --- a/twitchio/models/eventsub_.py +++ b/twitchio/models/eventsub_.py @@ -1783,7 +1783,7 @@ class ChannelSubscribe(BaseEvent): The broadcaster whose channel received a subscription. user: PartialUser The user who subscribed to the channel. - tier: str + tier: typing.Literal["1000", "2000", "3000"] The tier of the subscription. Valid values are 1000, 2000, and 3000. gift: bool Whether the subscription is a gift. @@ -1820,7 +1820,7 @@ class ChannelSubscriptionEnd(BaseEvent): The broadcaster whose channel had the subscription end. user: PartialUser The user whose subscription ended. - tier: str + tier: typing.Literal["1000", "2000", "3000"] The tier of the subscription that ended. Valid values are 1000, 2000, and 3000. gift: bool Whether the subscription was a gift. @@ -1840,7 +1840,7 @@ def __init__(self, payload: ChannelSubscriptionEndEvent, *, http: HTTPClient) -> payload["broadcaster_user_id"], payload["broadcaster_user_login"], payload["broadcaster_user_name"], http=http ) self.user: PartialUser = PartialUser(payload["user_id"], payload["user_login"], payload["user_name"], http=http) - self.tier: str = payload["tier"] + self.tier: Literal["1000", "2000", "3000"] = payload["tier"] self.gift: bool = bool(payload["is_gift"]) def __repr__(self) -> str: @@ -1857,7 +1857,7 @@ class ChannelSubscriptionGift(BaseEvent): The broadcaster whose channel received the gift subscriptions. user: PartialUser | None The user who sent the gift. `None` if it was an anonymous subscription gift. - tier: str + tier: typing.Literal["1000", "2000", "3000"] The tier of the subscription that ended. Valid values are 1000, 2000, and 3000. total: int The number of subscriptions in the subscription gift. @@ -1881,7 +1881,7 @@ def __init__(self, payload: ChannelSubscriptionGiftEvent, *, http: HTTPClient) - if payload["user_id"] is not None else None ) - self.tier: str = payload["tier"] + self.tier: Literal["1000", "2000", "3000"] = payload["tier"] self.total: int = int(payload["total"]) self.anonymous: bool = bool(payload["is_anonymous"]) cumulative_total = payload.get("cumulative_total") @@ -1934,8 +1934,8 @@ class ChannelSubscriptionMessage(BaseEvent): The broadcaster whose channel received a subscription message. user: PartialUser The user who sent a resubscription chat message. - tier: str - The tier of the user's subscription. + tier: typing.Literal["1000", "2000", "3000"] + The tier of the user's subscription. Valid values are 1000, 2000, and 3000. months: str The month duration of the subscription. cumulative_months: int @@ -1958,7 +1958,7 @@ def __init__(self, payload: ChannelSubscribeMessageEvent, *, http: HTTPClient) - payload["broadcaster_user_id"], payload["broadcaster_user_login"], payload["broadcaster_user_name"], http=http ) self.user: PartialUser = PartialUser(payload["user_id"], payload["user_login"], payload["user_name"], http=http) - self.tier: str = payload["tier"] + self.tier: Literal["1000", "2000", "3000"] = payload["tier"] self.months: int = int(payload["duration_months"]) self.cumulative_months: int = int(payload["cumulative_months"]) self.streak_months: int | None = int(payload["streak_months"]) if payload["streak_months"] is not None else None diff --git a/twitchio/types_/eventsub.py b/twitchio/types_/eventsub.py index aeb92106..0807e9c6 100644 --- a/twitchio/types_/eventsub.py +++ b/twitchio/types_/eventsub.py @@ -632,7 +632,7 @@ class ChannelSubscribeEvent(BroadcasterUserEvent): class ChannelSubscriptionEndEvent(BroadcasterUserEvent): - tier: str + tier: Literal["1000", "2000", "3000"] is_gift: bool @@ -641,7 +641,7 @@ class ChannelSubscriptionGiftEvent(BaseBroadcasterEvent): user_login: str | None user_name: str | None total: int - tier: str + tier: Literal["1000", "2000", "3000"] cumulative_total: int | None is_anonymous: bool @@ -665,7 +665,7 @@ class SubscribeMessageData(BaseMessageData): ... class ChannelSubscribeMessageEvent(BroadcasterUserEvent): total: int - tier: str + tier: Literal["1000", "2000", "3000"] cumulative_months: int streak_months: int | None duration_months: int