mirror of
https://github.com/syuilo/ai.git
synced 2024-11-23 21:47:58 +00:00
Compare commits
1 commit
7fe378ca50
...
9ad70138d2
Author | SHA1 | Date | |
---|---|---|---|
9ad70138d2 |
|
@ -54,6 +54,7 @@ export default class 藍 {
|
||||||
private mentionHooks: MentionHook[] = [];
|
private mentionHooks: MentionHook[] = [];
|
||||||
private contextHooks: { [moduleName: string]: ContextHook } = {};
|
private contextHooks: { [moduleName: string]: ContextHook } = {};
|
||||||
private timeoutCallbacks: { [moduleName: string]: TimeoutCallback } = {};
|
private timeoutCallbacks: { [moduleName: string]: TimeoutCallback } = {};
|
||||||
|
public installedModules: { [moduleName: string]: InstalledModule } = {};
|
||||||
public db: loki;
|
public db: loki;
|
||||||
public lastSleepedAt: number;
|
public lastSleepedAt: number;
|
||||||
|
|
||||||
|
|
|
@ -75,16 +75,10 @@ export default abstract class Module {
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
protected getData() {
|
protected getData() {
|
||||||
let doc = this.ai.moduleData.findOne({
|
const doc = this.ai.moduleData.findOne({
|
||||||
module: this.name
|
module: this.name
|
||||||
});
|
});
|
||||||
if (doc == null) {
|
return doc?.data;
|
||||||
doc = this.ai.moduleData.insertOne({
|
|
||||||
module: this.name,
|
|
||||||
data: {}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return doc.data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +124,7 @@ export abstract class InstalledModule<M extends Module = Module, Data = any> imp
|
||||||
this.doc = doc;
|
this.doc = doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.installed = this;
|
ai.installedModules[module.name] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
Loading…
Reference in a new issue