Skip to content

Commit faee30b

Browse files
committed
Update docstring and organise
Update docstring and organise deprecated methods
1 parent c6fbee0 commit faee30b

File tree

1 file changed

+144
-142
lines changed

1 file changed

+144
-142
lines changed

twitchio/user.py

Lines changed: 144 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -397,29 +397,6 @@ async def fetch_bans(self, token: str, userids: List[Union[str, int]] = None) ->
397397
data = await self._http.get_channel_bans(token, str(self.id), user_ids=userids)
398398
return [UserBan(self._http, d) for d in data]
399399

400-
async def fetch_ban_events(self, token: str, userids: List[int] = None):
401-
"""|coro|
402-
403-
This has been deprecated and will be removed in a future release.
404-
405-
Fetches ban/unban events from the User's channel.
406-
407-
Parameters
408-
-----------
409-
token: :class:`str`
410-
The oauth token with the ``moderation:read`` scope.
411-
userids: List[:class:`int`]
412-
An optional list of users to fetch ban/unban events for
413-
414-
Returns
415-
--------
416-
List[:class:`twitchio.BanEvent`]
417-
"""
418-
from .models import BanEvent
419-
420-
data = await self._http.get_channel_ban_unban_events(token, str(self.id), userids)
421-
return [BanEvent(self._http, x, self) for x in data]
422-
423400
async def fetch_moderators(self, token: str, userids: List[int] = None):
424401
"""|coro|
425402
@@ -496,57 +473,11 @@ async def fetch_stream_key(self, token: str):
496473
data = await self._http.get_stream_key(token, str(self.id))
497474
return data
498475

499-
async def fetch_following(self, token: Optional[str] = None) -> List["FollowEvent"]:
500-
"""|coro|
501-
502-
Fetches a list of users that this user is following.
503-
504-
.. warning::
505-
506-
The endpoint this method uses has been deprecated by Twitch and is no longer available.
507-
508-
Parameters
509-
-----------
510-
token: Optional[:class:`str`]
511-
An oauth token to use instead of the bots token
512-
513-
Returns
514-
--------
515-
List[:class:`twitchio.FollowEvent`]
516-
"""
517-
from .models import FollowEvent
518-
519-
data = await self._http.get_user_follows(token=token, from_id=str(self.id))
520-
return [FollowEvent(self._http, d, from_=self) for d in data]
521-
522-
async def fetch_followers(self, token: Optional[str] = None):
523-
"""|coro|
524-
525-
Fetches a list of users that are following this user.
526-
527-
.. warning::
528-
529-
The endpoint this method uses has been deprecated by Twitch and is no longer available.
530-
531-
Parameters
532-
-----------
533-
token: Optional[:class:`str`]
534-
An oauth token to use instead of the bots token
535-
536-
Returns
537-
--------
538-
List[:class:`twitchio.FollowEvent`]
539-
"""
540-
from .models import FollowEvent
541-
542-
data = await self._http.get_user_follows(token=token, to_id=str(self.id))
543-
return [FollowEvent(self._http, d, to=self) for d in data]
544-
545476
async def fetch_channel_followers(self, token: str, user_id: Optional[int] = None) -> List[ChannelFollowerEvent]:
546477
"""|coro|
547478
548479
Fetches a list of users that are following this broadcaster.
549-
Requires a user access token that includes the moderator:read:followers scope.
480+
Requires a user access token that includes the ``moderator:read:followers`` scope.
550481
The ID in the broadcaster_id query parameter must match the user ID in the access token or the user must be a moderator for the specified broadcaster.
551482
552483
Parameters
@@ -578,7 +509,7 @@ async def fetch_channel_following(
578509
Parameters
579510
-----------
580511
token: :class:`str`
581-
User access token that includes the moderator:read:followers scope for the channel.
512+
User access token that includes the ``moderator:read:follows`` scope for the channel.
582513
broadcaster_id: Optional[:class:`int`]
583514
Use this parameter to see whether the user follows this broadcaster.
584515
@@ -592,32 +523,6 @@ async def fetch_channel_following(
592523
data = await self._http.get_channel_followed(token=token, user_id=str(self.id), broadcaster_id=broadcaster_id)
593524
return [ChannelFollowingEvent(self._http, d) for d in data]
594525

595-
async def fetch_follow(self, to_user: "PartialUser", token: Optional[str] = None):
596-
"""|coro|
597-
598-
Check if a user follows another user or when they followed a user.
599-
600-
.. warning::
601-
602-
The endpoint this method uses has been deprecated by Twitch and is no longer available.
603-
604-
Parameters
605-
-----------
606-
to_user: :class:`PartialUser`
607-
token: Optional[:class:`str`]
608-
An oauth token to use instead of the bots token
609-
610-
Returns
611-
--------
612-
:class:`twitchio.FollowEvent`
613-
"""
614-
if not isinstance(to_user, PartialUser):
615-
raise TypeError(f"to_user must be a PartialUser not {type(to_user)}")
616-
from .models import FollowEvent
617-
618-
data = await self._http.get_user_follows(token=token, from_id=str(self.id), to_id=str(to_user.id))
619-
return FollowEvent(self._http, data[0]) if data else None
620-
621526
async def fetch_channel_follower_count(self, token: Optional[str] = None) -> int:
622527
"""|coro|
623528
@@ -626,7 +531,7 @@ async def fetch_channel_follower_count(self, token: Optional[str] = None) -> int
626531
Parameters
627532
-----------
628533
token: Optional[:class:`str`]
629-
An oauth token to use instead of the bots token
534+
An oauth token to use instead of the bots token.
630535
631536
Returns
632537
--------
@@ -644,7 +549,7 @@ async def fetch_channel_following_count(self, token: str) -> int:
644549
Parameters
645550
-----------
646551
token: :class:`str`
647-
An oauth token to use instead of the bots token
552+
Requires a user access token that includes the ``user:read:follows`` scope.
648553
649554
Returns
650555
--------
@@ -654,49 +559,6 @@ async def fetch_channel_following_count(self, token: str) -> int:
654559
data = await self._http.get_channel_followed_count(token=token, user_id=str(self.id))
655560
return data["total"]
656561

657-
async def fetch_follower_count(self, token: Optional[str] = None) -> int:
658-
"""|coro|
659-
660-
Fetches the total number of users that are following this user.
661-
662-
.. warning::
663-
664-
The endpoint this method uses has been deprecated by Twitch and is no longer available.
665-
666-
Parameters
667-
-----------
668-
token: Optional[:class:`str`]
669-
An oauth token to use instead of the bots token
670-
671-
Returns
672-
--------
673-
:class:`int`
674-
"""
675-
676-
data = await self._http.get_follow_count(token=token, to_id=str(self.id))
677-
return data["total"]
678-
679-
async def fetch_following_count(self, token: Optional[str] = None) -> int:
680-
"""|coro|
681-
682-
Fetches a list of users that this user is following.
683-
684-
.. warning::
685-
686-
The endpoint this method uses has been deprecated by Twitch and is no longer available.
687-
688-
Parameters
689-
-----------
690-
token: Optional[:class:`str`]
691-
An oauth token to use instead of the bots token
692-
693-
Returns
694-
--------
695-
:class:`int`
696-
"""
697-
data = await self._http.get_follow_count(token=token, from_id=str(self.id))
698-
return data["total"]
699-
700562
async def fetch_channel_emotes(self):
701563
"""|coro|
702564
@@ -1771,6 +1633,146 @@ async def fetch_charity_campaigns(self, token: str) -> List[CharityCampaign]:
17711633
data = await self._http.get_channel_charity_campaigns(str(self.id), token)
17721634
return [CharityCampaign(d, self._http, self) for d in data]
17731635

1636+
# DEPRECATED
1637+
1638+
async def fetch_follow(self, to_user: "PartialUser", token: Optional[str] = None):
1639+
"""|coro|
1640+
1641+
Check if a user follows another user or when they followed a user.
1642+
1643+
.. warning::
1644+
1645+
The endpoint this method uses has been deprecated by Twitch and is no longer available.
1646+
1647+
Parameters
1648+
-----------
1649+
to_user: :class:`PartialUser`
1650+
token: Optional[:class:`str`]
1651+
An oauth token to use instead of the bots token
1652+
1653+
Returns
1654+
--------
1655+
:class:`twitchio.FollowEvent`
1656+
"""
1657+
if not isinstance(to_user, PartialUser):
1658+
raise TypeError(f"to_user must be a PartialUser not {type(to_user)}")
1659+
from .models import FollowEvent
1660+
1661+
data = await self._http.get_user_follows(token=token, from_id=str(self.id), to_id=str(to_user.id))
1662+
return FollowEvent(self._http, data[0]) if data else None
1663+
1664+
async def fetch_following(self, token: Optional[str] = None) -> List["FollowEvent"]:
1665+
"""|coro|
1666+
1667+
Fetches a list of users that this user is following.
1668+
1669+
.. warning::
1670+
1671+
The endpoint this method uses has been deprecated by Twitch and is no longer available.
1672+
1673+
Parameters
1674+
-----------
1675+
token: Optional[:class:`str`]
1676+
An oauth token to use instead of the bots token
1677+
1678+
Returns
1679+
--------
1680+
List[:class:`twitchio.FollowEvent`]
1681+
"""
1682+
from .models import FollowEvent
1683+
1684+
data = await self._http.get_user_follows(token=token, from_id=str(self.id))
1685+
return [FollowEvent(self._http, d, from_=self) for d in data]
1686+
1687+
async def fetch_followers(self, token: Optional[str] = None):
1688+
"""|coro|
1689+
1690+
Fetches a list of users that are following this user.
1691+
1692+
.. warning::
1693+
1694+
The endpoint this method uses has been deprecated by Twitch and is no longer available.
1695+
1696+
Parameters
1697+
-----------
1698+
token: Optional[:class:`str`]
1699+
An oauth token to use instead of the bots token
1700+
1701+
Returns
1702+
--------
1703+
List[:class:`twitchio.FollowEvent`]
1704+
"""
1705+
from .models import FollowEvent
1706+
1707+
data = await self._http.get_user_follows(token=token, to_id=str(self.id))
1708+
return [FollowEvent(self._http, d, to=self) for d in data]
1709+
1710+
async def fetch_follower_count(self, token: Optional[str] = None) -> int:
1711+
"""|coro|
1712+
1713+
Fetches the total number of users that are following this user.
1714+
1715+
.. warning::
1716+
1717+
The endpoint this method uses has been deprecated by Twitch and is no longer available.
1718+
1719+
Parameters
1720+
-----------
1721+
token: Optional[:class:`str`]
1722+
An oauth token to use instead of the bots token
1723+
1724+
Returns
1725+
--------
1726+
:class:`int`
1727+
"""
1728+
1729+
data = await self._http.get_follow_count(token=token, to_id=str(self.id))
1730+
return data["total"]
1731+
1732+
async def fetch_following_count(self, token: Optional[str] = None) -> int:
1733+
"""|coro|
1734+
1735+
Fetches a list of users that this user is following.
1736+
1737+
.. warning::
1738+
1739+
The endpoint this method uses has been deprecated by Twitch and is no longer available.
1740+
1741+
Parameters
1742+
-----------
1743+
token: Optional[:class:`str`]
1744+
An oauth token to use instead of the bots token
1745+
1746+
Returns
1747+
--------
1748+
:class:`int`
1749+
"""
1750+
data = await self._http.get_follow_count(token=token, from_id=str(self.id))
1751+
return data["total"]
1752+
1753+
async def fetch_ban_events(self, token: str, userids: List[int] = None):
1754+
"""|coro|
1755+
1756+
This has been deprecated and will be removed in a future release.
1757+
1758+
Fetches ban/unban events from the User's channel.
1759+
1760+
Parameters
1761+
-----------
1762+
token: :class:`str`
1763+
The oauth token with the ``moderation:read`` scope.
1764+
userids: List[:class:`int`]
1765+
An optional list of users to fetch ban/unban events for
1766+
1767+
Returns
1768+
--------
1769+
List[:class:`twitchio.BanEvent`]
1770+
"""
1771+
from .models import BanEvent
1772+
1773+
data = await self._http.get_channel_ban_unban_events(token, str(self.id), userids)
1774+
return [BanEvent(self._http, x, self) for x in data]
1775+
17741776

17751777
class BitLeaderboardUser(PartialUser):
17761778
__slots__ = "rank", "score"

0 commit comments

Comments
 (0)