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.

mi.on_message(note: Note)#

Called when a note is posted in the channel you are connected to

mi.on_emoji_add(emoji: Emoji)#

Called when a pictogram is added to an instance

mi.on_mention(mention: Note)#

メンションが含まれたノートなどが投稿された際に呼び出されます

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#

class mi.abc.AbstractChat[source]#

AbstractChatContent#

class mi.abc.AbstractChatContent[source]#

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#

Attributes
Methods
class mi.framework.Note[source]#
property id#

ユーザーのID

Returns

ユーザーのID

Return type

str

property action#

ノートに対するアクション

Return type

NoteActions

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

emoji_count()[source]#

ノートの本文にemojiが何個含まれているかを返します

Returns

含まれている絵文字の数

Return type

int

user#

Methods
class mi.framework.User[source]#
await get_profile()[source]#

ユーザーのプロフィールを取得します

Returns

ユーザーのプロフィールオブジェクト

Return type

User

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#

Methods
class mi.framework.Chat[source]#

chat object

await delete()[source]#

Delete the chat (you must be the author of the chat)

Returns

Successful or not.

Return type

bool

emoji#

class mi.framework.Emoji[source]#

Renote#

Methods
class mi.framework.Renote[source]#
emoji_count()[source]#

ノートの本文にemojiが何個含まれているかを返します

Returns

含まれている絵文字の数

Return type

int

follow#

Methods
class mi.framework.Follow[source]#
await follow()[source]#

ユーザーをフォローします :returns: * bool – 成功ならTrue, 失敗ならFalse

  • str – Error code when execution fails.

await unfollow(user_id=None)[source]#

Unfollows the user with the given ID

Parameters

user_id (Optional[str] = None) – ID of the user you want to unfollow

Returns

成功ならTrue, 失敗ならFalse

Return type

status

Properties#

class mi.framework.Properties[source]#

file#

class mi.framework.File[source]#

reaction#

class mi.framework.Reaction[source]#

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

author#
Type

RawUser

content#
Type

Optional[str]

cw#
Type

Optional[str]

renote#
Type

Optional[RawRenote]

visibility#
Type

Optional[str]

renote_count#
Type

Optional[int]

replies_count#
Type

Optional[int]

reactions#
Type

Optional[Dict[str, Any]]

emojis#
Type

List[RawEmoji]

file_ids#
Type

Optional[List[str]]

files#
Type

List[RawFile]

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

author#

user who created the chat

Type

RawUser

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#

Attributes
class mi.wrapper.models.RawProperties[source]#
width#

ファイルの幅

Type

int

height#

ファイルの高さ

Type

int

avg_color#

ファイルの平均色

Type

Optional[str]

RawFolder#

class mi.wrapper.models.RawFolder[source]#
id#

フォルダーのID

Type

str

created_at#

フォルダーの作成された日時

Type

datetime

name#

フォルダーの名前

Type

str

folders_count#

# TODO: 調査

Type

Optional[int]

parent_id#

親フォルダーのID

Type

str

parent#

親フォルダー

Type

Optional[Dict[str, Any]]

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

folder#

親フォルダの情報? # TODO: 調査

Type

Optional[RawFolder]

user_id#

ファイル作成者のID

Type

str

user#

ファイル作成者の情報

Type

Dict[str, Any]

RawEmoji#

class mi.wrapper.models.RawEmoji[source]#
id#

絵文字のID

Type

Optional[str]

aliases#

絵文字のエイリアス

Type

Optional[List[str]]

name#

絵文字の名前

Type

Optional[str]

category#

絵文字のカテゴリ

Type

Optional[str]

host#

絵文字のホスト

Type

Optional[str]

url#

絵文字のURL

Type

Optional[str]

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

user#
Type

RawUser

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#

Attributes
class mi.wrapper.models.RawPollChoices[source]#
text#

アンケートの項目名

Type

str

votes#

投票数

Type

int

is_voted#

投票済みか否か

Type

bool

RawNoteReaction#

Attributes
class mi.wrapper.models.RawNoteReaction[source]#
id#

TODO: 調査

Type

str

created_at#

リアクションが付けられた時間

Type

datetime

user#

リアクションを付けたユーザー

Type

UserPayload

reaction#
Type

str

RawUserDetails#

class mi.wrapper.models.RawUserDetails[source]#

ユーザー情報だが、一般的に使うか怪しいもの

avatar_blurhash#

ユーザーのアバターのblurhash

Type

Optional[str]

avatar_color#

ユーザーのアバターの色

Type

str

lang#

ユーザーの言語

Type

str

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#

Attributes
Methods
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

Note

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

Note

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

Note

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#

class mi.actions.AdminActions[source]#

FolderActions#

class mi.actions.FolderActions[source]#

DriveActions#

class mi.actions.DriveActions[source]#

UserActions#

Methods
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

User

get_mention(user=None)[source]#

Get mention name of user.

Parameters

user (Optional[User], default=None) – メンションを取得したいユーザーのオブジェクト

Returns

メンション

Return type

str

型クラス#

ChatPayload#

class mi.types.ChatPayload[source]#

PropertiesPayload#

class mi.types.PropertiesPayload[source]#

プロパティー情報

FolderPayload#

class mi.types.FolderPayload[source]#

フォルダーの情報

FilePayload#

class mi.types.FilePayload[source]#

ファイル情報

EmojiPayload#

class mi.types.EmojiPayload[source]#

FeaturesPayload#

class mi.types.FeaturesPayload[source]#

OptionalMeta#

class mi.types.OptionalMeta[source]#

MetaPayload#

class mi.types.MetaPayload[source]#

OptionalInstance#

class mi.types.OptionalInstance[source]#

InstancePayload#

class mi.types.InstancePayload[source]#

GeoPayload#

class mi.types.GeoPayload[source]#

衛星情報

PollPayload#

class mi.types.PollPayload[source]#

アンケート情報

RenotePayload#

class mi.types.RenotePayload[source]#

NotePayload#

class mi.types.NotePayload[source]#

note object

OptionalReaction#

class mi.types.OptionalReaction[source]#

ReactionPayload#

class mi.types.ReactionPayload[source]#

NoteReactionPayload#

class mi.types.NoteReactionPayload[source]#

ChannelPayload#

class mi.types.ChannelPayload[source]#

PinnedNotePayload#

class mi.types.PinnedNotePayload[source]#

PinnedPagePayload#

class mi.types.PinnedPagePayload[source]#

FieldContentPayload#

class mi.types.FieldContentPayload[source]#

OptionalUser#

class mi.types.OptionalUser[source]#

UserPayload#

class mi.types.UserPayload[source]#

exception handling#

NotFoundError#

class mi.NotFoundError[source]#

Exception when a 404 is returned on http access

TaskNotRunningError#

class mi.TaskNotRunningError[source]#

Exception thrown when attempting to stop a task and the task is not started.

ImAi#

class mi.ImAi[source]#

I’m Indigo.

InternalServerError#

class mi.InternalServerError[source]#

Exception when 500 is returned on http access

ClientError#

class mi.ClientError[source]#

Exception when http access returns 400

AuthenticationError#

class mi.AuthenticationError[source]#

Exceptions in case of authentication problems

NotExistRequiredParameters#

class mi.NotExistRequiredParameters[source]#

Exception when a required parameter does not exist

InvalidParameters#

class mi.InvalidParameters[source]#

Parameter is invalid

CredentialRequired#

class mi.CredentialRequired[source]#

Authentication information is missing.

ContentRequired#

class mi.ContentRequired[source]#

Not enough content to send

CogNameDuplicate#

class mi.CogNameDuplicate[source]#

Duplicate cog names.

ExtensionAlreadyLoaded#

class mi.ExtensionAlreadyLoaded[source]#

cog is already loaded.

ExtensionFailed#

class mi.ExtensionFailed[source]#

Errors around cog

NoEntryPointError#

class mi.NoEntryPointError[source]#

Exception when cog does not have a setup function

ExtensionNotFound#

class mi.ExtensionNotFound[source]#

Exception if cog does not exist in the specified path

CommandRegistrationError#

class mi.CommandRegistrationError[source]#

Error in command registration

CommandError#

class mi.CommandError[source]#

Exception when a problem occurs with the command

CommandInvokeError#

class mi.CommandInvokeError[source]#

Exceptions when there is a problem executing the command

CheckFailure#

class mi.CheckFailure[source]#

Exception when the command fails to check if it is executable

InvalidCogPath#

class mi.InvalidCogPath[source]#

Incorrect path for cog

NotExistRequiredData#

class mi.NotExistRequiredData[source]#

Exception raised when the required data does not exist.

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_unfollow(message)[source]#

フォローを解除した際のイベントを解析する関数

parse_signin(message)[source]#

ログインが発生した際のイベント

parse_receive_follow_request(message)[source]#

フォローリクエストを受け取った際のイベントを解析する関数

parse_reply(message)[source]#

リプライ

parse_follow(message)[source]#

ユーザーをフォローした際のイベントを解析する関数

parse_followed(message)[source]#

フォローイベントを解析する関数

parse_mention(message)[source]#

メンションイベントを解析する関数

parse_messaging_message(message)[source]#

チャットが来た際のデータを処理する関数

parse_unread_messaging_message(message)[source]#

チャットが既読になっていない場合のデータを処理する関数

parse_notification(message)[source]#

通知イベントを解析する関数

Parameters

message (Dict[str, Any]) – Received message

parse_unread_notification(message)[source]#

未読の通知を解析する関数

Parameters

message (Dict[str, Any]) – Received message

parse_reaction(message)[source]#

リアクションに関する情報を解析する関数

parse_note(message)[source]#

ノートイベントを解析する関数

Low-Layer API#

class mi.framework.MisskeyClientWebSocketResponse[source]#
class mi.framework.MisskeyWebSocket[source]#
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]

ユーティリティ関数#

get_emoji_list#

emoji_count#

mi.utils.emoji_count(text=None, emojis=None)[source]#

テキストの中にいくつのemojiが含まれているかをカウントします

Parameters
  • text

  • emojis

check_multi_arg#