ai/src/module.ts

30 lines
619 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 {
2019-01-15 01:26:48 +00:00
public abstract readonly name: string;
2019-01-14 15:14:22 +00:00
protected ai: ;
2019-01-15 17:10:42 +00:00
public init(ai: ) {
2019-01-14 15:14:22 +00:00
this.ai = ai;
}
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 09:47:22 +00:00
protected subscribeReply(key: string, isDm: boolean, id: string, data?: any) {
this.ai.subscribeReply(this, key, isDm, id, data);
2019-01-14 15:14:22 +00:00
}
@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);
}
}