Skip to content

Commit

Permalink
feat!: ClientChannelActionsの対象のIDを指定する引数を削除 #140
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Jun 18, 2024
1 parent 75f96de commit a11c9ea
Showing 1 changed file with 12 additions and 57 deletions.
69 changes: 12 additions & 57 deletions mipac/actions/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ async def send(
renote_id: str | None = None,
files: list[MiFile | File | str] | None = None,
poll: MiPoll | None = None,
*,
channel_id: str | None = None,
) -> Note:
"""Send a note
Expand Down Expand Up @@ -407,15 +405,12 @@ async def send(
Files, by default None
poll : MiPoll, optional
Poll, by default None
channel_id : str, optional
ID of the channel, by default None
Returns
-------
Note
Created note
"""
channel_id = channel_id or self._channel_id
return await super().send(
text=text,
cw=cw,
Expand All @@ -429,45 +424,35 @@ async def send(
extract_emojis=extract_emojis,
reply_id=reply_id,
renote_id=renote_id,
channel_id=channel_id,
channel_id=self._channel_id,
local_only=local_only,
)

@override
async def follow(self, *, channel_id: str) -> bool:
async def follow(self) -> bool:
"""Follow a channel
Endpoint: `/api/channels/follow`
Parameters
----------
channel_id : str, optional
ID of the channel, by default None
Returns
-------
bool
Whether the channel is followed
"""
return await super().follow(channel_id=channel_id)
return await super().follow(channel_id=self._channel_id)

@override
async def unfollow(self, *, channel_id: str) -> bool:
async def unfollow(self) -> bool:
"""指定したIDのチャンネルのフォローを解除します
Endpoint: `/api/channels/unfollow`
Parameters
----------
channel_id : str | None
対象のチャンネルID, default=None
Returns
-------
bool
フォロー解除に成功したかどうか
"""
return await super().unfollow(channel_id=channel_id)
return await super().unfollow(channel_id=self._channel_id)

@override
async def update(
Expand All @@ -480,8 +465,6 @@ async def update(
color: str | None = MISSING,
is_sensitive: bool | None = MISSING,
allow_renote_to_external: bool | None = MISSING,
*,
channel_id: str,
) -> Channel:
"""チャンネルの情報を更新します
Expand All @@ -505,15 +488,12 @@ async def update(
チャンネルがセンシティブかどうか, default=MISSING
allow_renote_to_external : bool | None
外部へのリノートを許可するかどうか, default=MISSING
channel_id : str | None
対象のチャンネルID, default=None
Returns
-------
Channel
更新後のチャンネル
"""
channel_id = channel_id or self._channel_id

return await super().update(
name=name,
Expand All @@ -524,7 +504,7 @@ async def update(
color=color,
is_sensitive=is_sensitive,
allow_renote_to_external=allow_renote_to_external,
channel_id=channel_id,
channel_id=self._channel_id,
)

@override
Expand All @@ -535,8 +515,6 @@ async def timeline(
until_id: str | None = None,
since_date: int | None = None,
until_date: int | None = None,
*,
channel_id: str,
) -> list[Note]:
"""チャンネルのタイムラインを取得します
Expand All @@ -554,23 +532,20 @@ async def timeline(
指定した日付のノートより後のノートを取得します, default=None
until_date : int | None
指定した日付のノートより前のノートを取得します, default=None
channel_id : str | None
対象のチャンネルID, default=None
Returns
-------
list[Note]
取得したノートのリスト
"""
channel_id = channel_id or self._channel_id

return await super().timeline(
limit=limit,
since_id=since_id,
until_id=until_id,
since_date=since_date,
until_date=until_date,
channel_id=channel_id,
channel_id=self._channel_id,
)

@override
Expand All @@ -580,8 +555,6 @@ async def get_all_timeline(
until_id: str | None = None,
since_date: int | None = None,
until_date: int | None = None,
*,
channel_id: str | None = None,
) -> AsyncGenerator[Note, None]:
"""チャンネルのタイムラインを全て取得します
Expand All @@ -599,64 +572,46 @@ async def get_all_timeline(
指定した日付のノートより後のノートを取得します, default=None
until_date : int | None
指定した日付のノートより前のノートを取得します, default=None
channel_id : str | None
対象のチャンネルID, default=None
Returns
-------
AsyncGenerator[Note, None]
取得したノートのリスト
"""
channel_id = channel_id or self._channel_id

async for i in super().get_all_timeline(
since_id=since_id,
until_id=until_id,
since_date=since_date,
until_date=until_date,
channel_id=channel_id,
channel_id=self._channel_id,
):
yield i

@override
async def favorite(self, *, channel_id: str) -> bool:
async def favorite(self) -> bool:
"""指定したIDのチャンネルをお気に入りにします
Endpoint: `/api/channels/favorite`
Parameters
----------
channel_id : str | None
対象のチャンネルID, default=None
Returns
-------
bool
お気に入りに追加できたかどうか
"""
channel_id = channel_id or self._channel_id

return await super().favorite(channel_id=channel_id)
return await super().favorite(channel_id=self._channel_id)

@override
async def unfavorite(self, *, channel_id: str) -> bool:
async def unfavorite(self) -> bool:
"""指定したIDのチャンネルをお気に入りから外します
Endpoint: `/api/channels/unfavorite`
Parameters
----------
channel_id : str | None
対象のチャンネルID, default=None
Returns
-------
bool
お気に入りから外せたかどうか
"""
channel_id = channel_id or self._channel_id

return await super().unfavorite(channel_id=channel_id)
return await super().unfavorite(channel_id=self._channel_id)


class ChannelActions(SharedChannelActions):
Expand Down

0 comments on commit a11c9ea

Please sign in to comment.