ai/src/module.ts

52 lines
1.6 KiB
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) {
2019-01-24 08:47:13 +00:00
this.ai.log(`[${this.name}]: ${msg}`);
2019-01-14 15:14:22 +00:00
}
2019-02-01 16:53:06 +00:00
/**
*
* @param key
* @param isDm
* @param id ID稿ID
* @param data
*/
2019-01-14 15:14:22 +00:00
@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
}
2019-02-01 16:53:06 +00:00
/**
*
* @param key
*/
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);
}
2019-02-01 17:06:51 +00:00
/**
*
*
* @param delay
* @param data
*/
@autobind
public setTimeoutWithPersistence(delay: number, data?: any) {
this.ai.setTimeoutWithPersistence(this, delay, data);
}
2019-01-14 15:14:22 +00:00
}