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:
+14
-1
@@ -21,6 +21,19 @@ export const Config: Schema<TelegramChannelConfig> = Schema.object({
|
||||
pollingTimeoutSec: Schema.number().default(30),
|
||||
})
|
||||
|
||||
function resolveAllowedUserIds(config: TelegramChannelConfig): number[] {
|
||||
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: Context, config: TelegramChannelConfig): void {
|
||||
const token = (config.token && config.token.length > 0)
|
||||
? config.token
|
||||
@@ -33,7 +46,7 @@ export function apply(ctx: Context, config: TelegramChannelConfig): void {
|
||||
}
|
||||
const bridge = new TelegramBridge(ctx, {
|
||||
token,
|
||||
allowedUserIds: config.allowedUserIds ?? [],
|
||||
allowedUserIds: resolveAllowedUserIds(config),
|
||||
allowAllUsers: config.allowAllUsers ?? false,
|
||||
maxMessageLength: config.maxMessageLength ?? 4096,
|
||||
pollingTimeoutSec: config.pollingTimeoutSec ?? 30,
|
||||
|
||||
Reference in New Issue
Block a user