Skip to content

Commit 8c1b2e3

Browse files
committed
2 parents 472c051 + 80b8914 commit 8c1b2e3

File tree

3 files changed

+90
-46
lines changed

3 files changed

+90
-46
lines changed

twitchio/eventsub/subscriptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@ class HypeTrainBeginSubscription(SubscriptionPayload):
26922692
"""
26932693

26942694
type: ClassVar[Literal["channel.hype_train.begin"]] = "channel.hype_train.begin"
2695-
version: ClassVar[Literal["1"]] = "1"
2695+
version: ClassVar[Literal["2"]] = "2"
26962696

26972697
@handle_user_ids()
26982698
def __init__(self, **condition: Unpack[Condition]) -> None:
@@ -2734,7 +2734,7 @@ class HypeTrainProgressSubscription(SubscriptionPayload):
27342734
"""
27352735

27362736
type: ClassVar[Literal["channel.hype_train.progress"]] = "channel.hype_train.progress"
2737-
version: ClassVar[Literal["1"]] = "1"
2737+
version: ClassVar[Literal["2"]] = "2"
27382738

27392739
@handle_user_ids()
27402740
def __init__(self, **condition: Unpack[Condition]) -> None:
@@ -2773,7 +2773,7 @@ class HypeTrainEndSubscription(SubscriptionPayload):
27732773
"""
27742774

27752775
type: ClassVar[Literal["channel.hype_train.end"]] = "channel.hype_train.end"
2776-
version: ClassVar[Literal["1"]] = "1"
2776+
version: ClassVar[Literal["2"]] = "2"
27772777

27782778
@handle_user_ids()
27792779
def __init__(self, **condition: Unpack[Condition]) -> None:

twitchio/models/eventsub_.py

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4818,11 +4818,19 @@ def __repr__(self) -> str:
48184818

48194819

48204820
class BaseHypeTrain(BaseEvent):
4821-
__slots__ = ("broadcaster", "golden_kappa", "id", "level", "started_at", "top_contributions", "total")
4821+
__slots__ = (
4822+
"broadcaster",
4823+
"id",
4824+
"level",
4825+
"shared_train",
4826+
"shared_train_participants",
4827+
"started_at",
4828+
"top_contributions",
4829+
"total",
4830+
"type",
4831+
)
48224832

4823-
def __init__(
4824-
self, payload: HypeTrainBeginEvent | HypeTrainProgressEvent | HypeTrainEndEvent, *, http: HTTPClient
4825-
) -> None:
4833+
def __init__(self, payload: BaseHypeTrainEvent, *, http: HTTPClient) -> None:
48264834
self.broadcaster: PartialUser = PartialUser(
48274835
payload["broadcaster_user_id"], payload["broadcaster_user_login"], payload["broadcaster_user_name"], http=http
48284836
)
@@ -4833,7 +4841,12 @@ def __init__(
48334841
HypeTrainContribution(c, http=http) for c in payload["top_contributions"]
48344842
]
48354843
self.started_at: datetime.datetime = parse_timestamp(payload["started_at"])
4836-
self.golden_kappa: bool = bool(payload["is_golden_kappa_train"])
4844+
self.shared_train_participants: list[PartialUser] = [
4845+
PartialUser(u["broadcaster_user_id"], u["broadcaster_user_login"], u["broadcaster_user_name"], http=http)
4846+
for u in payload["shared_train_participants"]
4847+
]
4848+
self.shared_train: bool = bool(payload["is_shared_train"])
4849+
self.type: Literal["treasure", "golden_kappa", "regular"] = payload["type"]
48374850

48384851
def __repr__(self) -> str:
48394852
return f"<BaseHypeTrain id={self.id} broadcaster={self.broadcaster} started_at={self.started_at}>"
@@ -4859,34 +4872,49 @@ class HypeTrainBegin(BaseHypeTrain):
48594872
The number of points required to reach the next level.
48604873
top_contributions: list[HypeTrainContribution]
48614874
The contributors with the most points contributed.
4862-
last_contribution: HypeTrainContribution
4863-
The most recent contribution.
4875+
all_time_high_level: int
4876+
The all-time high level this type of Hype Train has reached for this broadcaster.
4877+
all_time_high_total: int
4878+
The all-time high total this type of Hype Train has reached for this broadcaster.
4879+
shared_train: bool
4880+
Indicates if the Hype Train is shared.
4881+
When True, `shared_train_participants` will contain the list of broadcasters the train is shared with.
4882+
shared_train_participants: list[PartialUser]
4883+
List of broadcasters in the shared Hype Train.
4884+
type: typing.Literal["treasure", "golden_kappa", "regular"]
4885+
The type of the Hype Train. Possible values are:
4886+
4887+
- treasure
4888+
- golden_kappa
4889+
- regular
4890+
48644891
started_at: datetime.datetime
48654892
The datetime of when the hype train started.
48664893
expires_at: datetime.datetime
48674894
The datetime when the hype train expires. The expiration is extended when the hype train reaches a new level.
4868-
golden_kappa: bool
4869-
Indicates if the hype train is a Golden Kappa Train.
4895+
48704896
"""
48714897

48724898
subscription_type = "channel.hype_train.begin"
48734899

48744900
__slots__ = (
4901+
"all_time_high_level",
4902+
"all_time_high_total",
48754903
"expires_at",
48764904
"goal",
4877-
"last_contribution",
48784905
"progress",
48794906
)
48804907

48814908
def __init__(self, payload: HypeTrainBeginEvent, *, http: HTTPClient) -> None:
48824909
super().__init__(payload, http=http)
48834910
self.progress: int = int(payload["progress"])
48844911
self.goal: int = int(payload["goal"])
4885-
self.last_contribution: HypeTrainContribution = HypeTrainContribution(payload["last_contribution"], http=http)
48864912
self.expires_at: datetime.datetime = parse_timestamp(payload["expires_at"])
4913+
self.all_time_high_level: int = int(payload["all_time_high_level"])
4914+
self.all_time_high_total: int = int(payload["all_time_high_total"])
48874915

48884916
def __repr__(self) -> str:
4889-
return f"<HypeTrainBegin id={self.id} broadcaster={self.broadcaster} goal={self.goal} started_at={self.started_at}>"
4917+
return f"<HypeTrainBegin id={self.id} broadcaster={self.broadcaster} goal={self.goal} started_at={self.started_at} type={self.type}>"
48904918

48914919

48924920
class HypeTrainProgress(BaseHypeTrain):
@@ -4909,34 +4937,40 @@ class HypeTrainProgress(BaseHypeTrain):
49094937
The number of points required to reach the next level.
49104938
top_contributions: list[HypeTrainContribution]
49114939
The contributors with the most points contributed.
4912-
last_contribution: HypeTrainContribution
4913-
The most recent contribution.
49144940
started_at: datetime.datetime
49154941
The datetime of when the hype train started.
49164942
expires_at: datetime.datetime
49174943
The datetime when the hype train expires. The expiration is extended when the hype train reaches a new level.
4918-
golden_kappa: bool
4919-
Indicates if the hype train is a Golden Kappa Train.
4944+
shared_train: bool
4945+
Indicates if the Hype Train is shared.
4946+
When True, `shared_train_participants` will contain the list of broadcasters the train is shared with.
4947+
shared_train_participants: list[PartialUser]
4948+
List of broadcasters in the shared Hype Train.
4949+
type: typing.Literal["treasure", "golden_kappa", "regular"]
4950+
The type of the Hype Train. Possible values are:
4951+
4952+
- treasure
4953+
- golden_kappa
4954+
- regular
4955+
49204956
"""
49214957

49224958
subscription_type = "channel.hype_train.progress"
49234959

49244960
__slots__ = (
49254961
"expires_at",
49264962
"goal",
4927-
"last_contribution",
49284963
"progress",
49294964
)
49304965

49314966
def __init__(self, payload: HypeTrainProgressEvent, *, http: HTTPClient) -> None:
49324967
super().__init__(payload, http=http)
49334968
self.progress: int = int(payload["progress"])
49344969
self.goal: int = int(payload["goal"])
4935-
self.last_contribution: HypeTrainContribution = HypeTrainContribution(payload["last_contribution"], http=http)
49364970
self.expires_at: datetime.datetime = parse_timestamp(payload["expires_at"])
49374971

49384972
def __repr__(self) -> str:
4939-
return f"<HypeTrainProgress id={self.id} broadcaster={self.broadcaster} goal={self.goal} progress={self.progress}>"
4973+
return f"<HypeTrainProgress id={self.id} broadcaster={self.broadcaster} goal={self.goal} progress={self.progress} type={self.type}>"
49404974

49414975

49424976
class HypeTrainEnd(BaseHypeTrain):
@@ -4961,8 +4995,18 @@ class HypeTrainEnd(BaseHypeTrain):
49614995
The datetime of when the hype train ended.
49624996
cooldown_until: datetime.datetime
49634997
The datetime when the hype train cooldown ends so that the next hype train can start.
4964-
golden_kappa: bool
4965-
Indicates if the hype train is a Golden Kappa Train.
4998+
shared_train: bool
4999+
Indicates if the Hype Train is shared.
5000+
When True, `shared_train_participants` will contain the list of broadcasters the train is shared with.
5001+
shared_train_participants: list[PartialUser]
5002+
List of broadcasters in the shared Hype Train.
5003+
type: typing.Literal["treasure", "golden_kappa", "regular"]
5004+
The type of the Hype Train. Possible values are:
5005+
5006+
- treasure
5007+
- golden_kappa
5008+
- regular
5009+
49665010
"""
49675011

49685012
subscription_type = "channel.hype_train.end"
@@ -4978,7 +5022,7 @@ def __init__(self, payload: HypeTrainEndEvent, *, http: HTTPClient) -> None:
49785022
self.cooldown_until: datetime.datetime = parse_timestamp(payload["cooldown_ends_at"])
49795023

49805024
def __repr__(self) -> str:
4981-
return f"<HypeTrainEnd id={self.id} broadcaster={self.broadcaster} total={self.total} ended_at={self.ended_at}>"
5025+
return f"<HypeTrainEnd id={self.id} broadcaster={self.broadcaster} total={self.total} ended_at={self.ended_at} type={self.type}>"
49825026

49835027

49845028
class ShieldModeBegin(BaseEvent):

twitchio/types_/eventsub.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"AutomodTermsUpdateEvent",
4242
"BaseChannelPointsRewardData",
4343
"BaseEmoteData",
44+
"BaseHypeTrainEvent",
4445
"ChannelAdBreakBeginEvent",
4546
"ChannelBanEvent",
4647
"ChannelBitsUseEvent",
@@ -1228,41 +1229,40 @@ class HypeTrainContributionData(TypedDict):
12281229
total: int
12291230

12301231

1231-
class HypeTrainBeginEvent(BaseBroadcasterEvent):
1232+
class HypeTrainSharedParticipants(TypedDict):
1233+
broadcaster_user_id: str
1234+
broadcaster_user_login: str
1235+
broadcaster_user_name: str
1236+
1237+
1238+
class BaseHypeTrainEvent(BaseBroadcasterEvent):
12321239
id: str
12331240
total: int
1234-
progress: int
1235-
goal: int
1236-
top_contributions: list[HypeTrainContributionData]
1237-
last_contribution: HypeTrainContributionData
12381241
level: int
12391242
started_at: str
1243+
top_contributions: list[HypeTrainContributionData]
1244+
shared_train_participants: list[HypeTrainSharedParticipants]
1245+
type: Literal["treasure", "golden_kappa", "regular"]
1246+
is_shared_train: bool
1247+
1248+
1249+
class HypeTrainBeginEvent(BaseHypeTrainEvent):
1250+
progress: int
1251+
goal: int
1252+
all_time_high_level: int
1253+
all_time_high_total: int
12401254
expires_at: str
1241-
is_golden_kappa_train: bool
12421255

12431256

1244-
class HypeTrainProgressEvent(BaseBroadcasterEvent):
1245-
id: str
1246-
total: int
1257+
class HypeTrainProgressEvent(BaseHypeTrainEvent):
12471258
progress: int
12481259
goal: int
1249-
top_contributions: list[HypeTrainContributionData]
1250-
last_contribution: HypeTrainContributionData
1251-
level: int
1252-
started_at: str
12531260
expires_at: str
1254-
is_golden_kappa_train: bool
12551261

12561262

1257-
class HypeTrainEndEvent(BaseBroadcasterEvent):
1258-
id: str
1259-
level: int
1260-
total: int
1261-
top_contributions: list[HypeTrainContributionData]
1262-
started_at: str
1263+
class HypeTrainEndEvent(BaseHypeTrainEvent):
12631264
ended_at: str
12641265
cooldown_ends_at: str
1265-
is_golden_kappa_train: bool
12661266

12671267

12681268
class ShieldModeBeginEvent(BroadcasterModeratorEvent):

0 commit comments

Comments
 (0)