refactor: share telegram caption splitting

This commit is contained in:
Peter Steinberger committed 2026-01-17 03:50:09 +00:00
1 parent 7f1f9473a0
commit 4b749f1b8f
3 files changed
+66 -41

No files matched your search

+15
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 };
}