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

Method updateConfig

ai/ai.ts:1605–1624  ·  view source on GitHub ↗
(updater: (config: DB) => void)

Source from the content-addressed store, hash-verified

1603
1604 async updateConfig(updater: (config: DB) => void): Promise<void> {
1605 this.writeQueue = this.writeQueue.then(async () => {
1606 const oldSnapshot: DB = JSON.parse(JSON.stringify(this.currentConfig));
1607 updater(this.currentConfig);
1608
1609 const hasChanged =
1610 JSON.stringify(oldSnapshot) !== JSON.stringify(this.currentConfig);
1611
1612 if (!hasChanged) {
1613 return;
1614 }
1615
1616 if (this.db) {
1617 this.db.data = { ...this.currentConfig };
1618 await this.db.write();
1619 }
1620 await this.notifyListeners(this.currentConfig);
1621 });
1622 return this.writeQueue;
1623 }
1624
1625 registerListener(listener: ConfigChangeListener): void {
1626 this.listeners.push(listener);
1627 }

Callers 15

ensureTGTokenMethod · 0.45
addConfigMethod · 0.45
setStreamMethod · 0.45
setResponsesMethod · 0.45
setProviderTypeMethod · 0.45
deleteConfigMethod · 0.45
executeMethod · 0.45
executeMethod · 0.45
executeMethod · 0.45
enableTelegraphMethod · 0.45
disableTelegraphMethod · 0.45
setTelegraphLimitMethod · 0.45

Calls 2

notifyListenersMethod · 0.95
writeMethod · 0.80

Tested by

no test coverage detected