ai/src/module.ts

31 lines
644 B
TypeScript
Raw Normal View History

2019-01-14 15:14:22 +00:00
import autobind from 'autobind-decorator';
import , { InstallerResult } from './ai';
export default abstract class Module {
public abstract name: string;
protected ai: ;
constructor(ai: ) {
this.ai = ai;
this.ai.modules.push(this);
}
2019-01-14 15:14:22 +00:00
public abstract install(): InstallerResult;
@autobind
protected log(msg: string) {
this.ai.log(`[module ${this.name}]: ${msg}`);
}
@autobind
public subscribeReply(key: string, isMessage: boolean, id: string, data?: any) {
this.ai.subscribeReply(this, key, isMessage, id, data);
}
@autobind
public unsubscribeReply(key: string) {
this.ai.unsubscribeReply(this, key);
}
}