heybox-bot
Version:
A heybox chat bot frame
118 lines • 3.19 kB
TypeScript
import { HeyBoxBot } from '../index';
import { AxiosInstance } from 'axios';
import { ILogger, Message, UserMessage } from '../type';
import { Logger } from 'winston';
/**
* HeyboxBot运行时上下文类,用于存储和提供全局的Bot实例和Logger实例
*/
export declare class HeyboxBotRuntimeContext {
private static bot?;
private static logger?;
/**
* 获取Bot实例
* @returns {HeyBoxBot} Bot实例
* @throws {Error} 如果Bot未初始化
*/
static getBot(): HeyBoxBot;
/**
* 设置Bot实例
* @param {HeyBoxBot} bot Bot实例
*/
static setBot(bot: HeyBoxBot): void;
/**
* 获取Logger实例
* @returns {Logger} Logger实例
* @throws {Error} 如果Logger未初始化
*/
static getLogger(): Logger;
/**
* 设置Logger实例
* @param {Logger} logger Logger实例
*/
static setLogger(logger: Logger): void;
}
/**
* 工具类,提供日志记录、获取确认ID、获取代理配置和字符串哈希功能
*/
export declare class Util {
private static ackID;
static log: ILogger;
/**
* 获取确认ID
* @returns {number} 确认ID
*/
static getAckId(): number;
/**
* 获取代理配置
* @returns 代理配置对象或未定义
*/
static getProxy(): {
host: string;
port: number;
protocol: 'http' | 'https';
} | undefined;
/**
* 使用DJB2算法计算字符串哈希值
* @param {string} str 输入字符串
* @returns {number} 哈希值
*/
static hashDJB2(str: string): number;
}
/**
* 请求类,处理与服务器的HTTP交互
*/
export declare class Request {
static readonly BASE_URL: string;
private static instance?;
static getInstance(): AxiosInstance;
/**
* 发送消息
* @param {Message} payload 消息负载
*/
static sendMessage(payload: Message): Promise<void>;
/**
* 发送用户消息
* @param {UserMessage} payload 用户消息负载
*/
static sendUserMessage(payload: UserMessage): Promise<void>;
/**
* 上传文件
* @param {BufferSource | string} file 文件内容或文件路径
* @returns {Promise<string>} 上传后的文件URL
*/
static uploadFile(file: BufferSource | string): Promise<string>;
/**
* 同步方式上传文件
* @param {BufferSource | string} file 文件内容或文件路径
* @returns {string} 上传后的文件URL
*/
static uploadFileSync(file: BufferSource | string): string;
}
/**
* 基于种子的随机数生成器类
*/
export declare class SeededRandom {
seed: number;
m: number;
a: number;
c: number;
state: number;
/**
* 构造函数
* @param {number} seed 种子
*/
constructor(seed: number);
/**
* 生成下一个随机数
* @returns {number} 随机数
*/
next(): number;
/**
* 生成下一个整数
* @param {number} min 最小值
* @param {number} max 最大值
* @returns {number} 随机整数
*/
nextInt(min: number, max: number): number;
}
//# sourceMappingURL=index.d.ts.map