koishi-plugin-adapter-iirose
Version:
[IIROSE-蔷薇花园](https://iirose.com/)适配器
94 lines (93 loc) • 3.7 kB
TypeScript
import { Context } from 'koishi';
import { IIROSE_Bot } from '../bot/bot';
/**
* 颜色转换函数:将rgba格式转换为十六进制格式
* @param rgba - rgba格式的颜色字符串或十六进制格式的颜色字符串
* @returns 六位十六进制格式的颜色字符串(不包含#)
*/
export declare function rgbaToHex(rgba: string): string;
/**
* 生成消息ID
* @returns 12位随机字符串作为消息ID
*/
export declare function generateMessageId(): string;
/**
* 解析用户头像URL
* @param avatar 原始头像字符串
* @returns {string} 完整的头像URL
*/
export declare const parseAvatar: (avatar: string) => string;
export declare const startEventsServer: (bot: IIROSE_Bot) => (() => boolean)[];
export declare const stopEventsServer: (event: (() => boolean)[]) => void;
/**
* 将数据写入到 wsdata 目录下的指定 JSON 文件中
* @param bot IIROSE_Bot 实例
* @param relativePath 文件路径 (例如 'wsdata/userlist.json')
* @param data 要写入的数据对象
*/
export declare const writeWJ: (bot: IIROSE_Bot, relativePath: string, data: any) => Promise<void>;
/**
* 从实例的数据目录中安全地读取和解析JSON文件。
* @param bot IIROSE_Bot 实例
* @param filename 相对于实例数据目录的文件路径 (e.g., 'wsdata/userlist.json')
* @returns 解析后的JSON数据,如果文件不存在或解析失败则返回 null
*/
export declare const readJsonData: (bot: IIROSE_Bot, filename: string) => Promise<any>;
/**
* 在嵌套的房间数据中递归查找指定的房间。
* @param guildData 嵌套的房间数据对象
* @param roomId 要查找的房间ID
* @returns 找到的房间信息对象,未找到则返回 null
*/
export declare const findRoomInGuild: (guildData: any, roomId: string) => any;
/**
* 将一个社区(Guild)下的所有层级嵌套的房间扁平化为一个房间列表。
* @param guildData 嵌套的房间数据对象
* @returns 扁平化后的房间信息数组
*/
export declare const flattenRooms: (guildData: any) => any[];
/**
* 根据用户 ID 从 userlist.json 查找用户名
* @param bot IIROSE_Bot 实例
* @param userId 用户 ID
* @returns 匹配的用户名,如果找不到则返回 undefined
*/
export declare const findUserNameById: (bot: IIROSE_Bot, userId: string) => Promise<string | undefined>;
/**
* 根据用户名从 userlist.json 查找用户 ID
* @param bot IIROSE_Bot 实例
* @param username 用户名
* @returns 匹配的用户 ID,如果找不到则返回 undefined
*/
export declare const findUserIdByName: (bot: IIROSE_Bot, username: string) => Promise<string | undefined>;
export declare function getMediaMetadata(url: string, ctx: Context): Promise<{
title: string;
artist: string;
album: string;
duration: number;
bitrate: number;
picture: string | {
format: string;
data: string;
};
}>;
/**
* @description 缓存发出的消息
* @param bot bot实例
* @param channelId 频道id
* @param messageId 消息id
* @param content 消息内容
*/
export declare function cacheSentMessage(bot: IIROSE_Bot, channelId: string, messageId: string, content: string): Promise<void>;
/**
* 确保在添加内容前有换行符
* 用于图文消息里的图片和文字之间的换行
*/
export declare function ensureNewlineBefore(text: string): string;
/**
* 获取图片并将其转换为Base64编码的Data URI
* @param bot IIROSE_Bot 实例
* @param url 图片的URL
* @returns 返回一个Promise,解析为Base64编码的Data URI字符串,或在失败时返回null
*/
export declare function getImageAsBase64(bot: IIROSE_Bot, url: string): Promise<string | null>;