Merge pull request #47 from luochen211/fix/telegram-proxy-diagnostics

fix: explain Telegram proxy connection failures
This commit is contained in:
xmanrui 2026-08-24 19:02:09 +08:00
commit a1427a8db6
5 changed files with 150 additions and 91 deletions

View file

@ -23,6 +23,11 @@ const ENDPOINTS = Object.freeze(Object.values(TOKEN_BOT_ENDPOINTS));
const FORBIDDEN_PUBLIC_KEYS = new Set([
'token', 'botToken', 'tokenRef', 'platformId', 'secret', 'secretRef',
]);
const TELEGRAM_NETWORK_ERRORS = new Set([
'telegram-transport-error',
'telegram-timeout',
'telegram-response-invalid',
]);
function isRecord(value) {
return value !== null && typeof value === 'object' && !Array.isArray(value);
@ -88,6 +93,12 @@ function operationError(channel, error) {
if (error?.code === 'telegram-401' || error?.code === 'discord-401') {
return { code: 'invalid-token', message: `${channel} Bot Token 无效,请重新填写。` };
}
if (channel === 'Telegram' && TELEGRAM_NETWORK_ERRORS.has(error?.code)) {
return {
code: 'telegram-network-error',
message: '无法访问 Telegram Bot API。请检查网络或代理设置;Node.js 22.21+ 可设置 NODE_USE_ENV_PROXY=1,并配置 HTTPS_PROXY、HTTP_PROXY 和 NO_PROXY,然后重启 dsh web。',
};
}
if (error?.code === 'discord-intents') {
return { code: 'discord-intents', message: error.message };
}