import type Api from './api';
import type { AdapterConfig, EventDataApiBase } from '../types';
import type Elements from './elements';
import { Session } from './session';
import type { EventsList, Context } from '../app';
type EventApiType = {
[K in keyof EventsList]: EventsList[K] extends EventDataApiBase ? EventsList[K] : never;
};
/** Bot Status */
interface AdapterStatus {
/** Online status */
value: 'online' | 'offline';
/** Bot create time */
createTime: Date;
/** Bot last sending message time, or empty if haven't received message */
lastMsgTime: Date | null;
/** Received message count */
receivedMsg: number;
/** Sent message count */
sentMsg: number;
/** Offline times */
offlineTimes: number;
}
/**
* Platform adapter.
*
* @template A - Api instance of bot bind
* @template C - Adapter config
* @template E - Elements instance of bot bind
*
* @class
* @abstract
*/
export interface AdapterImpl {
/**
* Context instance.
*
* @readonly
*/
readonly ctx: Context;
/**
* Adapter config.
*
* @readonly
*/
readonly config: C;
/**
* Adapter support platform.
*
* @readonly
*/
readonly platform: string;
/**
* Platform id of bot instanceof itself.
*
* @readonly
*/
readonly selfId: string;
/**
* Unique identity of bot.
*
* @readonly
*/
readonly identity: string;
/**
* Api instance of bot bind.
*
* @readonly
*/
readonly api: A;
/**
* Elements instance of bot bind.
*
* @readonly
*/
readonly elements: E;
/**
* Bot status.
*
* @readonly
*/
readonly status: AdapterStatus;
/**
* Handle interactive data from platform.
*
* @param data - Data from platform.
*/
handle(...data: unknown[]): void;
/**
* Start bot.
*/
start(): void;
/**
* Stop bot.
*/
stop(): void;
/**
* Send interactive data to platform.
*
* @param data - Data to send.
*/
send(...data: unknown[]): void;
}
export declare abstract class Adapter implements AdapterImpl {
constructor(ctx: Context, config: C, identity: string);
abstract readonly platform: string;
abstract readonly api: A;
abstract readonly elements: E;
abstract handle(...data: unknown[]): void;
abstract start(): void;
abstract stop(): void;
abstract send(...data: unknown[]): void;
protected online(): void;
protected offline(): void;
protected session(type: N, data: EventApiType[N] extends Session ? U : never): void;
readonly ctx: Context;
readonly config: C;
readonly identity: string;
readonly status: AdapterStatus;
selfId: string;
}
export default Adapter;