UNPKG

miraipie

Version:

the most powerful nodejs development kit for mirai-api-http

256 lines 9.51 kB
import * as Mirai from './mirai'; import { PokeType, SingleMessage, SingleMessageMap, SingleMessageType } from './mirai'; /** 消息链 */ export declare class MessageChain<T extends SingleMessage = SingleMessage> extends Array<SingleMessage> implements Mirai.MessageChain { [index: number]: T; constructor(...args: any[]); /** * 获取消息链中第一个有效消息, 如果没有将返回null * @return 第一个有效消息 * @example * const chain = MessageChain.from([AtAll(), Plain('Hello World!')]); * chain.firstClientMessage; // {type: 'AtAll'} */ get firstClientMessage(): SingleMessage; /** * 获取消息链中第一个有效消息, 如果没有将返回null * @return 第一个有效消息 * @example * const chain = MessageChain.from([AtAll(), Plain('Hello World!')]); * chain.f; // {type: 'AtAll'} */ get f(): SingleMessage; /** * 获取消息链中的消息id, 如果没有将返回null * @return 消息id * @example * const chain = fetchSomeMessages(); // MessageChain(2) [{type: 'Source', id: 123456, time: 123456}, {type: 'AtAll'}] * chain.sourceId; // 123456 */ get sourceId(): number; /** * 获取消息链的消息发送时间, 如果没有将返回null * @return 消息发送时间 * @since 1.2.2 */ get time(): number; /** * <strong>原地</strong>选择保留某类型的单一消息 * @param type 单一消息类型 * @return 消息链 * @example * const chain = MessageChain.from([AtAll(), Plain('Hello '), Plain('World!')]); * // MessageChain(1) [{type: 'AtAll'}] * chain.select('AtAll'); * // MessageChain(1) [{type: 'AtAll'}] * chain; */ select<D extends SingleMessageType>(type: D): this; /** * 选择保留某类型的单一消息并生成<strong>新消息链</strong> * @param type 单一消息类型 * @return 消息链 * @example * const chain = MessageChain.from([AtAll(), Plain('Hello '), Plain('World!')]); * // MessageChain(1) [{type: 'AtAll'}] * chain.selected('AtAll'); * // MessageChain(3) [{type: 'AtAll'}, {type: 'Plain', text: 'Hello '}, {type: 'Plain', text: 'World!'}] * chain; */ selected<D extends SingleMessageType>(type: D): MessageChain<SingleMessageMap[D]>; /** * <strong>原地</strong>删除某类型的单一消息 * @param type 单一消息类型 * @return 消息链 * @example * const chain = MessageChain.from([AtAll(), Plain('Hello '), Plain('World!')]); * // MessageChain(1) [{type: 'AtAll'}] * chain.drop('Plain'); * // MessageChain(1) [{type: 'AtAll'}] * chain; */ drop<D extends SingleMessageType>(type: D): this; /** * 删除某类型的单一消息并生成<strong>新消息链</strong> * @param type 单一消息类型 * @return 消息链 * @example * const chain = MessageChain.from([AtAll(), Plain('Hello '), Plain('World!')]); * // MessageChain(1) [{type: 'AtAll'}] * chain.dropped('Plain'); * // MessageChain(3) [{type: 'AtAll'}, {type: 'Plain', text: 'Hello '}, {type: 'Plain', text: 'World!'}] * chain; */ dropped<D extends SingleMessageType>(type: D): MessageChain<Exclude<SingleMessage, SingleMessageMap[D]>>; /** * 将消息链转化为mirai码表示形式(与mirai-core中的mirai码有差异, 不能混用) * @return mirai码表示形式 * @example * const chain = MessageChain.from([AtAll(), Plain('Hello '), Plain('World!')]); * // "[mirai:atall] Hello World!" * chain.toMiraiCode(); */ toMiraiCode(): string; /** * 将消息链转化为显示串 * @return 消息链的显示串 * @example * const chain = MessageChain.from([AtAll(), Plain('Hello '), Plain('World!')]); * // "@全体成员 Hello World!" * chain.toDisplayString(); */ toDisplayString(): string; /** * 使用单一消息数组构造消息链 * @param messageList 单一消息数组 * @return 消息链 * @example * // MessageChain(1) [{type: 'Plain', text: 'Hello World!'}] * MessageChain.from([Plain('Hello World!')]); * // MessageChain(2) [{type: 'AtAll'}, {type: 'Plain', text: 'Hello World!'}] * MessageChain.from([AtAll(), Plain('Hello World!')]); */ static from(messageList: SingleMessage[]): MessageChain; } /** * 构造引用回复消息 * @param id 引用消息id * @param groupId 群号 * @param senderId 发送人QQ号 * @param origin 接收者账号 * @param targetId 原始消息内容 */ export declare function Quote(id: number, groupId: number, senderId: number, origin: SingleMessage[], targetId?: number): Mirai.Quote; /** * 构造&#64;消息 * @param target 群成员QQ号 * @param display At时显示的文字, 发送消息时无效, 自动使用群名片 */ export declare function At(target: number, display?: string): Mirai.At; /** * 构造&#64;全体成员消息 */ export declare function AtAll(): Mirai.AtAll; /** * 构造表情消息 * @param faceId 表情id * @param name 表情名称(使用时需将 faceId 设置为 undefined) */ export declare function Face(faceId?: Mirai.FaceType | number, name?: string): Mirai.Face; /** * 构造普通文本消息 * @param text 文本内容 */ export declare function Plain(text: string): Mirai.Plain; /** * 构造图片消息 * @param imageId 图片id * @param url 图片链接 * @param path 图片文件路径 * @param base64 图片Base64编码 */ export declare function Image(imageId?: string, url?: string, path?: string, base64?: string): Mirai.Image; declare type ImageOptions = Partial<Omit<Mirai.Image, 'type' | 'isType' | 'toDisplayString' | 'toMiraiCode'>>; /** * 通过对象构造图片消息 * @param options 图片选项 */ export declare function makeImage(options: ImageOptions): Mirai.Image; /** * 构造闪图消息 * @param imageId 图片id * @param url 图片链接 * @param path 图片文件路径 * @param base64 图片Base64编码 */ export declare function FlashImage(imageId?: string, url?: string, path?: string, base64?: string): Mirai.FlashImage; declare type FlashImageOptions = Partial<Omit<Mirai.FlashImage, 'type' | 'isType' | 'toDisplayString' | 'toMiraiCode'>>; /** * 通过对象构造闪图消息 * @param options 闪图选项 */ export declare function makeFlashImage(options: FlashImageOptions): Mirai.FlashImage; /** * 构造语音消息 * @param voiceId 语音id * @param url 语音链接 * @param path 语音文件路径 * @param base64 语音Base64编码 */ export declare function Voice(voiceId?: string, url?: string, path?: string, base64?: string): Mirai.Voice; declare type VoiceOptions = Partial<Omit<Mirai.Voice, 'type' | 'isType' | 'toDisplayString' | 'toMiraiCode'>>; /** * 通过对象构造语音消息 * @param options 语音选项 */ export declare function makeVoice(options: VoiceOptions): Mirai.Voice; /** * 构造XML消息 * @param xml XML内容 */ export declare function Xml(xml: string): Mirai.Xml; /** * 构造JSON消息 * @param json JSON内容 */ export declare function Json(json: string): Mirai.Json; /** * 构造小程序消息(手动构造的一般无法发送) * @param content 小程序内容(Json格式) */ export declare function App(content: string): Mirai.App; /** * 构造戳一戳消息 * @param name 戳一戳名称 */ export declare function Poke(name: PokeType): Mirai.Poke; /** * 构造骰子消息 * @param value 骰子数值(1~6) */ export declare function Dice(value: number): Mirai.Dice; /** * 构造音乐分享消息 * @param kind 音乐分享类型 * @param title 标题 * @param summary 概括 * @param jumpUrl 跳转链接 * @param pictureUrl 封面图片链接 * @param musicUrl 音乐播放链接 * @param brief 简介 */ export declare function MusicShare(kind: string, title: string, summary: string, jumpUrl: string, pictureUrl: string, musicUrl: string, brief: string): Mirai.MusicShare; declare type MusicShareOptions = Partial<Omit<Mirai.MusicShare, 'type' | 'toDisplayString' | 'toMiraiCode'>>; /** * 通过对象构造音乐分享消息 * @param options 音乐分享选项 */ export declare function makeMusicShare(options: MusicShareOptions): Mirai.MusicShare; /** * 构造转发结点 * @param senderId 发送人QQ号 * @param time 发送时间戳 * @param senderName 发送人名称 * @param messageChain 消息链 * @param messageId 消息id */ export declare function ForwardNode(senderId: number, time: number, senderName: string, messageChain: MessageChain | SingleMessage[], messageId: number): Mirai.ForwardNode; /** * 构造合并转发消息 * @param nodeList 结点列表 */ export declare function Forward(nodeList: Mirai.ForwardNode[]): Mirai.Forward; /** * 构造文件消息 * @param id 文件id * @param name 文件名 * @param size 文件大小 */ export declare function File(id: string, name: string, size: number): Mirai.File; /** * 构造mirai码消息 * @param code mirai码 */ export declare function MiraiCode(code: string): Mirai.MiraiCode; export {}; //# sourceMappingURL=message.d.ts.map