import { MessageStream } from '../classes/session'; import { IMessage } from '../classes/receiver'; import { Sender, ISendResult } from '../classes/sender'; import { ICQCode } from '../classes/cqcode'; import { When } from '../classes/when'; import { TExtensibleMessage } from './definitions'; import { ICommandArguments } from '../classes/command'; export declare let sessionCount: number; /** * Initialize with default session timout * @param sessionTimeout the default session timeout */ export declare function init(sessionTimeout: number): void; /** Contexts that'll be passed into essions */ export interface ISessionContext { /** The first context */ init: { raw?: TExtensibleMessage; command?: ICommandArguments; contain?: string[] & RegExpMatchArray; }; /** Sender bound to this.init.raw */ sender: Sender; /** Stream of messages */ stream: MessageStream; /** Get a copy of the next message from this.stream */ get(condition?: (ctx: IMessage) => boolean): Promise; /** Reply to user */ reply(...message: (string | ICQCode)[]): Promise; /** Question user and get an answer */ question(...prompt: (string | ICQCode)[]): Promise; /** Forward to other sessions */ forward(...message: (string | ICQCode)[]): Promise; /** Reset the stream deletion timeout */ timeout: number; } /** * Use a session template * @param when when to start the session * @param params Another info of the session template */ export declare function use(when: When, { override, identifier, concurrent }?: { override?: boolean; identifier?: string; concurrent?: boolean; }): (session: (ctx: ISessionContext) => void) => void; /** * Create a new session manager * @param name the session manager's name * @param identifier the session manager's identifier */ export declare function create(name: string, identifier: (ctx: IMessage) => any): void; /** * Pass a context through the sessions * @param ctx the context */ export declare function run(ctx: TExtensibleMessage): Promise;