mirror of
https://github.com/syuilo/ai.git
synced 2024-11-09 15:38:00 +00:00
Compare commits
2 commits
9ad70138d2
...
7fe378ca50
Author | SHA1 | Date | |
---|---|---|---|
7fe378ca50 | |||
3f710c7c6b |
|
@ -54,7 +54,6 @@ 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,10 +75,16 @@ export default abstract class Module {
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
protected getData() {
|
protected getData() {
|
||||||
const doc = this.ai.moduleData.findOne({
|
let doc = this.ai.moduleData.findOne({
|
||||||
module: this.name
|
module: this.name
|
||||||
});
|
});
|
||||||
return doc?.data;
|
if (doc == null) {
|
||||||
|
doc = this.ai.moduleData.insertOne({
|
||||||
|
module: this.name,
|
||||||
|
data: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return doc.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,7 +130,7 @@ export abstract class InstalledModule<M extends Module = Module, Data = any> imp
|
||||||
this.doc = doc;
|
this.doc = doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ai.installedModules[module.name] = this;
|
module.installed = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
Loading…
Reference in a new issue