mirror of
https://github.com/syuilo/ai.git
synced 2024-11-13 01:17:58 +00:00
31 lines
649 B
TypeScript
31 lines
649 B
TypeScript
import autobind from 'autobind-decorator';
|
|
import 藍, { InstallerResult } from './ai';
|
|
|
|
export default abstract class Module {
|
|
public abstract readonly name: string;
|
|
|
|
protected ai: 藍;
|
|
|
|
constructor(ai: 藍) {
|
|
this.ai = ai;
|
|
this.ai.modules.push(this);
|
|
}
|
|
|
|
public abstract install(): InstallerResult;
|
|
|
|
@autobind
|
|
protected log(msg: string) {
|
|
this.ai.log(`[module ${this.name}]: ${msg}`);
|
|
}
|
|
|
|
@autobind
|
|
protected subscribeReply(key: string, isDm: boolean, id: string, data?: any) {
|
|
this.ai.subscribeReply(this, key, isDm, id, data);
|
|
}
|
|
|
|
@autobind
|
|
protected unsubscribeReply(key: string) {
|
|
this.ai.unsubscribeReply(this, key);
|
|
}
|
|
}
|