refactor: share telegram caption splitting

This commit is contained in:
Peter Steinberger
2026-01-17 03:50:05 +00:00
parent 7f1f9473a0
commit 4b749f1b8f
3 changed files with 66 additions and 41 deletions

15
src/telegram/caption.ts Normal file
View File

@@ -0,0 +1,15 @@
export const TELEGRAM_MAX_CAPTION_LENGTH = 1024;
export function splitTelegramCaption(text?: string): {
caption?: string;
followUpText?: string;
} {
const trimmed = text?.trim() ?? "";
if (!trimmed) {
return { caption: undefined, followUpText: undefined };
}
if (trimmed.length > TELEGRAM_MAX_CAPTION_LENGTH) {
return { caption: undefined, followUpText: trimmed };
}
return { caption: trimmed, followUpText: undefined };
}