Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/twitchio/models.py
7774 views
1
"""
2
The MIT License (MIT)
3
4
Copyright (c) 2017-2021 TwitchIO
5
6
Permission is hereby granted, free of charge, to any person obtaining a
7
copy of this software and associated documentation files (the "Software"),
8
to deal in the Software without restriction, including without limitation
9
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
and/or sell copies of the Software, and to permit persons to whom the
11
Software is furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
DEALINGS IN THE SOFTWARE.
23
"""
24
25
import datetime
26
from typing import Optional, Union, TYPE_CHECKING, List, Dict
27
28
from . import enums
29
from .utils import parse_timestamp
30
from .user import BitLeaderboardUser, PartialUser, User
31
32
if TYPE_CHECKING:
33
from .http import TwitchHTTP
34
35
36
__all__ = (
37
"BitsLeaderboard",
38
"Clip",
39
"CheerEmote",
40
"CheerEmoteTier",
41
"HypeTrainContribution",
42
"HypeTrainEvent",
43
"BanEvent",
44
"FollowEvent",
45
"SubscriptionEvent",
46
"Marker",
47
"VideoMarkers",
48
"Game",
49
"ModEvent",
50
"AutomodCheckMessage",
51
"AutomodCheckResponse",
52
"Extension",
53
"MaybeActiveExtension",
54
"ActiveExtension",
55
"ExtensionBuilder",
56
"Video",
57
"Tag",
58
"WebhookSubscription",
59
"Prediction",
60
"Predictor",
61
"PredictionOutcome",
62
"Schedule",
63
"ScheduleSegment",
64
"ScheduleCategory",
65
"ScheduleVacation",
66
"Stream",
67
"Team",
68
"ChannelTeams",
69
"ChannelInfo",
70
)
71
72
73
class BitsLeaderboard:
74
"""
75
Represents a Bits leaderboard from the twitch API.
76
77
Attributes
78
------------
79
started_at: datetime.datetime
80
The time the leaderboard started.
81
ended_at: datetime.datetime
82
The time the leaderboard ended.
83
leaders: List[:class:`BitLeaderboardUser`]
84
The current leaders of the Leaderboard.
85
"""
86
87
__slots__ = "_http", "leaders", "started_at", "ended_at"
88
89
def __init__(self, http: "TwitchHTTP", data: dict):
90
self._http = http
91
self.started_at = datetime.datetime.fromisoformat(data["date_range"]["started_at"])
92
self.ended_at = datetime.datetime.fromisoformat(data["date_range"]["ended_at"])
93
self.leaders = [BitLeaderboardUser(http, x) for x in data["data"]]
94
95
def __repr__(self):
96
return f"<BitsLeaderboard started_at={self.started_at} ended_at={self.ended_at}>"
97
98
99
class CheerEmoteTier:
100
101
__slots__ = "min_bits", "id", "colour", "images", "can_cheer", "show_in_bits_card"
102
103
def __init__(self, data: dict):
104
self.min_bits: int = data["min_bits"]
105
self.id: str = data["id"]
106
self.colour: str = data["colour"]
107
self.images = data["images"]
108
self.can_cheer: bool = data["can_cheer"]
109
self.show_in_bits_card: bool = data["show_in_bits_card"]
110
111
def __repr__(self):
112
return f"<CheerEmoteTier id={self.id} min_bits={self.min_bits}>"
113
114
115
class CheerEmote:
116
117
__slots__ = "_http", "prefix", "tiers", "type", "order", "last_updated", "charitable"
118
119
def __init__(self, http: "TwitchHTTP", data: dict):
120
self._http = http
121
self.prefix: str = data["prefix"]
122
self.tiers = [CheerEmoteTier(x) for x in data["tiers"]]
123
self.type: str = data["type"]
124
self.order: str = data["order"]
125
self.last_updated = parse_timestamp(data["last_updated"])
126
self.charitable: bool = data["is_charitable"]
127
128
def __repr__(self):
129
return f"<CheerEmote prefix={self.prefix} type={self.type} order={self.order}>"
130
131
132
class Clip:
133
134
__slots__ = (
135
"id",
136
"url",
137
"embed_url",
138
"broadcaster",
139
"creator",
140
"video_id",
141
"game_id",
142
"language",
143
"title",
144
"views",
145
"created_at",
146
"thumbnail_url",
147
)
148
149
def __init__(self, http: "TwitchHTTP", data: dict):
150
self.id = data["id"]
151
self.url = data["url"]
152
self.embed_url = data["embed_url"]
153
self.broadcaster = PartialUser(http, data["broadcaster_id"], data["broadcaster_name"])
154
self.creator = PartialUser(http, data["creator_id"], data["creator_name"])
155
self.video_id = data["video_id"]
156
self.game_id = data["game_id"]
157
self.language = data["language"]
158
self.title = data["title"]
159
self.views = data["view_count"]
160
self.created_at = parse_timestamp(data["created_at"])
161
self.thumbnail_url = data["thumbnail_url"]
162
163
def __repr__(self):
164
return f"<Clip id={self.id} broadcaster={self.broadcaster} creator={self.creator}>"
165
166
167
class HypeTrainContribution:
168
169
__slots__ = "total", "type", "user"
170
171
def __init__(self, http: "TwitchHTTP", data: dict):
172
self.total: int = data["total"]
173
self.type: str = data["type"]
174
self.user = PartialUser(http, id=data["user"], name=None) # we'll see how this goes
175
176
def __repr__(self):
177
return f"<HypeTrainContribution total={self.total} type={self.type} user={self.user}>"
178
179
180
class HypeTrainEvent:
181
182
__slots__ = (
183
"id",
184
"type",
185
"timestamp",
186
"version",
187
"broadcaster",
188
"expiry",
189
"event_id",
190
"goal",
191
"level",
192
"started_at",
193
"top_contributions",
194
"contributions_total",
195
"cooldown_end_time",
196
"last_contribution",
197
)
198
199
def __init__(self, http: "TwitchHTTP", data: dict):
200
self.id: str = data["id"]
201
self.event_id: str = data["event_data"]["id"]
202
self.type: str = data["event_type"]
203
self.version: str = data["version"]
204
self.broadcaster = PartialUser(http, id=data["event_data"]["broadcaster_id"], name=None)
205
self.timestamp = parse_timestamp(data["event_timestamp"])
206
self.cooldown_end_time = parse_timestamp(data["event_data"]["cooldown_end_time"])
207
self.expiry = parse_timestamp(data["expires_at"])
208
self.started_at = parse_timestamp(data["event_data"]["started_at"])
209
self.last_contribution = HypeTrainContribution(http, data["event_data"]["last_contribution"])
210
self.level: int = data["event_data"]["level"]
211
self.top_contributions = [HypeTrainContribution(http, x) for x in data["event_data"]["top_contributions"]]
212
self.contributions_total: int = data["event_data"]["total"]
213
214
def __repr__(self):
215
return f"<HypeTrainEvent id={self.id} type={self.type} level={self.level} broadcaster={self.broadcaster}>"
216
217
218
class BanEvent:
219
220
__slots__ = "id", "type", "timestamp", "version", "broadcaster", "user", "expires_at"
221
222
def __init__(self, http: "TwitchHTTP", data: dict, broadcaster: Optional[Union[PartialUser, User]]):
223
self.id: str = data["id"]
224
self.type: str = data["event_type"]
225
self.timestamp = parse_timestamp(data["event_timestamp"])
226
self.version: float = float(data["version"])
227
self.broadcaster = broadcaster or PartialUser(
228
http, data["event_data"]["broadcaster_id"], data["event_data"]["broadcaster_name"]
229
)
230
self.user = PartialUser(http, data["event_data"]["user_id"], data["event_data"]["user_name"])
231
self.expires_at = (
232
parse_timestamp(data["event_data"]["expires_at"]) if data["event_data"]["expires_at"] else None
233
)
234
235
def __repr__(self):
236
return f"<BanEvent id={self.id} type={self.type} broadcaster={self.broadcaster} user={self.user}>"
237
238
239
class FollowEvent:
240
241
__slots__ = "from_user", "to_user", "followed_at"
242
243
def __init__(
244
self,
245
http: "TwitchHTTP",
246
data: dict,
247
from_: Union[User, PartialUser] = None,
248
to: Union[User, PartialUser] = None,
249
):
250
self.from_user = from_ or PartialUser(http, data["from_id"], data["from_name"])
251
self.to_user = to or PartialUser(http, data["to_id"], data["to_name"])
252
self.followed_at = parse_timestamp(data["followed_at"])
253
254
def __repr__(self):
255
return f"<FollowEvent from_user={self.from_user} to_user={self.to_user} followed_at={self.followed_at}>"
256
257
258
class SubscriptionEvent:
259
260
__slots__ = "broadcaster", "gift", "tier", "plan_name", "user"
261
262
def __init__(
263
self,
264
http: "TwitchHTTP",
265
data: dict,
266
broadcaster: Union[User, PartialUser] = None,
267
user: Union[User, PartialUser] = None,
268
):
269
self.broadcaster = broadcaster or PartialUser(http, data["broadcaster_id"], data["broadcaster_name"])
270
self.user = user or PartialUser(http, data["user_id"], data["user_name"])
271
self.tier = int(data["tier"]) / 1000
272
self.plan_name: str = data["plan_name"]
273
self.gift: bool = data["is_gift"]
274
275
def __repr__(self):
276
return (
277
f"<SubscriptionEvent broadcaster={self.broadcaster} user={self.user} tier={self.tier} "
278
f"plan_name={self.plan_name} gift={self.gift}>"
279
)
280
281
282
class Marker:
283
284
__slots__ = "id", "created_at", "description", "position", "url"
285
286
def __init__(self, data: dict):
287
self.id: int = data["id"]
288
self.created_at = parse_timestamp(data["created_at"])
289
self.description: str = data["description"]
290
self.position: int = data["position_seconds"]
291
self.url: Optional[str] = data.get("URL")
292
293
def __repr__(self):
294
return f"<Marker id={self.id} created_at={self.created_at} position={self.position} url={self.url}>"
295
296
297
class VideoMarkers:
298
299
__slots__ = "id", "markers"
300
301
def __init__(self, data: dict):
302
self.id: str = data["video_id"]
303
self.markers = [Marker(d) for d in data]
304
305
def __repr__(self):
306
return f"<VideoMarkers id={self.id}>"
307
308
309
class Game:
310
311
__slots__ = "id", "name", "box_art_url"
312
313
def __init__(self, data: dict):
314
self.id: int = int(data["id"])
315
self.name: str = data["name"]
316
self.box_art_url: str = data["box_art_url"]
317
318
def __repr__(self):
319
return f"<Game id={self.id} name={self.name}>"
320
321
def art_url(self, width: int, height: int) -> str:
322
"""
323
Adds width and height into the box art url
324
325
Parameters
326
-----------
327
width: :class:`int`
328
The width of the image
329
height: :class:`int`
330
The height of the image
331
332
Returns
333
--------
334
:class:`str`
335
"""
336
return self.box_art_url.format(width=width, height=height)
337
338
339
class ModEvent:
340
341
__slots__ = "id", "type", "timestamp", "version", "broadcaster", "user"
342
343
def __init__(self, http: "TwitchHTTP", data: dict, broadcaster: Union[PartialUser, User]):
344
self.id: int = data["id"]
345
self.type = enums.ModEventEnum(value=data["event_type"])
346
self.timestamp = parse_timestamp(data["event_timestamp"])
347
self.version: str = data["version"]
348
self.broadcaster = broadcaster
349
self.user = PartialUser(http, data["event_data"]["user_id"], data["event_data"]["user_name"])
350
351
def __repr__(self):
352
return f"<ModEvent id={self.id} type={self.type} broadcaster={self.broadcaster} user={self.user}>"
353
354
355
class AutomodCheckMessage:
356
357
__slots__ = "id", "text", "user_id"
358
359
def __init__(self, id: str, text: str, user: Union[PartialUser, int]):
360
self.id = id
361
self.text = text
362
self.user_id = user.id if isinstance(user, PartialUser) else user
363
364
def _to_dict(self):
365
return {"msg_id": self.id, "msg_text": self.text, "user_id": str(self.user_id)}
366
367
def __repr__(self):
368
return f"<AutomodCheckMessage id={self.id} user_id={self.user_id}>"
369
370
371
class AutomodCheckResponse:
372
373
__slots__ = "id", "permitted"
374
375
def __init__(self, data: dict):
376
self.id: str = data["msg_id"]
377
self.permitted: bool = data["is_permitted"]
378
379
def __repr__(self):
380
return f"<AutomodCheckResponse id={self.id} permitted={self.permitted}>"
381
382
383
class Extension:
384
385
__slots__ = "id", "active", "version", "_x", "_y"
386
387
def __init__(self, data):
388
self.id: str = data["id"]
389
self.version: str = data["version"]
390
self.active: bool = data["active"]
391
self._x = None
392
self._y = None
393
394
def __repr__(self):
395
return f"<Extension id={self.id} version={self.version} active={self.active}>"
396
397
@classmethod
398
def new(cls, active: bool, version: str, id: str, x: int = None, y: int = None) -> "Extension":
399
self = cls.__new__(cls)
400
self.active = active
401
self.version = version
402
self.id = id
403
self._x = x
404
self._y = y
405
return self
406
407
def _to_dict(self):
408
v = {"active": self.active, "id": self.id, "version": self.version}
409
if self._x is not None:
410
v["x"] = self._x
411
if self._y is not None:
412
v["y"] = self._y
413
return v
414
415
416
class MaybeActiveExtension(Extension):
417
418
__slots__ = "id", "version", "name", "can_activate", "types"
419
420
def __init__(self, data):
421
self.id: str = data["id"]
422
self.version: str = data["version"]
423
self.name: str = data["name"]
424
self.can_activate: bool = data["can_activate"]
425
self.types: List[str] = data["type"]
426
427
def __repr__(self):
428
return f"<MaybeActiveExtension id={self.id} version={self.version} name={self.name}>"
429
430
431
class ActiveExtension(Extension):
432
433
__slots__ = "id", "active", "name", "version", "x", "y"
434
435
def __init__(self, data):
436
self.active: bool = data["active"]
437
self.id: Optional[str] = data.get("id", None)
438
self.version: Optional[str] = data.get("version", None)
439
self.name: Optional[str] = data.get("name", None)
440
self.x: Optional[int] = data.get("x", None) # x and y only show for component extensions.
441
self.y: Optional[int] = data.get("y", None)
442
443
def __repr__(self):
444
return f"<ActiveExtension id={self.id} version={self.version} name={self.name}>"
445
446
447
class ExtensionBuilder:
448
449
__slots__ = "panels", "overlays", "components"
450
451
def __init__(
452
self, panels: List[Extension] = None, overlays: List[Extension] = None, components: List[Extension] = None
453
):
454
self.panels = panels or []
455
self.overlays = overlays or []
456
self.components = components or []
457
458
def _to_dict(self):
459
return {
460
"panel": {str(x): y._to_dict() for x, y in enumerate(self.panels)},
461
"overlay": {str(x): y._to_dict() for x, y in enumerate(self.overlays)},
462
"component": {str(x): y._to_dict() for x, y in enumerate(self.components)},
463
}
464
465
466
class Video:
467
468
__slots__ = (
469
"_http",
470
"id",
471
"user",
472
"title",
473
"description",
474
"created_at",
475
"published_at",
476
"url",
477
"thumbnail_url",
478
"viewable",
479
"view_count",
480
"language",
481
"type",
482
"duration",
483
)
484
485
def __init__(self, http: "TwitchHTTP", data: dict, user: Union[PartialUser, User] = None):
486
self._http = http
487
self.id: id = int(data["id"])
488
self.user = user or PartialUser(http, data["user_id"], data["user_name"])
489
self.title: str = data["title"]
490
self.description: str = data["description"]
491
self.created_at = parse_timestamp(data["created_at"])
492
self.published_at = parse_timestamp(data["published_at"])
493
self.url: str = data["url"]
494
self.thumbnail_url: str = data["thumbnail_url"]
495
self.viewable: str = data["viewable"]
496
self.view_count: int = data["view_count"]
497
self.language: str = data["language"]
498
self.type: str = data["type"]
499
self.duration: str = data["duration"]
500
501
def __repr__(self):
502
return f"<Video id={self.id} title={self.title} url={self.url}>"
503
504
async def delete(self, token: str):
505
"""|coro|
506
507
Deletes the video. For bulk deletion see :func:`Client.delete_videos`
508
509
Parameters
510
-----------
511
token: :class:`str`
512
The users oauth token with the channel:manage:videos
513
"""
514
await self._http.delete_videos(token, ids=[str(self.id)])
515
516
517
class Tag:
518
519
__slots__ = "id", "auto", "localization_names", "localization_descriptions"
520
521
def __init__(self, data: dict):
522
self.id: str = data["tag_id"]
523
self.auto: bool = data["is_auto"]
524
self.localization_names: Dict[str, str] = data["localization_names"]
525
self.localization_descriptions: Dict[str, str] = data["localization_descriptions"]
526
527
def __repr__(self):
528
return f"<Tag id={self.id}>"
529
530
531
class WebhookSubscription:
532
533
__slots__ = "callback", "expires_at", "topic"
534
535
def __init__(self, data: dict):
536
self.callback: str = data["callback"]
537
self.expires_at = parse_timestamp(data["expired_at"])
538
self.topic: str = data["topic"]
539
540
def __repr__(self):
541
return f"<WebhookSubscription callback={self.callback} topic={self.topic} expires_at={self.expires_at}>"
542
543
544
class Stream:
545
546
__slots__ = (
547
"id",
548
"user",
549
"game_id",
550
"game_name",
551
"type",
552
"title",
553
"viewer_count",
554
"started_at",
555
"language",
556
"thumbnail_url",
557
"tag_ids",
558
"is_mature",
559
)
560
561
def __init__(self, http: "TwitchHTTP", data: dict):
562
self.id: int = data["id"]
563
self.user = PartialUser(http, data["user_id"], data["user_name"])
564
self.game_id: int = data["game_id"]
565
self.game_name: str = data["game_name"]
566
self.type: str = data["type"]
567
self.title: str = data["title"]
568
self.viewer_count: int = data["viewer_count"]
569
self.started_at = parse_timestamp(data["started_at"])
570
self.language: str = data["language"]
571
self.thumbnail_url: str = data["thumbnail_url"]
572
self.tag_ids: List[str] = data["tag_ids"]
573
self.is_mature: bool = data["is_mature"]
574
575
def __repr__(self):
576
return f"<Stream id={self.id} user={self.user} title={self.title} started_at={self.started_at}>"
577
578
579
class ChannelInfo:
580
581
__slots__ = ("user", "game_id", "game_name", "title", "language", "delay")
582
583
def __init__(self, http: "TwitchHTTP", data: dict):
584
self.user = PartialUser(http, data["broadcaster_id"], data["broadcaster_name"])
585
self.game_id: int = data["game_id"]
586
self.game_name: str = data["game_name"]
587
self.title: str = data["title"]
588
self.language: str = data["broadcaster_language"]
589
self.delay: int = data["delay"]
590
591
def __repr__(self):
592
return f"<ChannelInfo user={self.user} game_id={self.game_id} game_name={self.game_name} title={self.title} language={self.language} delay={self.delay}>"
593
594
595
class Prediction:
596
597
__slots__ = (
598
"user",
599
"prediction_id",
600
"title",
601
"winning_outcome_id",
602
"outcomes",
603
"prediction_window",
604
"prediction_status",
605
"created_at",
606
"ended_at",
607
"locked_at",
608
)
609
610
def __init__(self, http: "TwitchHTTP", data: dict):
611
self.user = PartialUser(http, data["broadcaster_id"], data["broadcaster_name"])
612
self.prediction_id: str = data["id"]
613
self.title: str = data["title"]
614
self.winning_outcome_id: str = data["winning_outcome_id"]
615
self.outcomes: List[PredictionOutcome] = [PredictionOutcome(http, x) for x in data["outcomes"]]
616
self.prediction_window: int = data["prediction_window"]
617
self.prediction_status: str = data["status"]
618
self.created_at = self._parse_time(data, "created_at")
619
self.ended_at = self._parse_time(data, "ended_at")
620
self.locked_at = self._parse_time(data, "locked_at")
621
622
def _parse_time(self, data, field) -> Optional["Datetime"]:
623
if field not in data or data[field] is None:
624
return None
625
626
time = data[field].split(".")[0]
627
return datetime.datetime.fromisoformat(time)
628
629
def __repr__(self):
630
return f"<Prediction user={self.user} prediction_id={self.prediction_id} winning_outcome_id={self.winning_outcome_id} title={self.title}>"
631
632
633
class Predictor:
634
635
__slots__ = ("outcome_id", "title", "channel_points", "color")
636
637
def __init__(self, http: "TwitchHTTP", data: dict):
638
self.channel_points_used: int = data["channel_points_used"]
639
self.channel_points_won: int = data["channel_points_won"]
640
self.user = PartialUser(http, data["user"]["id"], data["user"]["name"])
641
642
643
class PredictionOutcome:
644
645
__slots__ = ("outcome_id", "title", "channel_points", "color", "users", "top_predictors")
646
647
def __init__(self, http: "TwitchHTTP", data: dict):
648
self.outcome_id: str = data["id"]
649
self.title: str = data["title"]
650
self.channel_points: int = data["channel_points"]
651
self.color: str = data["color"]
652
self.users: int = data["users"]
653
if data["top_predictors"]:
654
self.top_predictors: List[Predictor] = [Predictor(http, x) for x in data["top_predictors"]]
655
else:
656
self.top_predictors: List[Predictor] = None
657
658
@property
659
def colour(self) -> str:
660
"""The colour of the prediction. Alias to color."""
661
return self.color
662
663
def __repr__(self):
664
return f"<PredictionOutcome outcome_id={self.outcome_id} title={self.title} channel_points={self.channel_points} color={self.color}>"
665
666
667
class Schedule:
668
669
__slots__ = ("segments", "user", "vacation")
670
671
def __init__(self, http: "TwitchHTTP", data: dict):
672
self.segments = [ScheduleSegment(d) for d in data["data"]["segments"]]
673
self.user = PartialUser(http, data["data"]["broadcaster_id"], data["data"]["broadcaster_login"])
674
self.vacation = ScheduleVacation(data["data"]["vacation"]) if data["data"]["vacation"] else None
675
676
def __repr__(self):
677
return f"<Schedule segments={self.segments} user={self.user} vacation={self.vacation}>"
678
679
680
class ScheduleSegment:
681
682
__slots__ = ("id", "start_time", "end_time", "title", "canceled_until", "category", "is_recurring")
683
684
def __init__(self, data: dict):
685
self.id: str = data["id"]
686
self.start_time = parse_timestamp(data["start_time"])
687
self.end_time = parse_timestamp(data["end_time"])
688
self.title: str = data["title"]
689
self.canceled_until = parse_timestamp(data["canceled_until"]) if data["canceled_until"] else None
690
self.category = ScheduleCategory(data["category"]) if data["category"] else None
691
self.is_recurring: bool = data["is_recurring"]
692
693
def __repr__(self):
694
return f"<Segment id={self.id} start_time={self.start_time} end_time={self.end_time} title={self.title} canceled_until={self.canceled_until} category={self.category} is_recurring={self.is_recurring}>"
695
696
697
class ScheduleCategory:
698
699
__slots__ = ("id", "name")
700
701
def __init__(self, data: dict):
702
self.id: str = data["id"]
703
self.name: str = data["name"]
704
705
def __repr__(self):
706
return f"<ScheduleCategory id={self.id} name={self.name}>"
707
708
709
class ScheduleVacation:
710
711
__slots__ = ("start_time", "end_time")
712
713
def __init__(self, data: dict):
714
self.start_time = parse_timestamp(data["start_time"])
715
self.end_time = parse_timestamp(data["end_time"])
716
717
def __repr__(self):
718
return f"<ScheduleVacation start_time={self.start_time} end_time={self.end_time}>"
719
720
721
class Team:
722
723
__slots__ = (
724
"users",
725
"background_image_url",
726
"banner",
727
"created_at",
728
"updated_at",
729
"info",
730
"thumbnail_url",
731
"team_name",
732
"team_display_name",
733
"id",
734
)
735
736
def __init__(self, http: "TwitchHTTP", data: dict):
737
738
self.users: List[PartialUser] = [PartialUser(http, x["user_id"], x["user_login"]) for x in data["users"]]
739
self.background_image_url = data["background_image_url"]
740
self.banner = data["banner"]
741
self.created_at = parse_timestamp(data["created_at"].split(" ")[0])
742
self.updated_at = parse_timestamp(data["updated_at"].split(" ")[0])
743
self.info = data["info"]
744
self.thumbnail_url = data["thumbnail_url"]
745
self.team_name = data["team_name"]
746
self.team_display_name = data["team_display_name"]
747
self.id = data["id"]
748
749
def __repr__(self):
750
return f"<Team users={self.users} team_name={self.team_name} team_display_name={self.team_display_name} id={self.id} created_at={self.created_at}>"
751
752
753
class ChannelTeams:
754
755
__slots__ = (
756
"broadcaster",
757
"background_image_url",
758
"banner",
759
"created_at",
760
"updated_at",
761
"info",
762
"thumbnail_url",
763
"team_name",
764
"team_display_name",
765
"id",
766
)
767
768
def __init__(self, http: "TwitchHTTP", data: dict):
769
770
self.broadcaster: PartialUser = PartialUser(http, data["broadcaster_id"], data["broadcaster_login"])
771
self.background_image_url = data["background_image_url"]
772
self.banner = data["banner"]
773
self.created_at = parse_timestamp(data["created_at"].split(" ")[0])
774
self.updated_at = parse_timestamp(data["updated_at"].split(" ")[0])
775
self.info = data["info"]
776
self.thumbnail_url = data["thumbnail_url"]
777
self.team_name = data["team_name"]
778
self.team_display_name = data["team_display_name"]
779
self.id = data["id"]
780
781
def __repr__(self):
782
return f"<ChannelTeams user={self.broadcaster} team_name={self.team_name} team_display_name={self.team_display_name} id={self.id} created_at={self.created_at}>"
783
784