ai/src/module.ts

31 lines
650 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
2019-01-15 01:10:41 +00:00
protected subscribeReply(key: string, isMessage: boolean, id: string, data?: any) {
2019-01-14 15:14:22 +00:00
this.ai.subscribeReply(this, key, isMessage, id, data);
}
@autobind
2019-01-15 01:10:41 +00:00
protected unsubscribeReply(key: string) {
2019-01-14 15:14:22 +00:00
this.ai.unsubscribeReply(this, key);
}
}