Skip to content

Commit 36a1d35

Browse files
committed
Add docs and additional attrs
1 parent e6d6cf9 commit 36a1d35

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

twitchio/models/eventsub_.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,31 +3167,140 @@ def __repr__(self) -> str:
31673167

31683168

31693169
class ChannelPredictionBegin(BaseChannelPrediction):
3170+
"""
3171+
Represents a channel points prediction begin event.
3172+
3173+
Attributes
3174+
----------
3175+
id: str
3176+
ID of the prediction.
3177+
broadcaster: PartialUser
3178+
The broadcaster whose channel started a prediction.
3179+
title: str
3180+
Title for the channel points Prediction.
3181+
outcomes: list[PredictionOutcome]
3182+
A list of outcomes for the predictions. Only `id`, `title` and `colour` will be populated.
3183+
started_at: datetime.datetime
3184+
The time the prediction started.
3185+
locks_at: datetime.datetime
3186+
The time the prediction will automatically lock.
3187+
"""
3188+
31703189
subscription_type = "channel.prediction.begin"
31713190

3191+
__slots__ = ("locks_at",)
3192+
31723193
def __init__(self, data: ChannelPredictionBeginEvent, *, http: HTTPClient) -> None:
31733194
super().__init__(data, http=http)
3195+
self.locks_at: datetime.datetime = parse_timestamp(data["locks_at"])
3196+
3197+
def __repr__(self) -> str:
3198+
return (
3199+
f"<ChannelPredictionBegin id={self.id} title={self.title} started_at={self.started_at} locks_at={self.locks_at}>"
3200+
)
31743201

31753202

31763203
class ChannelPredictionProgress(BaseChannelPrediction):
3204+
"""
3205+
Represents a channel points prediction progress event.
3206+
3207+
Attributes
3208+
----------
3209+
id: str
3210+
ID of the prediction.
3211+
broadcaster: PartialUser
3212+
The broadcaster whose channel started a prediction.
3213+
title: str
3214+
Title for the channel points Prediction.
3215+
outcomes: list[PredictionOutcome]
3216+
A list of outcomes for the predictions.
3217+
started_at: datetime.datetime
3218+
The time the prediction started.
3219+
locks_at: datetime.datetime
3220+
The time the prediction will automatically lock.
3221+
"""
3222+
31773223
subscription_type = "channel.prediction.progress"
31783224

3225+
__slots__ = ("locks_at",)
3226+
31793227
def __init__(self, data: ChannelPredictionProgressEvent, *, http: HTTPClient) -> None:
31803228
super().__init__(data, http=http)
3229+
self.locks_at: datetime.datetime = parse_timestamp(data["locks_at"])
3230+
3231+
def __repr__(self) -> str:
3232+
return f"<ChannelPredictionProgress id={self.id} title={self.title} started_at={self.started_at} locks_at={self.locks_at}>"
31813233

31823234

31833235
class ChannelPredictionLock(BaseChannelPrediction):
3236+
"""
3237+
Represents a channel points prediction progress event.
3238+
3239+
Attributes
3240+
----------
3241+
id: str
3242+
ID of the prediction.
3243+
broadcaster: PartialUser
3244+
The broadcaster whose channel started a prediction.
3245+
title: str
3246+
Title for the channel points Prediction.
3247+
outcomes: list[PredictionOutcome]
3248+
A list of outcomes for the predictions.
3249+
started_at: datetime.datetime
3250+
The time the prediction started.
3251+
locked_at: datetime.datetime
3252+
The time the prediction was locked.
3253+
"""
3254+
31843255
subscription_type = "channel.prediction.lock"
31853256

3257+
__slots__ = ("locked_at",)
3258+
31863259
def __init__(self, data: ChannelPredictionLockEvent, *, http: HTTPClient) -> None:
31873260
super().__init__(data, http=http)
3261+
self.locked_at: datetime.datetime = parse_timestamp(data["locked_at"])
3262+
3263+
def __repr__(self) -> str:
3264+
return f"<ChannelPredictionLock id={self.id} title={self.title} started_at={self.started_at} locked_at={self.locked_at}>"
31883265

31893266

31903267
class ChannelPredictionEnd(BaseChannelPrediction):
3268+
"""
3269+
Represents a channel points prediction progress event.
3270+
3271+
Attributes
3272+
----------
3273+
id: str
3274+
ID of the prediction.
3275+
broadcaster: PartialUser
3276+
The broadcaster whose channel started a prediction.
3277+
title: str
3278+
Title for the channel points Prediction.
3279+
outcomes: list[PredictionOutcome]
3280+
A list of outcomes for the predictions.
3281+
winning_outcome: PredictionOutcome | None
3282+
The winning outcome. This can be None if the prediction is deleted.
3283+
started_at: datetime.datetime
3284+
The time the prediction started.
3285+
ended_at: datetime.datetime
3286+
The time the prediction ended.
3287+
status: Literal["resolved", "canceled"]
3288+
The status of the Channel Points Prediction. Valid values are ``resolved`` and ``canceled``.
3289+
"""
3290+
31913291
subscription_type = "channel.prediction.end"
31923292

3293+
__slots__ = ("winning_outcome_id", "ended_at", "status")
3294+
31933295
def __init__(self, data: ChannelPredictionEndEvent, *, http: HTTPClient) -> None:
31943296
super().__init__(data, http=http)
3297+
self.ended_at: datetime.datetime = parse_timestamp(data["ended_at"])
3298+
self.status: Literal["resolved", "canceled"] = data["status"]
3299+
winning_outcome_id = data.get("winning_outcome_id")
3300+
self.winning_outcome = next((outcome for outcome in self.outcomes if outcome.id == winning_outcome_id), None)
3301+
3302+
def __repr__(self) -> str:
3303+
return f"<ChannelPredictionEnd id={self.id} title={self.title} started_at={self.started_at} ended_at={self.ended_at} status={self.status} winning_outcome={self.winning_outcome}>"
31953304

31963305

31973306
class SuspiciousUserUpdate(BaseEvent):

twitchio/types_/eventsub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ class ChannelPredictionLockEvent(BaseChannelPredictionData):
10251025

10261026

10271027
class ChannelPredictionEndEvent(BaseChannelPredictionData):
1028+
winning_outcome_id: str
10281029
status: Literal["resolved", "canceled"]
10291030
ended_at: str
10301031

0 commit comments

Comments
 (0)