feat(core): auto-inject hook on QQ process discovery
Headless / Docker deployments previously needed a human to click "Load" in WebUI for every newly-discovered QQ process. Add an opt-in HookManager.autoLoadOnDiscovery flag wired up through two layers: - SNOWLUMA_HOOK_AUTOLOAD env var (highest priority) - hookAutoLoad in runtime.json (persistent fallback) When enabled, every 'process-discovered' event from PipeWatcher fires session.load() fire-and-forget; failures stay scoped to the session via existing error-state handling and don't break the watcher loop. Default stays off, so non-Docker installs see no behaviour change.
This commit is contained in:
4 files changed
+156
-1
No files matched your search
@@ -15,7 +15,14 @@ async function main() {
|
||||
// HookManager defaults its packet sink to bridgeManager.onPacket, so
|
||||
// every parsed hook packet reaches the per-UIN bridge dispatcher with
|
||||
// no intermediate layer.
|
||||
const hookManager = new HookManager({ bridgeManager });
|
||||
// Env var SNOWLUMA_HOOK_AUTOLOAD wins over runtime.json so Docker /
|
||||
// headless deployments can flip auto-injection on without touching the
|
||||
// persisted user config volume.
|
||||
const autoLoadOnDiscovery = resolveAutoLoad(runtimeConfig.hookAutoLoad);
|
||||
const hookManager = new HookManager({ bridgeManager, autoLoadOnDiscovery });
|
||||
if (autoLoadOnDiscovery) {
|
||||
log.info('hook auto-load enabled: every discovered QQ process will be injected');
|
||||
}
|
||||
|
||||
oneBotManager.bind(bridgeManager);
|
||||
|
||||
@@ -40,6 +47,16 @@ async function main() {
|
||||
});
|
||||
}
|
||||
|
||||
function resolveAutoLoad(fromConfig: boolean | undefined): boolean {
|
||||
const envRaw = process.env.SNOWLUMA_HOOK_AUTOLOAD;
|
||||
if (typeof envRaw === 'string' && envRaw.trim()) {
|
||||
const v = envRaw.trim().toLowerCase();
|
||||
if (v === '1' || v === 'true' || v === 'yes' || v === 'on') return true;
|
||||
if (v === '0' || v === 'false' || v === 'no' || v === 'off') return false;
|
||||
}
|
||||
return fromConfig === true;
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
log.error(error instanceof Error ? (error.stack ?? error.message) : String(error));
|
||||
process.exit(1);
|
||||
|
||||
Reference in new issue
Block a user