UNPKG

koishi-plugin-koishiaimix

Version:

基于AiHubMix API的AI对话和绘图插件,支持多种AI模型的聊天对话和图像生成功能,现已支持xAI Grok绘图

87 lines (86 loc) 2.06 kB
import { Session } from 'koishi'; /** * 工具函数集合 */ export declare class Utils { /** * 从消息中提取图片URL */ static extractImageUrls(session: Session): string[]; /** * 清理文本内容,移除HTML标签和特殊字符 */ static cleanText(text: string): string; /** * 截断文本到指定长度 */ static truncateText(text: string, maxLength: number): string; /** * 格式化错误消息 */ static formatError(error: any): string; /** * 验证API密钥格式 */ static validateApiKey(apiKey: string): boolean; /** * 验证xAI API密钥格式 */ static validateXAIApiKey(apiKey: string): boolean; /** * 生成随机ID */ static generateId(): string; /** * 延迟执行 */ static delay(ms: number): Promise<void>; /** * 重试执行函数 */ static retry<T>(fn: () => Promise<T>, maxRetries?: number, delayMs?: number): Promise<T>; /** * 解析命令参数 */ static parseArgs(input: string): { command: string; args: string[]; options: Record<string, string>; }; /** * 格式化文件大小 */ static formatFileSize(bytes: number): string; /** * 格式化时间间隔 */ static formatDuration(ms: number): string; /** * 检查URL是否有效 */ static isValidUrl(url: string): boolean; /** * 获取文件扩展名 */ static getFileExtension(filename: string): string; /** * 检查是否为图片文件 */ static isImageFile(filename: string): boolean; /** * 转义HTML字符 */ static escapeHtml(text: string): string; /** * 创建进度条 */ static createProgressBar(current: number, total: number, width?: number): string; /** * 生成帮助文本 */ static generateHelpText(commands: Array<{ name: string; description: string; usage?: string; }>): string; }