API Reference#
This section describes the API of Mi.py
Note
This library can output debug using logging. Because it doesn’t appear in the standard configuration, you should pass debug as an argument at startup.
event reference#
- mi.on_ready(ws)#
It is called when the bot has finished connecting to the websocket.
abstract base class#
abstract base class is a class that can be inherited to get a list of methods etc. Abstract base class can not be instantiated.
AbstractBotBase#
AbstractChatContent#
Misskey Models#
Danger
The following classes are not intended to be created by the user. You should not create your own instances, and you should not modify the values.
note#
- defemoji_count
- asyncreply
- class mi.framework.Note[source]#
- property id#
ユーザーのID
- Returns
ユーザーのID
- Return type
str
- property action#
ノートに対するアクション
- Return type
- await reply(content, cw=None, extract_mentions=True, extract_hashtags=True, extract_emojis=True, renote_id=None, channel_id=None, file_ids=None, poll=None)[source]#
ノートに対して返信を送信します
- Parameters
content (Optional[str]) – 返信内容
cw (Optional[str]) – 閲覧注意
extract_mentions (bool, optional) – メンションを展開するか, by default False
extract_hashtags (bool, optional) – ハッシュタグを展開するか, by default False
extract_emojis (bool, optional) – 絵文字を展開するか, by default False
renote_id (Optional[str], optional) – リノート先のid, by default None
channel_id (Optional[str], optional) – チャンネルid, by default None
file_ids ([type], optional) – 添付するファイルのid, by default None
poll (Optional[Poll], optional) – アンケート, by default None
user#
- defget_followers
- asyncget_profile
- class mi.framework.User[source]#
-
- get_followers(until_id=None, limit=10, get_all=False)[source]#
ユーザーのフォロワー一覧を取得します
- Parameters
until_id (str, default=None) – 前回のフォロワーの続きを取得する場合の起点とするユーザーid
limit (int, default=10) – 最大何人取得するか, max=100
get_all (bool, default=False) – 全てのフォロワーを取得するか否か
- Returns
ユーザーのフォロワー一覧
- Return type
AsyncIterator[FollowRequest]
Chat#
- asyncdelete
emoji#
Renote#
- defemoji_count
follow#
Header#
Properties#
file#
reaction#
data class#
MiFile#
- class mi.wrapper.file.MiFile[source]#
- Parameters
path (Optional[str], default=None) – path to a local file
file_id (Optional[str], default=None) – ID of the file that exists on the drive
Optional[str] (name) – file name
default=None – file name
folder_id (Optional[str], default=None) – Folder ID
comment (Optional[str], default=None) – Comments on files
is_sensitive (Optional[str], default=None) – Whether this item is sensitive
force (bool, default=False) – Whether to force overwriting even if it already exists on the drive
RawNote#
- class mi.wrapper.models.RawNote[source]#
- id#
- Type
str
- created_at#
- Type
datetime
- user_id#
- Type
str
- content#
- Type
Optional[str]
- cw#
- Type
Optional[str]
- visibility#
- Type
Optional[str]
- renote_count#
- Type
Optional[int]
- replies_count#
- Type
Optional[int]
- reactions#
- Type
Optional[Dict[str, Any]]
- file_ids#
- Type
Optional[List[str]]
- reply_id#
- Type
Optional[str]
- renote_id#
- Type
Optional[str]
- poll#
- Type
Optional[RawPoll]
- visible_user_ids#
- Type
Optional[List[str]]
- via_mobile#
- Type
bool
- local_only#
- Type
bool
- extract_mentions#
- Type
bool
- extract_hashtags#
- Type
bool
- extract_emojis#
- Type
bool
- preview#
- Type
bool
- media_ids#
- Type
Optional[List[str]]
- field#
- Type
Optional[dict]
- tags#
- Type
Optional[List[str]]
- channel_id#
- Type
Optional[str]
RawChat#
- class mi.wrapper.models.RawChat[source]#
- id#
chat ID
- Type
str
- created_at#
chat creation time
- Type
str
- content#
chat content
- Type
str
- user_id#
ID of the user who created the chat
- Type
str
- recipient_id#
- Type
str
- recipient#
- Type
str
- group_id#
group ID
- Type
str
- file_id#
ID of the attached file
- Type
str
- is_read#
whether the chat is read
- Type
bool
- reads#
- Type
List
- Parameters
data (ChatPayload) –
RawProperties#
RawFolder#
RawFile#
- class mi.wrapper.models.RawFile[source]#
- id#
ファイルのID
- Type
str
- created_at#
ファイルのの作成された日時
- Type
datetime
- name#
ファイルの名前
- Type
str
- type#
ファイルの拡張子
- Type
str
- md5#
ファイルのmd5
- Type
str
- size#
ファイルのサイズ
- Type
int
- is_sensitive#
このファイルはセンシティブか否か
- Type
bool
- blurhash#
このファイルのblurhash
- Type
str
- properties#
ファイルの情報
- Type
Optional[RawProperties]
- url#
ファイルのurl
- Type
str
- thumbnail_url#
ファイルのサムネイルurl
- Type
str
- comment#
ファイルのコメント
- Type
str
- folder_id#
親フォルダのID
- Type
str
- user_id#
ファイル作成者のID
- Type
str
- user#
ファイル作成者の情報
- Type
Dict[str, Any]
RawEmoji#
RawInstance#
- class mi.wrapper.models.RawInstance[source]#
- host#
- Type
Optional[str], default=None
- name#
- Type
Optional[str], default=None
- software_name#
- Type
Optional[str], default=None
- software_version#
- Type
Optional[str], default=None
- icon_url#
- Type
Optional[str], default=None
- favicon_url#
- Type
Optional[str], default=None
- theme_color#
- Type
Optional[str], default=None
RawRenote#
- class mi.wrapper.models.RawRenote[source]#
- id#
- Type
str
- created_at#
- Type
datetime
- user_id#
- Type
str
- content#
- Type
Optional[str], default=None
- cw#
- Type
Optional[str], default=None
- visibility#
- Type
str
- renote_count#
- Type
int
- replies_count#
- Type
int
- reactions#
- emojis#
- file_ids#
- Type
List[str]
- files#
- reply_id#
- renote_id#
- uri#
- poll Optional[RawPoll]
RawPollChoices#
RawNoteReaction#
RawUserDetails#
RawUser#
- class mi.wrapper.models.RawUser[source]#
- idstr
ユーザーのID
- namestr
ユーザーの名前
- nicknameOptional[str]
ユーザーの表示名
- hostOptional[str]
# TODO: いい感じに
- avatar_urlOptional[str]
ユーザーのアバターurl
- is_adminbool
管理者か否か
- is_botbool
ボットか否か
- is_catbool
ねこか否か
- is_ladybool
お嬢様か否か (Ayuskeyのみ)
- emojisOptional[List[str]]
# TODO 謎
- urlOptional[str]
# TODO 謎
- uriOptional[str]
# TODO 謎
- created_atOptional[datetime]
ユーザーの作成日時
- ff_visibilitystr
# TODO 謎
- is_followingbool
フォローされてるか否か
- is_followbool
フォローしているか否か
- is_blockingbool
ブロックしているか否か
- is_blockedbool
ブロックされてるか否か
- is_mutedbool
ミュートしているか否か
- detailsRawUserDetails
ユーザーの詳細情報
- instanceOptional[RawInstance]
インスタンスの情報
アクションクラス#
NoteActions#
- asyncadd_clips
- asynccreate_quote
- asynccreate_renote
- asyncdelete
- asyncget_note
- asyncget_replies
- class mi.actions.NoteActions[source]#
- await add_clips(clip_id, note_id=None)[source]#
クリップに追加します
- Parameters
note_id (Optional[str], default=None) – 追加するノートのID
clip_id (str) – クリップのID
note_id – 追加したいノートのID
- Returns
Successful or not.
- Return type
bool
- staticmethod await send(content=None, visibility='public', visible_user_ids=None, cw=None, local_only=False, extract_mentions=True, extract_hashtags=True, extract_emojis=True, reply_id=None, renote_id=None, channel_id=None, files=None, poll=None)[source]#
ノートを投稿します。
- Parameters
content (Optional[str], default=None) – 投稿する内容
visibility (str, optional) – 公開範囲, by default “public”
visible_user_ids (Optional[List[str]], optional) – 公開するユーザー, by default None
cw (Optional[str], optional) – 閲覧注意の文字, by default None
local_only (bool, optional) – ローカルにのみ表示するか, by default False
extract_mentions (bool, optional) – メンションを展開するか, by default False
extract_hashtags (bool, optional) – ハッシュタグを展開するか, by default False
extract_emojis (bool, optional) – 絵文字を展開するか, by default False
reply_id (Optional[str], optional) – リプライ先のid, by default None
renote_id (Optional[str], optional) – リノート先のid, by default None
channel_id (Optional[str], optional) – チャンネルid, by default None
files (List[MiFile], optional) – 添付するファイルのリスト, by default None
poll (Optional[Poll], optional) – アンケート, by default None
- Returns
投稿したノート
- Return type
- Raises
ContentRequired – [description]
- await delete(note_id=None)[source]#
ノートを削除します
- Parameters
note_id (Optional[str], default=None) – 削除したいノートのID
- Returns
削除に成功したか否か
- Return type
bool
- await create_renote(note_id=None)[source]#
リノートを作成します
- Parameters
note_id (Optional[str], default=None) – ノートのID
- Returns
作成したリノート
- Return type
- await create_quote(content=None, visibility='public', visible_user_ids=None, cw=None, local_only=False, extract_mentions=True, extract_hashtags=True, extract_emojis=True, file_ids=None, poll=None, note_id=None)[source]#
Create a note quote.
- Parameters
content (Optional[str], default=None) – text
visibility (str, default='public') – Disclosure range
visible_user_ids (Optional[List[str]], default=None) – List of users to be published
cw (Optional[str], default=None) – Text to be displayed when warning is given
local_only (bool, default=False) – Whether to show only locally or not
extract_mentions (bool, default=True) – Whether to expand the mention
extract_hashtags (bool, default=True) – Whether to expand the hashtag
extract_emojis (bool, default=True) – Whether to expand the emojis
file_ids (Optional[List[str]], default=None) – The ID list of files to be attached
poll (Optional[Poll], default=None) – Questionnaire to be created
note_id (Optional[str], default=None) – Note IDs to target for renote and citations
- await get_note(note_id=None)[source]#
ノートを取得します
- Parameters
note_id (Optional[str], default=None) – ノートのID
- Returns
取得したノートID
- Return type
- await get_replies(since_id=None, until_id=None, limit=10, note_id=None)[source]#
ノートに対する返信を取得します
- Parameters
since_id (Optional[str], default=None) – 指定すると、その投稿を投稿を起点としてより新しい投稿を取得します
until_id (Optional[str], default=None) – 指定すると、その投稿を投稿を起点としてより古い投稿を取得します
limit (int, default=10) – 取得する上限
note_id (Optional[str], default=None) – 返信を取得したいノートのID
- Returns
返信のリスト
- Return type
List[Note]
AdminActions#
FolderActions#
DriveActions#
UserActions#
- asyncget
- defget_mention
- class mi.actions.UserActions[source]#
- await get(user_id=None, username=None, host=None)[source]#
ユーザーのプロフィールを取得します。一度のみサーバーにアクセスしキャッシュをその後は使います。 fetch_userを使った場合はキャッシュが廃棄され再度サーバーにアクセスします。
- Parameters
user_id (str) – 取得したいユーザーのユーザーID
username (str) – 取得したいユーザーのユーザー名
host (str, default=None) – 取得したいユーザーがいるインスタンスのhost
- Returns
ユーザー情報
- Return type
型クラス#
ChatPayload#
PropertiesPayload#
FolderPayload#
FilePayload#
EmojiPayload#
FeaturesPayload#
OptionalMeta#
MetaPayload#
OptionalInstance#
InstancePayload#
GeoPayload#
PollPayload#
RenotePayload#
NotePayload#
OptionalReaction#
ReactionPayload#
NoteReactionPayload#
ChannelPayload#
PinnedNotePayload#
PinnedPagePayload#
FieldContentPayload#
OptionalUser#
UserPayload#
exception handling#
NotFoundError#
TaskNotRunningError#
ImAi#
InternalServerError#
ClientError#
AuthenticationError#
NotExistRequiredParameters#
InvalidParameters#
CredentialRequired#
ContentRequired#
CogNameDuplicate#
ExtensionAlreadyLoaded#
ExtensionFailed#
NoEntryPointError#
ExtensionNotFound#
CommandRegistrationError#
CommandError#
CommandInvokeError#
CheckFailure#
InvalidCogPath#
NotExistRequiredData#
Low-Level API#
- class mi.framework.ConnectionState[source]#
- parse_channel(message)[source]#
parse_channel is a function to parse channel event
チャンネルタイプのデータを解析後適切なパーサーに移動させます
- Parameters
message (Dict[str, Any]) – Received message
- parse_notification(message)[source]#
通知イベントを解析する関数
- Parameters
message (Dict[str, Any]) – Received message
Low-Layer API#
- class mi.framework.InstanceIterator[source]#
- async for ... in get_users(limit=10, *, offset=0, sort=None, state='all', origin='local', username=None, hostname=None, get_all=False)[source]#
- Parameters
limit (int) –
offset (int) –
sort (str) –
state (str) –
origin (str) –
username (str) –
hostname (str) –
get_all (bool) –
- Return type
Iterator[User]