|
37 | 37 | from .http import TwitchHTTP |
38 | 38 | from .channel import Channel |
39 | 39 | from .models import ( |
| 40 | + AdSchedule, |
40 | 41 | BitsLeaderboard, |
41 | 42 | Clip, |
42 | 43 | ExtensionBuilder, |
@@ -334,6 +335,48 @@ async def create_clip(self, token: str, has_delay=False) -> dict: |
334 | 335 | data = await self._http.post_create_clip(token, self.id, has_delay) |
335 | 336 | return data[0] |
336 | 337 |
|
| 338 | + async def fetch_ad_schedule(self, token: str) -> AdSchedule: |
| 339 | + """|coro| |
| 340 | +
|
| 341 | + Fetches the streamers's ad schedule. |
| 342 | +
|
| 343 | + Parameters |
| 344 | + ----------- |
| 345 | + token: :class:`str` |
| 346 | + The user's oauth token with the ``channel:read:ads`` scope. |
| 347 | +
|
| 348 | + Returns |
| 349 | + -------- |
| 350 | + :class:`twitchio.AdSchedule` |
| 351 | + """ |
| 352 | + from .models import AdSchedule |
| 353 | + |
| 354 | + data = await self._http.get_ad_schedule(token, str(self.id)) |
| 355 | + return AdSchedule(data[0]) |
| 356 | + |
| 357 | + async def snooze_ad(self, token: str) -> List[AdSchedule]: |
| 358 | + """|coro| |
| 359 | +
|
| 360 | + Snoozes an ad on the streamer's channel. |
| 361 | +
|
| 362 | + .. note:: |
| 363 | + The resulting :class:`~twitchio.AdSchedule` only has data for the :attr:`~twitchio.AdSchedule.snooze_count`, |
| 364 | + :attr:`~twitchio.AdSchedule.snooze_refresh_at`, and :attr:`~twitchio.AdSchedule.next_ad_at` attributes. |
| 365 | +
|
| 366 | + Parameters |
| 367 | + ----------- |
| 368 | + token: :class:`str` |
| 369 | + The user's oauth token with the ``channel:manage:ads`` scope. |
| 370 | +
|
| 371 | + Returns |
| 372 | + -------- |
| 373 | + :class:`twitchio.AdSchedule` |
| 374 | + """ |
| 375 | + from .models import AdSchedule |
| 376 | + |
| 377 | + data = await self._http.post_snooze_ad(token, str(self.id)) |
| 378 | + return AdSchedule(data[0]) |
| 379 | + |
337 | 380 | async def fetch_clips( |
338 | 381 | self, |
339 | 382 | started_at: Optional[datetime.datetime] = None, |
@@ -403,6 +446,23 @@ async def fetch_bans(self, token: str, userids: List[Union[str, int]] = None) -> |
403 | 446 | data = await self._http.get_channel_bans(token, str(self.id), user_ids=userids) |
404 | 447 | return [UserBan(self._http, d) for d in data] |
405 | 448 |
|
| 449 | + async def fetch_moderated_channels(self, token: str) -> List[PartialUser]: |
| 450 | + """|coro| |
| 451 | +
|
| 452 | + Fetches channels that this user moderates. |
| 453 | +
|
| 454 | + Parameters |
| 455 | + ----------- |
| 456 | + token: :class:`str` |
| 457 | + An oauth token for this user with the ``user:read:moderated_channels`` scope. |
| 458 | +
|
| 459 | + Returns |
| 460 | + -------- |
| 461 | + List[:class:`twitchio.PartialUser`] |
| 462 | + """ |
| 463 | + data = await self._http.get_moderated_channels(token, str(self.id)) |
| 464 | + return [PartialUser(self._http, d["user_id"], d["user_name"]) for d in data] |
| 465 | + |
406 | 466 | async def fetch_moderators(self, token: str, userids: List[int] = None): |
407 | 467 | """|coro| |
408 | 468 |
|
|
0 commit comments