kbotify
Version:
kaiheila bot framework
69 lines (68 loc) • 2.82 kB
TypeScript
import { MessageCreateResponseInternal } from 'kaiheila-bot-root/dist/api/message/message.types';
import { KBotify } from '../..';
import { ButtonEventMessage, TextMessage } from '../message';
import { GuildSession, PrivateSession, BaseSession } from '../session';
import { BaseCommand, ResultTypes, CommandTypes } from '../types';
import { AppFunc, FuncResult } from './types';
import { MenuCommand } from './command.menu';
export declare function initFuncResult<T>(data: T, resultType?: ResultTypes, msgSent?: MessageCreateResponseInternal): FuncResult;
/**
* Class of functional command.
* you need to initialize code, trigger, help, func for proper usage.
* Please return ResultTypes.HELP if you need to show the help message. AppCommand.exec will handle this.
*
* @export
* @class AppCommand
* @param code 功能代号
* @param trigger 触发功能可用的字符串
* @param help 功能提示/帮助文字
* @param intro 功能简介,用于生成菜单
* @param func 负责执行功能
* @param [messageSender] 负责发送消息
* @template T
*/
export declare abstract class AppCommand implements BaseCommand {
code: string;
/**
* 命令响应:仅响应频道,仅响应私聊,全部响应
*/
response: 'guild' | 'private' | 'both';
/**
* 默认的触发命令,如果有上级菜单需要先触发菜单
*/
/**
* 帮助文字,发送`.命令 帮助`时自动回复,kmarkdown消息
*/
help: string;
/**
* 命令介绍,自动生成菜单时调用
*/
intro: string;
client: KBotify | undefined;
/**
* 接受的消息类型,默认为Button和Text,如有需要可以更改
*
* @memberof AppCommand
*/
acceptMessageType: (typeof TextMessage | typeof ButtonEventMessage)[];
parent: MenuCommand | null;
readonly type = CommandTypes.APP;
abstract trigger: string;
get _botInstance(): KBotify | undefined;
constructor();
func: AppFunc<BaseSession | GuildSession>;
init: (bot: KBotify) => void;
exec(command: string, args: string[], msg: any): Promise<ResultTypes | void>;
exec(session: BaseSession | GuildSession | PrivateSession): Promise<ResultTypes | void>;
/**
* return true if check passed
*
* @param {(BaseSession | string)} sessionOrCommand
* @param {(TextMessage | ButtonEventMessage)} [msg]
* @memberof AppCommand
*/
checkInput: (sessionOrCommand: BaseSession | string, msg?: TextMessage | ButtonEventMessage | undefined) => Promise<boolean>;
createSession: (sessionOrCommand: BaseSession | string, args?: string[] | undefined, msg?: TextMessage | ButtonEventMessage | undefined, client?: KBotify | undefined) => Promise<BaseSession | GuildSession | PrivateSession>;
private run;
}
export {};