mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:51:25 +00:00
refactor(telegram): share outbound param parsing
This commit is contained in:
22
src/telegram/outbound-params.ts
Normal file
22
src/telegram/outbound-params.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export function parseTelegramReplyToMessageId(replyToId?: string | null): number | undefined {
|
||||
if (!replyToId) {
|
||||
return undefined;
|
||||
}
|
||||
const parsed = Number.parseInt(replyToId, 10);
|
||||
return Number.isFinite(parsed) ? parsed : undefined;
|
||||
}
|
||||
|
||||
export function parseTelegramThreadId(threadId?: string | number | null): number | undefined {
|
||||
if (threadId == null) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof threadId === "number") {
|
||||
return Number.isFinite(threadId) ? Math.trunc(threadId) : undefined;
|
||||
}
|
||||
const trimmed = threadId.trim();
|
||||
if (!trimmed) {
|
||||
return undefined;
|
||||
}
|
||||
const parsed = Number.parseInt(trimmed, 10);
|
||||
return Number.isFinite(parsed) ? parsed : undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user