Simplify install with one-click scripts; honor HTTP(S)_PROXY for Telegram.

Add install.ps1/install.sh, shrink README to script-first flow, register bot commands, and route API calls through undici EnvHttpProxyAgent when a proxy is set (v0.2.2).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
owo
2026-08-14 17:46:01 +08:00
co-authored by Cursor
parent 8ef1622822
commit a83af2f33c
15 changed files with 1255 additions and 204 deletions
+13 -1
View File
@@ -9,6 +9,18 @@ export const Config = Schema.object({
maxMessageLength: Schema.number().default(4096),
pollingTimeoutSec: Schema.number().default(30),
});
function resolveAllowedUserIds(config) {
if (config.allowedUserIds && config.allowedUserIds.length > 0) {
return config.allowedUserIds;
}
const raw = process.env.DSH_TELEGRAM_ALLOWED_USER_IDS ?? '';
return raw
.split(/[,;\s]+/)
.map((part) => part.trim())
.filter(Boolean)
.map((part) => Number(part))
.filter((n) => Number.isFinite(n) && n > 0);
}
export function apply(ctx, config) {
const token = (config.token && config.token.length > 0)
? config.token
@@ -19,7 +31,7 @@ export function apply(ctx, config) {
}
const bridge = new TelegramBridge(ctx, {
token,
allowedUserIds: config.allowedUserIds ?? [],
allowedUserIds: resolveAllowedUserIds(config),
allowAllUsers: config.allowAllUsers ?? false,
maxMessageLength: config.maxMessageLength ?? 4096,
pollingTimeoutSec: config.pollingTimeoutSec ?? 30,