feat: get_all_followed メソッドを追加

pull/109/head
yupix 7 months ago
parent 8cd4503c3f
commit e6748caa7d
No known key found for this signature in database
GPG Key ID: 2FF705F5C56D9C06

@ -442,29 +442,29 @@ class ChannelActions(ClientChannelActions):
is_sensitive: bool = MISSING, is_sensitive: bool = MISSING,
allow_renote_to_external: bool = MISSING, allow_renote_to_external: bool = MISSING,
) -> Channel: ) -> Channel:
"""Create a channel """チャンネルを作成します
Endpoint: `/api/channels/create` Endpoint: `/api/channels/create`
Parameters Parameters
---------- ----------
name : str name : str
Name of the channel チャンネル名
color : str, optional color : str
Color of the channel, by default MISSING チャンネルの色, default=MISSING
description : str, optional description : str
Description of the channel, by default MISSING チャンネルの説明, default=MISSING
banner_id : str, optional banner_id : str
Banner ID of the channel, by default MISSING チャンネルのバナーに使用するファイルのID, default=MISSING
is_sensitive : bool, optional is_sensitive : bool
Whether the channel is sensitive, by default MISSING チャンネルがセンシティブかどうか, default=MISSING
allow_renote_to_external : bool, optional allow_renote_to_external : bool, optional
Whether the channel allows renote to external, by default MISSING 外部へのリノートを許可するかどうか, default=MISSING
Returns Returns
------- -------
Channel Channel
Created channel 作成したチャンネル
""" """
data = remove_dict_missing( data = remove_dict_missing(
{ {
@ -486,14 +486,14 @@ class ChannelActions(ClientChannelActions):
return Channel(raw_channel=raw_channel, client=self._client) return Channel(raw_channel=raw_channel, client=self._client)
async def featured(self) -> list[Channel]: async def featured(self) -> list[Channel]:
"""Get featured channels """トレンドのチャンネルを取得します
Endpoint: `/api/channels/featured` Endpoint: `/api/channels/featured`
Returns Returns
------- -------
list[Channel] list[Channel]
List of featured channels 取得したチャンネルのリスト
""" """
raw_channels: list[IChannel] = await self._session.request( raw_channels: list[IChannel] = await self._session.request(
@ -506,19 +506,19 @@ class ChannelActions(ClientChannelActions):
@credentials_required @credentials_required
@override @override
async def follow(self, channel_id: str) -> bool: async def follow(self, channel_id: str) -> bool:
"""Follow a channel """指定したIDのチャンネルをフォローします
Endpoint: `/api/channels/follow` Endpoint: `/api/channels/follow`
Parameters Parameters
---------- ----------
channel_id : str channel_id : str
ID of the channel 対象のチャンネルID
Returns Returns
------- -------
bool bool
Whether the channel is followed フォローに成功したかどうか
""" """
return await super().follow(channel_id=channel_id) return await super().follow(channel_id=channel_id)
@ -526,23 +526,23 @@ class ChannelActions(ClientChannelActions):
async def followed( async def followed(
self, since_id: str | None = None, until_id: str | None = None, limit: int = 5 self, since_id: str | None = None, until_id: str | None = None, limit: int = 5
) -> list[Channel]: ) -> list[Channel]:
"""Get followed channels """フォロー中のチャンネル一覧を取得します
Endpoint: `/api/channels/followed` Endpoint: `/api/channels/followed`
Parameters Parameters
---------- ----------
since_id : str, optional since_id : str | None
Since ID, by default None 指定したチャンネルIDよりも後のチャンネルを取得します, default=None
until_id : str, optional until_id : str | None
Until ID, by default None 指定したチャンネルIDよりも前のチャンネルを取得します, default=None
limit : int, optional limit : int, optional
Limit, by default 5 一度に取得するチャンネルの数, default=5
Returns Returns
------- -------
list[Channel] list[Channel]
List of followed channels 取得したフォロー中のチャンネルのリスト
""" """
data = {"sinceId": since_id, "untilId": until_id, "limit": limit} data = {"sinceId": since_id, "untilId": until_id, "limit": limit}
@ -553,6 +553,38 @@ class ChannelActions(ClientChannelActions):
Channel(raw_channel=raw_channel, client=self._client) for raw_channel in raw_channels Channel(raw_channel=raw_channel, client=self._client) for raw_channel in raw_channels
] ]
async def get_all_followed(
self, since_id: str | None = None, until_id: str | None = None, limit: int = 5
) -> AsyncGenerator[Channel, None]:
"""フォロー中のすべてのチャンネルを取得します
Endpoint: `/api/channels/followed`
Parameters
----------
since_id : str | None
指定したチャンネルIDよりも後のチャンネルを取得します, default=None
until_id : str | None
指定したチャンネルIDよりも前のチャンネルを取得します, default=None
limit : int, optional
一度に取得するチャンネルの数, default=5
Returns
-------
AsyncGenerator[Channel, None]
取得したフォロー中のチャンネル
"""
body = {"sinceId": since_id, "untilId": until_id, "limit": limit}
pagination = Pagination[IChannel](
self._session, Route("POST", "/api/channels/followed"), json=body, auth=True
)
while pagination.is_final is False:
for raw_channel in await pagination.next():
yield Channel(raw_channel=raw_channel, client=self._client)
@credentials_required @credentials_required
async def owned( async def owned(
self, since_id: str | None = None, until_id: str | None = None, limit: int = 5 self, since_id: str | None = None, until_id: str | None = None, limit: int = 5

Loading…
Cancel
Save