mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 15:00:44 +00:00
18 lines
589 B
TypeScript
18 lines
589 B
TypeScript
export function normalizeTelegramAllowFromEntry(raw: unknown): string {
|
|
const base = typeof raw === "string" ? raw : typeof raw === "number" ? String(raw) : "";
|
|
return base
|
|
.trim()
|
|
.replace(/^(telegram|tg):/i, "")
|
|
.trim();
|
|
}
|
|
|
|
export function isNumericTelegramUserId(raw: string): boolean {
|
|
return /^-?\d+$/.test(raw);
|
|
}
|
|
|
|
// Telegram sender authorization only accepts concrete user IDs. Negative chat IDs
|
|
// belong under `channels.telegram.groups`, not sender allowlists.
|
|
export function isNumericTelegramSenderUserId(raw: string): boolean {
|
|
return /^\d+$/.test(raw);
|
|
}
|