import { Config } from "./config";
import { OneBot } from "../../onebot";
import { Action } from "./action";
import { Logger } from "log4js";
import { WebSocket, WebSocketServer } from "ws";
import { Service } from "../../service";
import { App } from "../../server/app";
import { Dict } from "@zhinjs/shared";
export declare class V12 extends Service<"V12"> implements OneBot.Base {
    oneBot: OneBot;
    config: OneBot.Config<"V12">;
    version: OneBot.Version;
    action: Action;
    protected timestamp: number;
    protected heartbeat?: NodeJS.Timeout;
    logger: Logger;
    app: App;
    wss?: WebSocketServer;
    wsr: Set<WebSocket>;
    private db;
    constructor(oneBot: OneBot, config: OneBot.Config<"V12">);
    addHistory(payload: V12.Payload<keyof Action>): number;
    shiftHistory(): unknown;
    get history(): V12.Payload<keyof Action>[];
    getFile(file_id: string): V12.FileInfo;
    delFile(file_id: string): boolean;
    saveFile(fileInfo: V12.FileInfo): string;
    get files(): ({
        file_id: string;
    } & V12.FileInfo)[];
    set history(value: any[]);
    start(): void;
    private startHttp;
    private startWebhook;
    private runActions;
    private startWs;
    private startWsReverse;
    stop(force?: boolean): Promise<void>;
    format<E extends keyof V12.BotEventMap>(event: E, ...args: [V12.BotEventMap[E]]): {
        self_id: string;
        time: number;
        detail_type: E;
        type: string;
        sub_type: string;
    } & Omit<V12.BotEventMap[E], E> & {
        group: any;
        friend: any;
        member: any;
    };
    system_online(data: any): void;
    dispatch(data: Record<string, any>): Promise<void>;
    transformMedia(segment: V12.Segment): V12.Segment;
    apply(req: V12.RequestAction): Promise<string>;
    private httpAuth;
    private httpRequestHandler;
    private _httpRequestHandler;
    /**
     * 快速操作
     */
    protected _quickOperate(event: any, res: any): void;
    /**
     * 创建反向ws
     */
    protected _createWsr(url: string, config: V12.WsReverseConfig): void;
    /**
     * 处理ws消息
     */
    protected _webSocketHandler(ws: WebSocket): void;
}
export declare namespace V12 {
    interface Config {
        heartbeat?: number;
        access_token?: string;
        request_timeout?: number;
        reconnect_interval?: number;
        enable_cors?: boolean;
        enable_reissue?: boolean;
        use_http?: boolean | HttpConfig;
        webhook?: (string | WebhookConfig)[];
        use_ws?: boolean | WsConfig;
        ws_reverse?: (string | WsReverseConfig)[];
    }
    interface HttpConfig extends Config.AuthInfo, Config.EventBufferConfig {
    }
    interface WebhookConfig extends Config.AuthInfo {
        url: string;
        timeout?: number;
        get_latest_actions?: boolean | string | {
            path?: string;
            interval: number;
        };
    }
    interface WsConfig extends Config.AuthInfo {
    }
    interface WsReverseConfig extends Config.AuthInfo {
        url: string;
    }
    interface Result<T extends any> {
        status: "ok" | "failed";
        retcode: 0 | 10001 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007;
        data: T;
        message: string;
        echo?: string;
    }
    const defaultConfig: Config;
    type Payload<T = Dict> = {
        id: string;
        impl: "onebots";
        version: 12;
        platform: string;
        self: {
            platform: string;
            user_id: string;
        };
        time: number;
        type: "meta" | "message" | "notice" | "request";
        detail_type: string;
        sub_type: string;
    } & T;
    type SelfInfo = {
        nickname?: string;
    };
    interface Protocol {
        action: string;
        params: any;
        echo?: string;
    }
    type BotEventMap = {
        system: Record<string, any>;
        connect: {
            type: any;
            detail_type: "connect";
            version: ReturnType<Action["getVersion"]>;
        };
        heartbeat: {
            detail_type: "heartbeat";
            status: ReturnType<Action["getStatus"]>;
            interval: number;
        };
        status_update: {
            detail_type: "status_update";
            status: ReturnType<Action["getStatus"]>;
        };
    };
    function success<T extends any>(data: T, retcode?: Result<T>["retcode"], echo?: string): Result<T>;
    function error(message: string, retcode?: Result<null>["retcode"], echo?: string): Result<null>;
    function formatPayload<K extends keyof BotEventMap>(uin: string, type: K, data: Omit<BotEventMap[K], K>): {
        self_id: string;
        time: number;
        detail_type: K;
        type: string;
        sub_type: string;
    } & Omit<BotEventMap[K], K> & {
        group: any;
        friend: any;
        member: any;
    };
    type RequestAction = {
        action: string;
        params: Record<string, any>;
        echo?: number;
    };
    type FileInfo = {
        type: "url" | "path" | "data";
        name: string;
        url?: string;
        headers?: Record<string, any>;
        path?: string;
        data?: string;
        sha256?: string;
        total_size?: number;
    };
    interface GroupInfo {
        group_id: string;
        group_name: string;
    }
    interface UserInfo {
        user_id: string;
        user_name: string;
    }
    interface GroupMemberInfo {
        group_id: string;
        user_id: string;
        user_name: string;
    }
    interface Segment {
        type: string;
        data: Dict;
    }
    type Sendable = string | Segment | (string | Segment)[];
    interface Message {
        message: Sendable;
    }
    type MessageNode = {
        content: Sendable;
    } & ({
        uin: number;
        user_id: never;
        name: string;
        nickname: never;
    } | {
        user_id: number;
        uin: never;
        nickname: string;
        name: never;
    });
    interface Message {
    }
    interface MessageRet {
        message_id: string;
    }
}
