ai/src/module.ts
2019-01-15 18:47:22 +09:00

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);
}
}