refactor: share telegram caption splitting
This commit is contained in:
1 parent
7f1f9473a0
commit
4b749f1b8f
3 files changed
+66
-41
No files matched your search
@@ -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 };
|
||||
}
|
||||
Reference in new issue
Block a user