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

Function initDb

pmcaptcha/pmcaptcha.ts:215–226  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213 JSONFilePreset(path.join(pmcDir, "pmcaptcha_config.json"), DEFAULT_CONFIG) as Promise<JsonDb>,
214 JSONFilePreset(path.join(dataDir, "pmcaptcha_data.json"), DEFAULT_DATA) as Promise<JsonDb>,
215 ]);
216 dbReady = true;
217 log(LogLevel.INFO, `Config DB ready | Data DB: ${path.join(dataDir, "pmcaptcha_data.json")}`);
218 } catch (e) {
219 log(LogLevel.ERROR, "DB init failed", e);
220 }
221}
222
223async function generationDelay(ms: number): Promise<boolean> {
224 const lifecycle = getActiveLifecycle();
225 if (!lifecycle) return false;
226 return await new Promise<boolean>((resolve) => {
227 lifecycle.setTimeout(() => resolve(!lifecycle.signal.aborted), ms, { label: "pmcaptcha-delay" });
228 if (lifecycle.signal.aborted) resolve(false);
229 });

Callers 1

pmcaptcha.tsFile · 0.85

Calls 1

logFunction · 0.85

Tested by

no test coverage detected