kbotify
Version:
kaiheila bot framework
81 lines (80 loc) • 2.6 kB
TypeScript
/// <reference types="bunyan" />
import { KaiheilaBot } from 'kaiheila-bot-root';
import { AppCommand, MenuCommand } from '../..';
import { ButtonEventMessage, TextMessage } from '../message';
import { CacheManager } from '../cache/cache.manager';
import { BotConfig, RawEmissions } from './types';
import { MessageProcessor } from './message.ee';
import { EventProcessor } from './event.ee';
import { CollectorManager } from './collector';
import { API } from './api';
export declare interface KBotify {
on<K extends keyof RawEmissions>(event: K, listener: RawEmissions[K]): this;
emit<K extends keyof RawEmissions>(event: K, ...args: Parameters<RawEmissions[K]>): boolean;
}
export declare class KBotify extends KaiheilaBot {
commandMap: Map<string, AppCommand | MenuCommand>;
help: string;
userId: string;
message: MessageProcessor;
event: EventProcessor;
/**
* @deprecated
*
* @type {boolean}
* @memberof KBotify
*/
mentionWithSpace: boolean;
cache: CacheManager;
collectors: CollectorManager;
logger: import("bunyan");
API: API;
/**
* Creates an instance of KBotify.
* @param config the config of bot, please see readme.md
* @param [default_process=true] Deprecated. if you want to process message yourself, please change the KBotify.defaultHandler() method.
* @memberof KBotify
*/
constructor(config: BotConfig & {
debug?: boolean;
}, omit?: boolean);
connect(): void;
defaultHandler(): void;
/**
* Process the msg object and generate [command, ...args]
*
* @param msg
* @return [command, ...args] | void
* @memberof KBotify
*/
processMsg(msg: TextMessage | ButtonEventMessage): string[] | void;
/**
* Add menu/app to this bot.
*
* @param commands array of instances of menu/app command
* @memberof KBotify
*/
addCommands: (...commands: (MenuCommand | AppCommand)[]) => void;
/**
* Add alias for certain menu/app
*
* @param command instance of menu/app command
* @param alias
* @memberof KBotify
*/
addAlias: (command: MenuCommand | AppCommand, ...aliases: string[]) => void;
/**
* Process the command.
*
* @param command
* @param args
* @param msg
* @memberof KBotify
*/
execute: (command: string, args: string[], msg: TextMessage | ButtonEventMessage) => Promise<unknown>;
toJSON(): {
botUserId: string;
mode: "webhook" | "websocket" | "pc";
port: number | undefined;
};
}