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);
|
|
|
|
}
|
2018-09-18 23:52:06 +00:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|