Skip to content

Commit

Permalink
Update tiers to be Literal instead of string.
Browse files Browse the repository at this point in the history
  • Loading branch information
chillymosh committed Dec 31, 2024
1 parent 5e74e22 commit 2a17329
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions twitchio/models/eventsub_.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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.
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions twitchio/types_/eventsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ class ChannelSubscribeEvent(BroadcasterUserEvent):


class ChannelSubscriptionEndEvent(BroadcasterUserEvent):
tier: str
tier: Literal["1000", "2000", "3000"]
is_gift: bool


Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 2a17329

Please sign in to comment.