MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / init

Method init

ai/ai.ts:1582–1599  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1580
1581 private async init(): Promise<void> {
1582 if (this.db) return;
1583
1584 this.baseDir = createDirectoryInAssets("ai");
1585 this.file = path.join(this.baseDir, "config.json");
1586 this.db = await JSONFilePreset<DB>(this.file, this.getDefaultConfig());
1587
1588 await this.writeQueue;
1589 await this.db.read();
1590 this.currentConfig = { ...this.db.data };
1591 const before = JSON.stringify(this.currentConfig);
1592 this.ensureDefaults();
1593 const after = JSON.stringify(this.currentConfig);
1594 if (before !== after) {
1595 this.db.data = { ...this.currentConfig };
1596 await this.db.write();
1597 }
1598 }
1599
1600 getConfig(): DB {
1601 return { ...this.currentConfig };
1602 }

Callers 1

getInstanceMethod · 0.95

Calls 3

getDefaultConfigMethod · 0.95
ensureDefaultsMethod · 0.95
writeMethod · 0.80

Tested by

no test coverage detected