fix: prefer config tokens over env for discord/telegram

This commit is contained in:
Peter Steinberger
2026-01-16 23:12:50 +00:00
parent bf72a126d1
commit 106e308953
7 changed files with 73 additions and 13 deletions

View File

@@ -54,11 +54,6 @@ export function resolveTelegramToken(
}
const allowEnv = accountId === DEFAULT_ACCOUNT_ID;
const envToken = allowEnv ? (opts.envToken ?? process.env.TELEGRAM_BOT_TOKEN)?.trim() : "";
if (envToken) {
return { token: envToken, source: "env" };
}
const tokenFile = telegramCfg?.tokenFile?.trim();
if (tokenFile && allowEnv) {
if (!fs.existsSync(tokenFile)) {
@@ -81,5 +76,10 @@ export function resolveTelegramToken(
return { token: configToken, source: "config" };
}
const envToken = allowEnv ? (opts.envToken ?? process.env.TELEGRAM_BOT_TOKEN)?.trim() : "";
if (envToken) {
return { token: envToken, source: "env" };
}
return { token: "", source: "none" };
}