From 57c0cf5e92873a4b991cc3957cdc9226ccea1e05 Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 08:29:59 +0000 Subject: [PATCH 01/11] =?UTF-8?q?feat:=20=E3=83=81=E3=83=A3=E3=83=B3?= =?UTF-8?q?=E3=83=8D=E3=83=AB=E3=81=AE=E3=83=95=E3=82=A9=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=81=AE=E6=A6=82=E5=BF=B5=E3=82=92=E8=BF=BD=E5=8A=A0=20#64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/models/channel.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mipac/models/channel.py b/mipac/models/channel.py index d89a83b..caf3fb1 100644 --- a/mipac/models/channel.py +++ b/mipac/models/channel.py @@ -16,3 +16,11 @@ class Channel(ChannelLite[IChannel]): @property def has_unread_note(self) -> bool: return self._channel['has_unread_note'] + + @property + def is_following(self) -> bool | None: + return self._channel.get('is_following') + + @property + def is_favorited(self) -> bool | None: + return self._channel.get('is_favorited') From cbe7737e0e655250e21b8fd48ed4b9d603bfa574 Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 08:30:53 +0000 Subject: [PATCH 02/11] =?UTF-8?q?chore:=20misskey=E3=81=AE=E3=83=90?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=82=92=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mipac/config.py b/mipac/config.py index 2b4a001..d010dce 100644 --- a/mipac/config.py +++ b/mipac/config.py @@ -15,7 +15,7 @@ class CacheConfig: IMisskeyDistribution = Literal['ayuskey', 'm544', 'areionskey', 'official'] - +IMisskeyVersions = Literal[13, 12, 11] class ILimits(TypedDict, total=False): channel_name: int @@ -56,7 +56,7 @@ class Config: is_ssl: bool = True, distro: IMisskeyDistribution = 'official', is_ayuskey: bool = False, - use_version: Literal[13, 12, 11] = 12, + use_version: IMisskeyVersions = 12, cache: CacheConfigData | None = None, use_version_autodetect: bool = True, features: IFeatures | None = None, @@ -66,7 +66,7 @@ class Config: self.is_ssl: bool = is_ssl self.host: str = host self.is_ayuskey: bool = is_ayuskey - self.use_version: Literal[13, 12, 11] = use_version + self.use_version: IMisskeyVersions = use_version self.cache: CacheConfig = CacheConfig(cache or CacheConfigData()) self.use_version_autodetect: bool = use_version_autodetect self.features: Features = Features(features) if features else Features() @@ -78,7 +78,7 @@ class Config: host: str | None = None, is_ssl: bool | None = None, is_ayuskey: bool | None = None, - use_version: Literal[13, 12, 11] | None = None, + use_version: IMisskeyVersions | None = None, cache: CacheConfigData | None = None, use_version_autodetect: bool | None = None, features: IFeatures | None = None, From 70beddbf2cff4333e12dbc647d8a2a1a7df8df5b Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 08:31:02 +0000 Subject: [PATCH 03/11] =?UTF-8?q?feat:=20Client=E3=82=92=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=B3=E3=82=B9=E5=8C=96=E3=81=99=E3=82=8B?= =?UTF-8?q?=E9=9A=9B=E3=81=AB=E3=82=B5=E3=83=BC=E3=83=90=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/client.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mipac/client.py b/mipac/client.py index 6d5faa2..a185286 100644 --- a/mipac/client.py +++ b/mipac/client.py @@ -1,4 +1,4 @@ -from mipac.config import Config, config +from mipac.config import Config, IMisskeyVersions, config from mipac.http import HTTPClient from mipac.manager.client import ClientManager from mipac.utils.log import LOGING_LEVEL_TYPE, setup_logging @@ -6,11 +6,18 @@ from mipac.utils.log import LOGING_LEVEL_TYPE, setup_logging class Client: def __init__( - self, url: str, token: str | None = None, *, log_level: LOGING_LEVEL_TYPE = 'INFO' + self, + url: str, + token: str | None = None, + *, + log_level: LOGING_LEVEL_TYPE = 'INFO', + use_version: IMisskeyVersions = 12, + use_version_autodetect: bool = True ) -> None: setup_logging(level=log_level) self.__url: str = url self.__token: str | None = token + config.from_dict(use_version=use_version, use_version_autodetect=use_version_autodetect) self.config: Config = config self.http: HTTPClient = HTTPClient(url, token) From 3d303dd5354d7605ffe0ee926cf5591575088caf Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 08:36:44 +0000 Subject: [PATCH 04/11] =?UTF-8?q?fix:=20channel=E3=81=AE=E5=9E=8B=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20#64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/types/channel.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mipac/types/channel.py b/mipac/types/channel.py index 0c5f968..1cbd183 100644 --- a/mipac/types/channel.py +++ b/mipac/types/channel.py @@ -7,12 +7,15 @@ class IChannelLite(TypedDict): last_noted_at: str | None name: str description: str | None + user_id: str banner_url: str | None - notes_count: int users_count: int - is_following: bool - user_id: str + notes_count: int + pinned_note_ids: list | None # pinned系は 13.11.0以上が必要 + pinned_notes: list | None class IChannel(IChannelLite): has_unread_note: bool + is_following: bool | None + is_favorited: bool | None # is_favoritedは 13.11.0以上が必要 From e710cb6c4ab254b74c269a482a85f747f69fa8f0 Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 10:59:22 +0000 Subject: [PATCH 05/11] docs: update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b60222d..0cf217d 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ Client.config.from_dict(is_ayuskey=True, use_version=13) ### 注意事項 +### 一部サーバー(インスタンス)のバージョンによっては正常に動作しない可能性があります + +MiPACの特徴として、v11,v12,v13のバージョンごとに生じる変更点をなるべく気にしなくてよいように作成していますが、現状の最新版であるv13でもv13の中で削除されたり、増えたりした物があります。結果的に追従しきれていない箇所があることがあります。そのため、そのような物を見つけた場合は、使用しているサーバーのバージョンと使用できないエンドポイント名をIssueに送信してください。 + ### モデルを基本的に自分でインスタンス化することは推奨しません MiPACのモデルでは多くの場合、キーワード引数に `client`を受け取り、それを用いて`api` プロパティを生成します。しかし、サポート途中の機能なのではそこが省かれ、リリース後にモデルのインスタンス化に必要な引数として `client` が追加されることがあります。また、他にもモデルの更新のために引数が変更される可能性があります。そのため、引数の変更に関することをCHANGELOG等で通知することはありません。 From e495ed969ab1486ab4371b157005a742b82a684e Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 11:42:45 +0000 Subject: [PATCH 06/11] =?UTF-8?q?feat:=20note=E3=81=AE=E5=9E=8B=E3=82=92?= =?UTF-8?q?=E3=82=88=E3=82=8A=E3=82=88=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/types/note.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mipac/types/note.py b/mipac/types/note.py index bca13c6..e9dea18 100644 --- a/mipac/types/note.py +++ b/mipac/types/note.py @@ -54,24 +54,27 @@ class GeoPayload(TypedDict): speed: int | None -class INoteRequired(TypedDict): - id: str +class IPartialNote(TypedDict): created_at: str - text: str | None cw: str | None - user: ILiteUser - user_id: str - reply_id: str - renote_id: str - files: list[IDriveFile] file_ids: list[str] - visibility: Literal['public', 'home', 'followers', 'specified'] - reactions: dict[str, int] + files: list[IDriveFile] + id: str + reaction_acceptance: NotRequired[Literal['likeOnly', 'likeOnlyForRemote']] # v13 only + reaction_emojis: NotRequired[dict[str, str]] # v13 only + renote_id: str | None renote_count: int + reactions: dict[str, int] replies_count: int + reply_id: str | None + text: str | None + user: ILiteUser + user_id: str + visibility: Literal['public', 'home', 'followers', 'specified'] + tags: NotRequired[list[str]] # タグがついてないとbodyに存在しない -class INote(INoteRequired, total=False): +class INote(IPartialNote, total=False): """ note object """ @@ -86,8 +89,6 @@ class INote(INoteRequired, total=False): is_hidden: bool poll: IPoll emojis: list[ICustomEmojiLite] - reaction_emojis: dict[str, str] - reaction_acceptance: Literal['likeOnly', 'likeOnlyForRemote'] | None class ICreatedNote(TypedDict): From 720c67036b47ca2e5f60369a203d238dec699fdb Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 11:43:05 +0000 Subject: [PATCH 07/11] =?UTF-8?q?feat:=20IChannelNote=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/types/channel.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mipac/types/channel.py b/mipac/types/channel.py index 1cbd183..d66fa97 100644 --- a/mipac/types/channel.py +++ b/mipac/types/channel.py @@ -1,18 +1,29 @@ -from typing import TypedDict +from typing import NotRequired, TypedDict +from mipac.types.note import IPartialNote -class IChannelLite(TypedDict): + +class IPartialChannel(TypedDict): id: str + name: str + + +class IChannelNote(IPartialNote): + channel: IPartialChannel + channel_id: str + local_only: bool + + +class IChannelLite(IPartialChannel): created_at: str last_noted_at: str | None - name: str description: str | None user_id: str banner_url: str | None users_count: int notes_count: int - pinned_note_ids: list | None # pinned系は 13.11.0以上が必要 - pinned_notes: list | None + pinned_note_ids: NotRequired[list[str]] # pinned系は 13.11.0以上が必要 + pinned_notes: NotRequired[list[IChannelNote]] class IChannel(IChannelLite): From 1d280a00c2528b32c544c2752fa6661c69b26917 Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 11:43:51 +0000 Subject: [PATCH 08/11] =?UTF-8?q?feat:=20PartialNote=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/models/lite/note.py | 122 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 mipac/models/lite/note.py diff --git a/mipac/models/lite/note.py b/mipac/models/lite/note.py new file mode 100644 index 0000000..29ccec1 --- /dev/null +++ b/mipac/models/lite/note.py @@ -0,0 +1,122 @@ +from __future__ import annotations +from datetime import datetime + +from typing import TYPE_CHECKING, Generic, Literal, TypeVar +from mipac.models.lite.user import LiteUser +from mipac.types.drive import IDriveFile + +from mipac.types.note import IPartialNote +from mipac.utils.format import str_to_datetime + +if TYPE_CHECKING: + from mipac.manager.client import ClientManager + from mipac.manager.note import ClientNoteManager + + +T = TypeVar('T', bound=IPartialNote) + + +class PartialNote(Generic[T]): + def __init__(self, note_data: T, client: ClientManager) -> None: + self._note: T = note_data + self._client: ClientManager = client + + @property + def created_at(self) -> datetime: + return str_to_datetime(self._note['created_at']) + + @property + def cw(self) -> str | None: + return self._note.get('cw') + + @property + def file_ids(self) -> list[str]: + return self._note['file_ids'] + + @property + def files(self) -> list[IDriveFile]: # TODO: モデルに + return self._note['files'] + + @property + def id(self) -> str: + """ + ノートのID + + Returns + ------- + str + ユーザーのID + """ + return self._note['id'] + + @property + def reaction_acceptance(self) -> Literal['likeOnly', 'likeOnlyForRemote'] | None: + """リアクションを受け入れ + + Returns + ------- + Literal['likeOnly', 'likeOnlyForRemote'] | None + """ + return self._note.get('reaction_acceptance') + + @property + def reaction_emojis(self) -> dict[str, str] | None: + """リアクション一覧です + + Returns + ------- + dict[str, str] | None + リアクション名がキー、値はリアクション画像のリンクです + """ + return self._note.get('reaction_emojis') + + @property + def renote_id(self) -> str | None: + return self._note['renote_id'] + + @property + def renote_count(self) -> int: + return self._note['renote_count'] + + @property + def reactions(self) -> dict[str, int]: + return self._note['reactions'] + + @property + def replies_count(self) -> int: + return self._note['replies_count'] + + @property + def reply_id(self) -> str | None: + return self._note['reply_id'] + + @property + def tags(self) -> list[str]: + return self._note.get('tags', []) + + @property + def content(self) -> str | None: + return self._note.get('text') + + @property + def author(self) -> LiteUser: + return LiteUser(self._note['user'], client=self._client) + + @property + def user_id(self) -> str: + return self._note['user_id'] + + @property + def visibility(self,) -> Literal['public', 'home', 'followers', 'specified']: + return self._note['visibility'] + + @property + def api(self) -> ClientNoteManager: + """ + ノートに対するアクション + + Returns + ------- + NoteActions + """ + return self._client.note.create_client_note_manager(self.id) From c9faf0aac63ffdfe45152549b05e8b2bfb49ca4b Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 11:44:27 +0000 Subject: [PATCH 09/11] =?UTF-8?q?feat:=20Note=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=81=A7PartialNote=E3=82=92=E7=B6=99=E6=89=BF=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/models/note.py | 135 ++++++------------------------------------- 1 file changed, 18 insertions(+), 117 deletions(-) diff --git a/mipac/models/note.py b/mipac/models/note.py index ac6816e..37267ec 100644 --- a/mipac/models/note.py +++ b/mipac/models/note.py @@ -1,21 +1,20 @@ from __future__ import annotations from datetime import datetime -from typing import TYPE_CHECKING, Literal, Optional +from typing import TYPE_CHECKING, Optional, Self from mipac.errors.base import NotExistRequiredData +from mipac.models.lite.note import PartialNote from mipac.models.lite.user import LiteUser from mipac.models.poll import Poll from mipac.types.note import INoteState, INoteTranslateResult, INoteUpdated, INoteUpdatedDelete from mipac.utils.format import str_to_datetime +from mipac.types.note import INote, INoteReaction if TYPE_CHECKING: from mipac.manager.client import ClientManager - from mipac.manager.note import ClientNoteManager from mipac.models.user import UserDetailed - from mipac.types.drive import IDriveFile from mipac.types.emoji import ICustomEmojiLite - from mipac.types.note import INote, INoteReaction __all__ = ( 'NoteState', @@ -136,7 +135,7 @@ class NoteReaction: return LiteUser(self.__reaction['user'], client=self.__client) -class Note: +class Note(PartialNote[INote]): """ Noteモデル @@ -148,93 +147,7 @@ class Note: """ def __init__(self, note: INote, client: ClientManager): - self.__note = note - self._client: ClientManager = client - - @property - def id(self) -> str: - """ - ユーザーのID - - Returns - ------- - str - ユーザーのID - """ - return self.__note['id'] - - @property - def created_at(self) -> datetime: - return str_to_datetime(self.__note['created_at']) - - @property - def content(self) -> str | None: - return self.__note.get('text') - - @property - def cw(self) -> str | None: - return self.__note.get('cw') - - @property - def user_id(self) -> str: - return self.__note['user_id'] - - @property - def author(self) -> LiteUser: - return LiteUser(self.__note['user'], client=self._client) - - @property - def reply_id(self) -> str: - return self.__note['reply_id'] - - @property - def renote_id(self) -> str: - return self.__note['renote_id'] - - @property - def files(self) -> list[IDriveFile]: # TODO: モデルに - return self.__note['files'] - - @property - def file_ids(self) -> list[str]: - return self.__note['file_ids'] - - @property - def visibility(self,) -> Literal['public', 'home', 'followers', 'specified']: - return self.__note['visibility'] - - @property - def reaction_acceptance(self) -> Literal['likeOnly', 'likeOnlyForRemote'] | None: - """リアクションを受け入れ - - Returns - ------- - Literal['likeOnly', 'likeOnlyForRemote'] | None - """ - return self.__note.get('reaction_acceptance') - - @property - def reaction_emojis(self) -> dict[str, str] | None: - """リアクション一覧です - - Returns - ------- - dict[str, str] | None - リアクション名がキー、値はリアクション画像のリンクです - """ - return self.__note.get('reaction_emojis') - - @property - def reactions(self) -> dict[str, int]: - return self.__note['reactions'] - - @property - def renote_count(self) -> int: - return self.__note['renote_count'] - - @property - def replies_count(self) -> int: - return self.__note['replies_count'] + super().__init__(note_data=note, client=client) @property def emojis(self) -> list[ICustomEmojiLite]: # TODO: モデルに @@ -248,62 +161,50 @@ class Note: List of emojis contained in note text """ - return self.__note.get('emojis', []) + return self._note.get('emojis', []) @property - def renote(self) -> 'Note' | None: + def renote(self) -> Self | None: return ( - Note(note=self.__note['renote'], client=self._client) - if 'renote' in self.__note + Note(note=self._note['renote'], client=self._client) + if 'renote' in self._note else None ) @property - def reply(self) -> 'Note' | None: + def reply(self) -> Self | None: return ( - Note(note=self.__note['reply'], client=self._client) - if 'reply' in self.__note - else None + Note(note=self._note['reply'], client=self._client) if 'reply' in self._note else None ) @property def visible_user_ids(self) -> list[str]: - return self.__note['visible_user_ids'] if 'visible_user_ids' in self.__note else [] + return self._note['visible_user_ids'] if 'visible_user_ids' in self._note else [] @property def local_only(self) -> bool: - return self.__note['local_only'] if 'local_only' in self.__note else False + return self._note['local_only'] if 'local_only' in self._note else False @property def my_reaction(self) -> str | None: - return self.__note['my_reaction'] if 'my_reaction' in self.__note else None + return self._note['my_reaction'] if 'my_reaction' in self._note else None @property def uri(self) -> str | None: - return self.__note['uri'] if 'uri' in self.__note else None + return self._note['uri'] if 'uri' in self._note else None @property def url(self) -> str | None: - return self.__note['url'] if 'url' in self.__note else None + return self._note['url'] if 'url' in self._note else None @property def is_hidden(self) -> bool: - return self.__note['is_hidden'] if 'is_hidden' in self.__note else False + return self._note['is_hidden'] if 'is_hidden' in self._note else False @property def poll(self) -> Poll | None: - return Poll(self.__note['poll'], client=self._client) if 'poll' in self.__note else None + return Poll(self._note['poll'], client=self._client) if 'poll' in self._note else None - @property - def api(self) -> ClientNoteManager: - """ - ノートに対するアクション - - Returns - ------- - NoteActions - """ - return self._client.note.create_client_note_manager(self.id) class NoteTranslateResult: From 7b3efaa10daef254af3669d025344c47f6a6991c Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 11:48:40 +0000 Subject: [PATCH 10/11] =?UTF-8?q?feat:=20channel=E5=91=A8=E3=82=8A?= =?UTF-8?q?=E3=82=92=E6=95=B4=E5=82=99=20#64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/actions/channel.py | 74 ++++++++++++++++++++++++++++++++++++ mipac/manager/channel.py | 21 ++++++++++ mipac/manager/client.py | 3 ++ mipac/models/lite/channel.py | 23 ++++++----- 4 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 mipac/actions/channel.py create mode 100644 mipac/manager/channel.py diff --git a/mipac/actions/channel.py b/mipac/actions/channel.py new file mode 100644 index 0000000..b27eddf --- /dev/null +++ b/mipac/actions/channel.py @@ -0,0 +1,74 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Literal, overload + +from mipac.abstract.action import AbstractAction +from mipac.http import HTTPClient, Route +from mipac.models.channel import Channel +from mipac.models.lite.channel import ChannelLite +from mipac.types.channel import IChannel, IChannelLite + +if TYPE_CHECKING: + from mipac.client import ClientManager + + +class ClientChannelActions(AbstractAction): + def __init__( + self, channel_id: str | None = None, *, session: HTTPClient, client: ClientManager + ): + self._channel_id: str | None = channel_id + self._session: HTTPClient = session + self._client: ClientManager = client + + async def favorite(self, channel_id: str | None = None): + if self._client._config.use_version < 13: + raise Exception() + + channel_id = self._channel_id or channel_id + if channel_id is None: + raise Exception() + + res: bool = await self._session.request( + Route('POST', '/api/channels/favorite'), auth=True, json={'channelId': channel_id} + ) + + return res + + async def unfavorite(self, channel_id: str | None = None): + + if self._client._config.use_version < 13: + raise Exception() + + channel_id = self._channel_id or channel_id + if channel_id is None: + raise Exception() + + res: bool = await self._session.request( + Route('POST', '/api/channels/unfavorite'), auth=True, json={'channelId': channel_id} + ) + + return res + + +class ChannelActions(ClientChannelActions): + def __init__( + self, channel_id: str | None = None, *, session: HTTPClient, client: ClientManager + ): + super().__init__(channel_id=channel_id, session=session, client=client) + + async def get_my_favorite(self) -> list[Channel]: + """お気に入りに登録したチャンネルの一覧を取得します。 + + Returns + ------- + Channel + チャンネル + """ + if self._client._config.use_version < 13: + raise Exception() + + res: list[IChannel] = await self._session.request( + Route('POST', '/api/channels/my-favorites'), auth=True + ) + return [Channel(i, client=self._client) for i in res] + diff --git a/mipac/manager/channel.py b/mipac/manager/channel.py new file mode 100644 index 0000000..9094779 --- /dev/null +++ b/mipac/manager/channel.py @@ -0,0 +1,21 @@ + +from __future__ import annotations +from typing import TYPE_CHECKING + +from mipac.abstract.manager import AbstractManager +from mipac.http import HTTPClient +from mipac.actions.channel import ChannelActions + +if TYPE_CHECKING: + from mipac.manager.client import ClientManager + + +class ChannelManager(AbstractManager): + def __init__(self, channel_id: str | None = None, *, session: HTTPClient, client: ClientManager): + self.__channel_id: str | None = channel_id + self.__session: HTTPClient = session + self.__client: ClientManager = client + + @property + def action(self) -> ChannelActions: + return ChannelActions(channel_id=self.__channel_id, session=self.__session, client=self.__client) diff --git a/mipac/manager/client.py b/mipac/manager/client.py index cb1e08f..88a8c65 100644 --- a/mipac/manager/client.py +++ b/mipac/manager/client.py @@ -54,5 +54,8 @@ class ClientManager: def _create_note_instance(self, note_id: str) -> NoteManager: return NoteManager(note_id, session=self.__session, client=self) + def _create_channel_instance(self, channel_id: str) -> ChannelManager: + return ChannelManager(channel_id=channel_id, session=self.__session, client=self) + async def get_me(self) -> UserDetailed: return await self.user.action.get_me() diff --git a/mipac/models/lite/channel.py b/mipac/models/lite/channel.py index 6766e12..dbe0787 100644 --- a/mipac/models/lite/channel.py +++ b/mipac/models/lite/channel.py @@ -2,12 +2,13 @@ from __future__ import annotations from datetime import datetime from typing import TYPE_CHECKING, Generic, TypeVar - from mipac.types.channel import IChannelLite from mipac.utils.format import str_to_datetime if TYPE_CHECKING: from mipac.manager import ClientManager + from mipac.manager.channel import ChannelManager + T = TypeVar('T', bound=IChannelLite) @@ -39,21 +40,25 @@ class ChannelLite(Generic[T]): return self._channel['description'] @property - def banner_url(self) -> str | None: - return self._channel['banner_url'] + def user_id(self) -> str: + return self._channel['user_id'] @property - def notes_count(self) -> int: - return self._channel['notes_count'] + def banner_url(self) -> str | None: + return self._channel['banner_url'] @property def users_count(self) -> int: return self._channel['users_count'] @property - def is_following(self) -> bool: - return bool(self._channel['is_following']) + def notes_count(self) -> int: + return self._channel['notes_count'] @property - def user_id(self) -> str: - return self._channel['user_id'] + def pinned_note_ids(self) -> list: + return self._channel.get('pinned_note_ids', []) + + @property + def api(self) -> ChannelManager: + return self.__client._create_channel_instance(channel_id=self.id) From 015070ae1cc68ccc5d755441dd21deaee8a4d4d5 Mon Sep 17 00:00:00 2001 From: yupix Date: Mon, 17 Apr 2023 11:48:48 +0000 Subject: [PATCH 11/11] docs: update CHANGELOG.md --- CHANGELOG.md | 400 +++++++++++++++++++++++++++------------------------ 1 file changed, 210 insertions(+), 190 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00bd738..6e48e11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,19 +10,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - 以下のエンドポイントがサポートされます。 - - `emoji` + - `emoji` + - `channels/favorite` + - `channels/unfavorite` + - `channels/my-favorites` +- 以下のクラスを追加 + - `IChannelNote` + - `PartialNote` +- `Note` クラスで `tags` を取得できるように +- `Client` クラスのコンストラクタ引数に以下を追加 + - `use_version` + - `use_version_autodetect` +- `ClientManager` に属性 `emoji` を追加 +- `Channel` に `api` プロパティを追加 - `CustomEmoji` に `host` プロパティを追加 -- `ClientManager` の属性に `emoji` を追加 +- `ChannelLite` に `api` プロパティを追加 + - `Channel` クラスは `ChannelLite` を継承しているため必然的にこちらにも `api` プロパティが増えています ### Changed -- `mipac.util` モジュールは `mipac.utils` 配下の `auth`, `cache`, `format`, `log`, `util`の5つに分離しました。そのため `v0.5.0`で削除されます。 - - 今後は `mipac.utils.*` をご利用ください +- `INoteRequired` が `IPartialNote` に変更されました +- `mipac.util` モジュールは `mipac.utils` 配下の `auth`, `cache`, `format`, `log`, `util`の 5 つに分離しました。そのため `v0.5.0`で削除されます。 + - 今後は `mipac.utils.*` をご利用ください + +### Fixed + +- `Note` のプロパティで一部戻り値が正しくない +- `ChannelLite` クラスに `is_following` プロパティは存在してはいけないので修正 + - tip: `Channel` クラスに移動されました ### Removed - `LiteUser` から `name` プロパティが削除されました。 - - 今後は `nickname` をご利用ください + - 今後は `nickname` をご利用ください ## [0.4.2] 2023-03-22 @@ -30,12 +50,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). #### `config.features` が追加されました -MiPACはv13, v12, v11という大きな区切りでエンドポイントが利用可能かを確認しています。その都合上、v13でサポートされいた物、例えばチャットが`13.7.0`で廃止されたような場合、MiPACは最新のMisskeyに追従しているため、デフォルトの挙動を変更します。これにより、`13.7.0`に更新してなかったり、`fork`を使用していてチャットが存在する場合でもチャットを使用すると例外である`NotSupportVersion`が発生してしまいます。その対策としてこの機能が追加されました。 -このconfigの主な役割は以下の通りです。 +MiPAC は v13, v12, v11 という大きな区切りでエンドポイントが利用可能かを確認しています。その都合上、v13 でサポートされいた物、例えばチャットが`13.7.0`で廃止されたような場合、MiPAC は最新の Misskey に追従しているため、デフォルトの挙動を変更します。これにより、`13.7.0`に更新してなかったり、`fork`を使用していてチャットが存在する場合でもチャットを使用すると例外である`NotSupportVersion`が発生してしまいます。その対策としてこの機能が追加されました。 +この config の主な役割は以下の通りです。 -- 最新のMisskeyでは使用できないが、自身が使用しているサーバーのバージョンでは使用できる場合に該当する物を有効にすることで例外を返さず、使用できるようにする +- 最新の Misskey では使用できないが、自身が使用しているサーバーのバージョンでは使用できる場合に該当する物を有効にすることで例外を返さず、使用できるようにする -使い方は以下の通りです。また、現在サポートされているfeatureは`chat`のみです。 +使い方は以下の通りです。また、現在サポートされている feature は`chat`のみです。 ```py async def main(): @@ -47,55 +67,55 @@ async def main(): #### `config.limits` が追加されました -MiPACでは文字数等にデフォルトで最新のMisskeyの値を入れています。しかし、一部のForkで文字数の制限が緩和されている・制限されている場合に正しくエラーを返せなくなる可能性があります。その対策としてこの機能が追加されました。 +MiPAC では文字数等にデフォルトで最新の Misskey の値を入れています。しかし、一部の Fork で文字数の制限が緩和されている・制限されている場合に正しくエラーを返せなくなる可能性があります。その対策としてこの機能が追加されました。 +また、自分で作成・使用している Fork でこれ存在するからデフォルトでサポートしてくれない?という物がありましたら、Issue を作成してくだされば検討します。 -また、自分で作成・使用しているForkでこれ存在するからデフォルトでサポートしてくれない?という物がありましたら、Issueを作成してくだされば検討します。 - -- Note周りのメソッドで`visibility`の型を正確に +- Note 周りのメソッドで`visibility`の型を正確に - 以下のエンドポイントがサポートされます。 - - `i/claim-achievement` - - `blocking/create` - - `blocking/delete` - - `blocking/list` - - `admin/ad/create` - - `admin/ad/delete` - - `admin/ad/list` - - `admin/ad/update` + - `i/claim-achievement` + - `blocking/create` + - `blocking/delete` + - `blocking/list` + - `admin/ad/create` + - `admin/ad/delete` + - `admin/ad/list` + - `admin/ad/update` - Added `IT_ACHIEVEMENT_NAME` fixed variable. - Added class the given below. - - Channel - - `IChannelLite` - - `ChannelLite` - - `ChannelActions` - - `ChannelManager` - - Blocking - - `BlockingUser` - - `IBlockingUser` - - `BlockingActions` - - `BlockingManager` - - Ad - - `AdminAdvertisingModelActions` - - `AdminAdvertisingActions` - - `Ad` - - `IAd` - - `AdminAdvertisingModelManager` - - `AdminAdvertisingManager` + - Channel + - `IChannelLite` + - `ChannelLite` + - `ChannelActions` + - `ChannelManager` + - Blocking + - `BlockingUser` + - `IBlockingUser` + - `BlockingActions` + - `BlockingManager` + - Ad + - `AdminAdvertisingModelActions` + - `AdminAdvertisingActions` + - `Ad` + - `IAd` + - `AdminAdvertisingModelManager` + - `AdminAdvertisingManager` - Added `block` attribute to `UserManager`. - Added `channel` attribute to `ClientManager`. - Added `reaction_emojis` property to `Note`. - Added `reaction_acceptance` property to `Note`. + ### Changed -- chatがv13で廃止された為v13を利用している際は例外を返すように変更しました。 - - v13だが、forkやchatが廃止される前のバージョンを使用していてチャットが使用したい際は新しい機能である `config.features` をご利用ください -- aiohttpのバージョンを `3.8.4`に固定 -- Tokenを使用しなくてもAPIが一部使用できるようになりました。当然ですが、認証が必要なAPIを使用した場合はエラーが出ます。 -- `Config.from_dict` の引数が全てキーワード引数になりました。これは今後Configに引数が増えた際など、変更に強くするためです。 +- chat が v13 で廃止された為 v13 を利用している際は例外を返すように変更しました。 + - v13 だが、fork や chat が廃止される前のバージョンを使用していてチャットが使用したい際は新しい機能である `config.features` をご利用ください +- aiohttp のバージョンを `3.8.4`に固定 +- Token を使用しなくても API が一部使用できるようになりました。当然ですが、認証が必要な API を使用した場合はエラーが出ます。 +- `Config.from_dict` の引数が全てキーワード引数になりました。これは今後 Config に引数が増えた際など、変更に強くするためです。 ### Removed -- サポートする気が無いため、sphinxを用いたドキュメントを削除 +- サポートする気が無いため、sphinx を用いたドキュメントを削除 ### Fixed @@ -109,76 +129,75 @@ MiPACでは文字数等にデフォルトで最新のMisskeyの値を入れて これはデフォルトで有効になっており、有効の間は自動的に `/api/meta` からバージョンを推論します。機能としては以下の通りです -- 11, 12, 13にヒットした場合それらにバージョンを変更する - - ヒットしなかった場合は何もしない -Misskey公式のバージョンニングを元に判断している為、独自のバージョニングを行っているフォーク等では正常に動作しない可能性があります。その際は `client.config.use_version_autodetect = False` とすることで無効にすることが可能です。また、手動でバージョンを設定する場合もoffにしてください。 -一部のAPIはバージョンとフォークの種類で判断しています。そのため公式のバージョン的には使用できないが、フォークの機能として存在するという場合は報告をくださればサポートします。 +- 11, 12, 13 にヒットした場合それらにバージョンを変更する - ヒットしなかった場合は何もしない + Misskey 公式のバージョンニングを元に判断している為、独自のバージョニングを行っているフォーク等では正常に動作しない可能性があります。その際は `client.config.use_version_autodetect = False` とすることで無効にすることが可能です。また、手動でバージョンを設定する場合も off にしてください。 + 一部の API はバージョンとフォークの種類で判断しています。そのため公式のバージョン的には使用できないが、フォークの機能として存在するという場合は報告をくださればサポートします。 - Added `role` property to `AdminManager`. - Added `remove_none` argument to request method. - Added method to`ClientActions` class the given below. - - `get_announcements` + - `get_announcements` - Added class the given below. - - `AdminUserActions` - - `AnnouncementCommon` - - `Announcement` - - `AnnouncementSystem` - - `IMetaAnnouncement` - - `IAnnouncementSystem` - - `AdminAnnouncementClientActions` - - `AdminAnnouncementActions` - - `AdminAnnouncementManager` - - `IModerationLog` - - `ModerationLog` - - `ServerInfoCpu` - - `ServerInfoMem` - - `ServerInfoFs` - - `ServerInfoNet` - - `ServerInfo` - - `IServerInfoCpu` - - `IServerInfoMem` - - `IServerInfoFs` - - `IServerInfoNet` - - `IServerInfo` - - `ITableStats` - - `IIndexStat` - - `IndexStat` - - `IUserIP` - - `UserIP` - - `FederationActions` - - `FederationManager` - - `IFederationInstanceStat` - - `IFederationFollowCommon` - - `IFederationFollower` - - `IFederationFollowing` + - `AdminUserActions` + - `AnnouncementCommon` + - `Announcement` + - `AnnouncementSystem` + - `IMetaAnnouncement` + - `IAnnouncementSystem` + - `AdminAnnouncementClientActions` + - `AdminAnnouncementActions` + - `AdminAnnouncementManager` + - `IModerationLog` + - `ModerationLog` + - `ServerInfoCpu` + - `ServerInfoMem` + - `ServerInfoFs` + - `ServerInfoNet` + - `ServerInfo` + - `IServerInfoCpu` + - `IServerInfoMem` + - `IServerInfoFs` + - `IServerInfoNet` + - `IServerInfo` + - `ITableStats` + - `IIndexStat` + - `IndexStat` + - `IUserIP` + - `UserIP` + - `FederationActions` + - `FederationManager` + - `IFederationInstanceStat` + - `IFederationFollowCommon` + - `IFederationFollower` + - `IFederationFollowing` - Roles - - `IRolePolicieValue` - - `IRolePolicies` - - `IRole` - - `RolePolicyValue` - - `RolePolicies` - - `Role` - - `AdminRoleActions` - - `AdminRolesManager` - - `IRoleUser` - - `RoleUser` + - `IRolePolicieValue` + - `IRolePolicies` + - `IRole` + - `RolePolicyValue` + - `RolePolicies` + - `Role` + - `AdminRoleActions` + - `AdminRolesManager` + - `IRoleUser` + - `RoleUser` - Achievements - - added `IAchievementNf` class. - - added `NotificationAchievement` class. - - added `Achievement` class. - - added `get_achievements` method at `UserActions` class. - - added `achievements` property at `UserDetailed` class. + - added `IAchievementNf` class. + - added `NotificationAchievement` class. + - added `Achievement` class. + - added `get_achievements` method at `UserActions` class. + - added `achievements` property at `UserDetailed` class. - Note - - content field auto convert empty string to None + - content field auto convert empty string to None ### Changed - Maximum number of characters has been changed from 79 to 99 - - The main reason for this change is to solve the problem that the MiPAC code is inevitably longer because of the method chain. We have kept it to the maximum of [pep8](https://peps.python.org/pep-0008/#maximum-line-length). + - The main reason for this change is to solve the problem that the MiPAC code is inevitably longer because of the method chain. We have kept it to the maximum of [pep8](https://peps.python.org/pep-0008/#maximum-line-length). - Changed a method that was returning an `AsyncIterator` to return an `AsyncGenerator`. - - Generator is more correct than Iterator because it is the correct usage. + - Generator is more correct than Iterator because it is the correct usage. - Changed class name the given below. - - `IAnnouncement` -> `IMetaAnnouncement` + - `IAnnouncement` -> `IMetaAnnouncement` - `cache` decorator no longer uses `dynamic_args` decorator ### Removed @@ -207,7 +226,7 @@ Misskey公式のバージョンニングを元に判断している為、独自 - added `IDriveLocalChart` class. - added `IDriveRemoteChart` class. - added attribute `is_official` at `Config` class. - - became `is_ayuskey` attribute is deprecated(I'll remove with v0.4.0) + - became `is_ayuskey` attribute is deprecated(I'll remove with v0.4.0) - added `get_exception_from_id` function. - Return an exception appropriate for the error encountered. - [@omg-xtao](https://github.com/omg-xtao) added `users_search_by_username_and_host` method at `UserActions` class [#24](https://github.com/yupix/MiPAC/pull/24). @@ -215,7 +234,7 @@ Misskey公式のバージョンニングを元に判断している為、独自 - [@omg-xtao](https://github.com/omg-xtao) added `users_search` method at `UserActions` class [#24](https://github.com/yupix/MiPAC/pull/24). - added new `ClientActions` class. - added `avatar_color` property at `LiteUser` class. - - Note: Since avatar_color is deprecated in v13, only None is returned for v13 instances. + - Note: Since avatar_color is deprecated in v13, only None is returned for v13 instances. - added `un_renote` method at `ClientNoteActions` class. - added `get_children` method at `ClientNoteActions` class. - added `invalidate` method at `FollowActions` class. @@ -228,47 +247,47 @@ Misskey公式のバージョンニングを元に判断している為、独自 - added `AdminActions` class. - added `ICustomEmojiLiteRequired` class. - The following methods are added to the `AdminEmojiActions` class. - - `gets` - - `gets_remote` + - `gets` + - `gets_remote` - added some meta class. - - `ICPU` - - `IPolicies` - - `IAnnouncement` - - `IV12Features` - - `IV11Features` - - `IFeatures` - - `IV12AdminMeta` - - `ISharedAdminMeta` - - `ILiteV12Meta` - - `ILiteV11Meta` - - `IMetaCommonV12` - - `ICommonV11` - - `IMetaCommon` - - `ILiteMeta` - - `IV12Meta` - - `IMeta` - - `IAdminMeta` - - `Policies` - - `Features` - - `Meta` - - `AdminMeta` - - `CPU` - - `MetaCommon` - - `LiteMeta` + - `ICPU` + - `IPolicies` + - `IAnnouncement` + - `IV12Features` + - `IV11Features` + - `IFeatures` + - `IV12AdminMeta` + - `ISharedAdminMeta` + - `ILiteV12Meta` + - `ILiteV11Meta` + - `IMetaCommonV12` + - `ICommonV11` + - `IMetaCommon` + - `ILiteMeta` + - `IV12Meta` + - `IMeta` + - `IAdminMeta` + - `Policies` + - `Features` + - `Meta` + - `AdminMeta` + - `CPU` + - `MetaCommon` + - `LiteMeta` - added some federation class. - - `IFederationInstanceRequired` - - `IFederationInstance` - - `FederationInstance` + - `IFederationInstanceRequired` + - `IFederationInstance` + - `FederationInstance` - added some notification classes. - - `Notification` - - `NotificationFollow` - - `NotificationFollowRequest` - - `NotificationNote` - - `NotificationPollEnd` - - `NotificationReaction` - - `IUserNf` - - `INoteNf` - - `IPollEndNf` + - `Notification` + - `NotificationFollow` + - `NotificationFollowRequest` + - `NotificationNote` + - `NotificationPollEnd` + - `NotificationReaction` + - `IUserNf` + - `INoteNf` + - `IPollEndNf` ### Changed @@ -278,41 +297,41 @@ Misskey公式のバージョンニングを元に判断している為、独自 - rename `DriveChartPayload` class to `IDriveChart` class. - The attribute `emojis` for Note and LiteUser is obsolete in misskey v13, so v13 will return an empty list. - config is now a global variable. - - If you want to change the config, please use `Client.config.from_dict`. + - If you want to change the config, please use `Client.config.from_dict`. - CustomEmoji now inherits PartialCustomEmoji. - PartialCustomEmoji url has been changed to return `str | None` to match v13. - AdminManager's `get_invite` method has been moved to `AdminActions. - **BREAKING CHANGE** `ClientActions` has been changed to `ClientManager` - **BREAKING CHANGE** Some paths will be changed as follows - - `manager.admin` -> `manager.admins` - - `manager.admin.manager` -> `manager.admins.admin` - - `actions.admin` -> `actions.admins` + - `manager.admin` -> `manager.admins` + - `manager.admin.manager` -> `manager.admins.admin` + - `actions.admin` -> `actions.admins` - **BREAKING CHANGE** - - The `action` property in the model has been changed to `api`. - - Change `note.action.send` to `note.api.action.send`. - - Moved the reaction attribute of `ClientActions` to `NoteManager`. - - Change `api.reaction` to `api.note.reaction`. - - Moved methods from `AdminEmojiManager` to `AdminEmojiActions`. - - Change `api.admin.emoji.add` to `api.admin.emoji.action.add`. - - Moved methods from `AdminModeratorManager` to `AdminModeratorActions`. - - Change `api.admin.moderator.add` to `api.admin.moderator.action.add`. - - Moved methods from `ChartManager` to `ChartActions`. - - Change `api.chart.get_active_user` to `api.chat.action.get_active_user`. - - Moved methods from `FollowManager` to `FollowActions`. - - Change `api.user.follow.add` to `api.user.follow.action.add`. - - Moved methods from `FollowRequestManager` to `FollowRequestActions`. - - `api.user.follow.action.get_all`. - - Moved some attributes of `NoteActions` to `NoteManager`. - - Change `api.note.action.reaction.add` to `api.note.reaction.action.add`. - - Moved the reaction attribute of `NoteActions` to `ClientNoteManager`. - - Change `api.note.action.reaction` to `api.note.reaction.action`. - - Change `api.note.action.favorite` to `api.note.favorite.action`. + - The `action` property in the model has been changed to `api`. + - Change `note.action.send` to `note.api.action.send`. + - Moved the reaction attribute of `ClientActions` to `NoteManager`. + - Change `api.reaction` to `api.note.reaction`. + - Moved methods from `AdminEmojiManager` to `AdminEmojiActions`. + - Change `api.admin.emoji.add` to `api.admin.emoji.action.add`. + - Moved methods from `AdminModeratorManager` to `AdminModeratorActions`. + - Change `api.admin.moderator.add` to `api.admin.moderator.action.add`. + - Moved methods from `ChartManager` to `ChartActions`. + - Change `api.chart.get_active_user` to `api.chat.action.get_active_user`. + - Moved methods from `FollowManager` to `FollowActions`. + - Change `api.user.follow.add` to `api.user.follow.action.add`. + - Moved methods from `FollowRequestManager` to `FollowRequestActions`. + - `api.user.follow.action.get_all`. + - Moved some attributes of `NoteActions` to `NoteManager`. + - Change `api.note.action.reaction.add` to `api.note.reaction.action.add`. + - Moved the reaction attribute of `NoteActions` to `ClientNoteManager`. + - Change `api.note.action.reaction` to `api.note.reaction.action`. + - Change `api.note.action.favorite` to `api.note.favorite.action`. ### Fixed - can't delete emoji with v12. - fixed `ChatMessage` model. - - For v13, the url is automatically generated. (Although it returns None by type, it never actually returns None. + - For v13, the url is automatically generated. (Although it returns None by type, it never actually returns None. - fixed `Chat` action. - fixed `Chat` action. @@ -325,11 +344,11 @@ Misskey公式のバージョンニングを元に判断している為、独自 - Delete `RawDriveChart` class. - Delete `get_user` method at `FollowRequestActions` class. - removed some meta classes. - - `LiteInstanceMeta` - - `IInstanceMetaLite` - - `IInstanceFeatures` - - `IInstancePolicies` - - `InstanceMeta` + - `LiteInstanceMeta` + - `IInstanceMetaLite` + - `IInstanceFeatures` + - `IInstancePolicies` + - `InstanceMeta` ## [0.3.1] 2022-12-24 @@ -360,7 +379,7 @@ Misskey公式のバージョンニングを元に判断している為、独自 ### Added - `LiteUser` に `action` プロパティを追加しました。 - - これにより `UserDetailed` の方から `action`が削除されていますが、`UserDetailed` は `LiteUser` を継承しているため今まで通りご利用いただけます + - これにより `UserDetailed` の方から `action`が削除されていますが、`UserDetailed` は `LiteUser` を継承しているため今まで通りご利用いただけます - `UserActions` クラスに `get_profile_link` メソッドを追加しました ## [0.2.7] 2022-12-23 @@ -387,8 +406,8 @@ Misskey公式のバージョンニングを元に判断している為、独自 ### Fixed -- Noteモデルの `content` が無い場合KeyErrorになる -- Noteモデルの `cw` が無い場合KeyErrorになる +- Note モデルの `content` が無い場合 KeyError になる +- Note モデルの `cw` が無い場合 KeyError になる ## [0.2.4] - 2022-12-08 @@ -400,38 +419,38 @@ Misskey公式のバージョンニングを元に判断している為、独自 ### Changed - `NoteActions` が持っているノートに対する操作を `ClientNoteActions` に移動しました - - 継承しているため今まで通り使用できます + - 継承しているため今まで通り使用できます ### Fixed -- sendメソッドの引数 `extract_hashtags` が正常に動作しない +- send メソッドの引数 `extract_hashtags` が正常に動作しない ## [0.2.3] - 2022-11-27 ### Fixed - `NoteAction.send` メソッドで作成したノートのモデルが生成できない -- `request` メソッドで戻り値がlistではなくdistだった場合snake caseに置き換えできない +- `request` メソッドで戻り値が list ではなく dist だった場合 snake case に置き換えできない ## [0.2.2] - 2022-11-27 ### Added -- `LiteUser` に属性 `name` を互換性の為に再追加しましたが、非推奨です。v0.4.0で削除する予定です - - `username` と `name` の違いを区別しにくい可能性がある為、新たに使用する際は `nickname` を使用することを推奨しています +- `LiteUser` に属性 `name` を互換性の為に再追加しましたが、非推奨です。v0.4.0 で削除する予定です + - `username` と `name` の違いを区別しにくい可能性がある為、新たに使用する際は `nickname` を使用することを推奨しています ### Changed -- deprecatedに関する仕組みを変更しました。 - - 該当するコードを表示するようになっています +- deprecated に関する仕組みを変更しました。 + - 該当するコードを表示するようになっています ### Fixed - 型の間違い等 - 使用しているインポートが`TYPE_CHECKING`の条件式の中に入っていた為使用できない -- `get_mention` メソッドで`username` ではなく`nickname`を使用していた為正しいmentionが作れない -- `LiteUser` クラスの属性`instance` でBotと同じインスタンスのユーザーの場合はNoneを返せずKeyErrorになる可能性があった -- `LiteUser` クラスの属性 `host` を取得すると KeyErrorになる可能性があった +- `get_mention` メソッドで`username` ではなく`nickname`を使用していた為正しい mention が作れない +- `LiteUser` クラスの属性`instance` で Bot と同じインスタンスのユーザーの場合は None を返せず KeyError になる可能性があった +- `LiteUser` クラスの属性 `host` を取得すると KeyError になる可能性があった ### Removed @@ -443,18 +462,18 @@ Misskey公式のバージョンニングを元に判断している為、独自 ### Added - `NoteActions` に `gets` メソッドが追加されました #MP-20 -- Type Hintの追加 +- Type Hint の追加 ### Changed -- WebSocketを使用した際のレスポンスクラスを `MisskeyClientWebSocketResponse` クラス に +- WebSocket を使用した際のレスポンスクラスを `MisskeyClientWebSocketResponse` クラス に - `Reaction` クラスを `NotificationReaction` に変更しました - `IUserLite` を `ILiteUser` に変更しました - `LiteUser` の属性 `name` を `nickname` に変更しました。 `LiteUser` を継承しているクラスも同様に変更されていますのでご注意ください。 ### Removed -- printを使用したデバッグログを削除しました +- print を使用したデバッグログを削除しました ## [0.2.0] - 2022-11-02 @@ -481,9 +500,10 @@ Misskey公式のバージョンニングを元に判断している為、独自 - added `ChatGroup` class - added `ChatMessage` class - added `IChatGroup` class -- NoteActionsクラスに `get` `fetch` メソッドを追加 -- データをキャッシュするためのツールをutils.pyに追加 -- orjsonが使用者の環境にある場合はjsonではなくorjsonを使用するようになりました +- NoteActions クラスに `get` `fetch` メソッドを追加 +- データをキャッシュするためのツールを utils.py に追加 +- orjson が使用者の環境にある場合は json ではなく orjson を使用するようになりました + ### Changed - `Dict[Any, Any]` のような構文を typing モジュールを使わない `dict[any, any]` に変更 @@ -500,7 +520,7 @@ Misskey公式のバージョンニングを元に判断している為、独自 - `Renote` クラスを削除しました。今後は `Note` クラスをご利用ください - `IRenote`, `RenotePayload` クラスを削除しました。今後は `INote` クラスをご利用ください - `RawEmoji`, `Emoji` クラスを削除しました。 今後は `CustomEmoji` クラスをご利用ください -- `EmojiPayload` クラスを削除しました。今後は `ICustomEmoji` クラスをご利用ください +- `EmojiPayload` クラスを削除しました。今後は `ICustomEmoji` クラスをご利用ください - `IReactionRequired`, `ReactionPayload`を削除しました。 今後は `IReactionNf` クラスをご利用ください - `RawUser`, `User` クラスを削除しました。今後は `UserDetailed`, `LiteUser` クラスをご利用ください - `RawInstance` クラスを削除しました。今後は `LiteInstance` クラスをご利用ください @@ -533,7 +553,7 @@ Misskey公式のバージョンニングを元に判断している為、独自 - `Note` クラスの`created_at` 属性の type hint を `Optional[str]` => `Optional[datetime]` に変更 - `Note` クラスの `cw` 属性の取得方法が get ではなかったので修正 - **BREAKING CHANGE** `FileManager`, `FolderManager`, `DriveManager`の役割が変わりました - - 例だと `FolderManager.get_files()` だったコードが `FolderManager.action.get_files()` と行ったふうに Actions クラスを経由するようになりました + - 例だと `FolderManager.get_files()` だったコードが `FolderManager.action.get_files()` と行ったふうに Actions クラスを経由するようになりました - 開発者向け情報 `Folder` クラスの引数に `client` を追加しました ### Fixed