Class MiraiApiHttp

Constructors

Properties

axios: AxiosStatic
command: Command
file: File
http: {
    address: string;
} = ...

http adapter

Type declaration

  • address: string
logger: ConsolaInstance = ...
mirai: Mirai
qq: number = 0
resp: Resp
sessionKey: string = ''
verified: boolean = false
ws: {
    address: string;
    client?: WebSocket;
    sessionKey: string;
} = ...

WebSocket SessionKey

Type declaration

  • address: string
  • Optional client?: WebSocket
  • sessionKey: string

Methods

  • 监听该接口,插件将推送 Bot 收到的消息和事件

    Parameters

    • callback: ((data) => any)

      回调函数

    Returns void

  • 监听该接口,插件将推送 Bot 收到的事件

    Parameters

    • callback: ((event) => any)

      回调函数

        • (event): any
        • Parameters

          Returns any

    Returns void

  • 使用此方法获取 bot 接收到的最新消息和最新各类事件(会从 MiraiApiHttp 消息记录中删除)

    Parameters

    • count: number = 10

      获取消息和事件的数量

    Returns Promise<FetchMessage>

  • 使用此方法获取 bot 接收到的最老消息和最老各类事件(会从 MiraiApiHttp 消息记录中删除)

    Parameters

    • count: number = 10

      获取消息和事件的数量

    Returns Promise<FetchMessage>

    Example

    { code: 0, data: [] }
    
  • 移除群成员

    Parameters

    • target: number

      指定群的群号

    • memberId: number

      指定群员QQ号

    • msg: string = '您已被移出群聊'

      信息

    Returns Promise<BaseResponse>

  • 监听该接口,插件将推送 Bot 收到的消息

    Parameters

    • callback: ((msg) => any)

      回调函数

    Returns void

  • 指定群禁言指定群员

    Parameters

    • target: number

      指定群的群号

    • memberId: number

      指定群员QQ号

    • time: number = 60

      禁言时长,单位为秒,最多30天,默认为 60 秒

    Returns Promise<BaseResponse>

  • 使用此方法获取 bot 接收到的最老消息和最老各类事件(不会从 MiraiApiHttp 消息记录中删除)

    Parameters

    • count: number = 10

      获取消息和事件的数量

    Returns Promise<FetchMessage>

  • 使用此方法获取 bot 接收到的最老消息和最老各类事件(不会从 MiraiApiHttp 消息记录中删除)

    Parameters

    • count: number = 10

      获取消息和事件的数量

    Returns Promise<FetchMessage>

  • 撤回消息 使用此方法撤回指定消息。对于bot发送的消息,有2分钟时间限制。对于撤回群聊中群员的消息,需要有相应权限

    Parameters

    • params: ChatMessage | RecallParams

      { messageId, target }

    Returns Promise<BaseResponse>

    Desc

    mirai 更新强制需要 messageId + target

  • 使用此方式释放 session 及其相关资源(Bot不会被释放) 不使用的 Session 应当被释放,长时间(30分钟)未使用的 Session 将自动释放。 否则 Session 持续保存Bot收到的消息,将会导致内存泄露(开启websocket后将不会自动释放)

    Parameters

    • qq: number = ...

    Returns Promise<BaseResponse>

  • 使用此方法向指定好友发送消息

    Parameters

    • messageChain: string | MessageChain

      消息链,是一个消息对象构成的数组

    • target: number

      发送消息目标好友的 QQ 号

    • Optional quote: number

      引用一条消息的messageId进行回复

    Returns Promise<Api.Response.SendMessage>

    messageId 一个Int类型属性,标识本条消息,用于撤回和引用回复

  • 使用此方法向指定群发送消息

    Parameters

    • messageChain: string | MessageChain

      消息链,是一个消息对象构成的数组

    • target: number

      发送消息目标群的群号

    • Optional quote: number

      引用一条消息的messageId进行回复

    Returns Promise<Api.Response.SendMessage>

    messageId 一个Int类型属性,标识本条消息,用于撤回和引用回复

  • 使用此方法向指定对象(群或好友)发送图片消息 除非需要通过此手段获取imageId,否则不推荐使用该接口

    Parameters

    • urls: string[]

      是一个url字符串构成的数组

    • Optional target: number

      发送对象的QQ号或群号,可能存在歧义

    • Optional qq: number

      发送对象的QQ号

    • Optional group: number

      发送对象的群号

    Returns Promise<string[]>

  • 戳一戳

    Parameters

    • target: number

      戳一戳的目标, QQ号, 可以为 bot QQ号

    • subject: number

      戳一戳接受主体(上下文), 戳一戳信息会发送至该主体, 为群号/好友QQ号

    • kind: "Friend" | "Group" | "Stranger" = 'Group'

      上下文类型

    Returns Promise<BaseResponse>

  • 文件上传

    Parameters

    • type: "Group"

      当前仅支持 "Group"

    • target: number

      指定群的群号

    • path: string

      文件上传目录与名字

    • file: File

      文件内容

    Returns Promise<any>

  • 使用此方法上传语音文件至服务器并返回 VoiceId

    Parameters

    • type: "friend" | "group" | "temp"

      当前仅支持 "group"

    • voice: File

      语音文件 fs.createReadStream(voice)

    Returns Promise<UploadVoice>

  • 使用此方法验证你的身份,并返回一个会话

    Parameters

    • verifyKey: string = ...

    Returns Promise<Auth>

Generated using TypeDoc