onebots
Version:
基于icqq的多例oneBot实现
79 lines (78 loc) • 4.14 kB
TypeScript
import { EventEmitter } from "events";
import { App } from "./server/app";
import { OneBot } from "./onebot";
import { Dict } from "@zhinjs/shared";
import { Logger } from "log4js";
import { V11 } from "./service/V11";
export declare abstract class Adapter<T extends string = string, Sendable = any> extends EventEmitter {
#private;
app: App;
platform: T;
config: Adapter.Configs[T];
oneBots: Map<string, OneBot>;
icon: string;
protected constructor(app: App, platform: T, config: Adapter.Configs[T]);
materialize(content: string): string;
toCqcode<V extends OneBot.Version>(version: V, messageArr: OneBot.Segment<V>[]): string;
fromCqcode<V extends OneBot.Version>(version: V, message: string): OneBot.Segment<V>[];
transformMessage(uin: string, version: OneBot.Version, message: any): string | (import("./service/V12").V12.Segment | V11.Segment)[];
getOneBot<C = any>(uin: string): OneBot<C> | undefined;
get logger(): Logger;
get info(): {
platform: T;
config: Adapter.Configs[T];
icon: string;
bots: {
uin: string;
status: import("./onebot").OneBotStatus;
platform: string;
avatar: string;
nickname: string;
dependency: string;
urls: string[];
}[];
};
setOnline(uin: string): Promise<void>;
setOffline(uin: string): Promise<void>;
getLogger(uin: string, version?: string): Logger;
createOneBot<T = any>(uin: string, protocol: Dict, versions: OneBot.Config[]): OneBot<T>;
start(uin?: string): Promise<any>;
stop(uin?: string, force?: boolean): Promise<any>;
}
export interface Adapter<T extends string = string, Sendable = any> extends Adapter.Base<Sendable> {
call<V extends OneBot.Version>(uin: string, version: V, method: string, args?: any[]): Promise<any>;
}
export declare namespace Adapter {
interface Base<Sendable = any> {
toSegment<V extends OneBot.Version>(version: V, message: Sendable): OneBot.Segment<V>[];
fromSegment<V extends OneBot.Version>(onebot: OneBot, version: V, segment: OneBot.Segment<V>[]): Sendable;
getSelfInfo<V extends OneBot.Version>(uin: string, version: V): OneBot.SelfInfo<V>;
/** 格式化事件 */
formatEventPayload<V extends OneBot.Version>(uin: string, version: V, event: string, payload: Dict): OneBot.Payload<V>;
/** 解析消息事件的消息 */
parseMessage<V extends OneBot.Version>(version: V, payload: Dict): OneBot.Message<V>[];
/** 获取群列表 */
getGroupList<V extends OneBot.Version>(uin: string, version: V): Promise<OneBot.GroupInfo<V>[]>;
/** 获取好友列表 */
getFriendList<V extends OneBot.Version>(uin: string, version: V): Promise<OneBot.UserInfo<V>[]>;
getGroupMemberList<V extends OneBot.Version>(uin: string, version: V, args: [string]): Promise<OneBot.GroupMemberInfo<V>[]>;
/** 发送群消息 */
sendGroupMessage<V extends OneBot.Version>(uin: string, version: V, args: [string, Sendable, string]): Promise<OneBot.MessageRet<V>>;
/** 发送私聊消息 */
sendPrivateMessage<V extends OneBot.Version>(uin: string, version: V, args: [string, Sendable, string]): Promise<OneBot.MessageRet<V>>;
sendGuildMessage<V extends OneBot.Version>(uin: string, version: V, args: [string, string, Sendable, string]): Promise<OneBot.MessageRet<V>>;
/** 发送私聊消息 */
sendDirectMessage<V extends OneBot.Version>(uin: string, version: V, args: [string, Sendable, string]): Promise<OneBot.MessageRet<V>>;
/** 获取消息 */
getMessage<V extends OneBot.Version>(uin: string, version: V, args: [string]): Promise<OneBot.Message<V>>;
deleteMessage<V extends OneBot.Version>(uin: string, version: V, args: [string]): Promise<boolean>;
}
interface Configs {
[key: string]: Adapter.Config;
}
type Config<T extends string = string> = {
platform?: T;
versions: OneBot.Config<OneBot.Version>[];
protocol?: Dict;
} & Record<string, any>;
}