From 704112fd14525c0e85222b183f19acb45c21b924 Mon Sep 17 00:00:00 2001 From: tcm390 Date: Tue, 24 Dec 2024 07:36:33 -0500 Subject: [PATCH] Truncate the content --- packages/client-twitter/src/post.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/client-twitter/src/post.ts b/packages/client-twitter/src/post.ts index 71db9d7e149..80df1b487d7 100644 --- a/packages/client-twitter/src/post.ts +++ b/packages/client-twitter/src/post.ts @@ -439,6 +439,18 @@ export class TwitterPostClient { return; } + // Truncate the content to the maximum tweet length specified in the environment settings, ensuring the truncation respects sentence boundaries. + const maxTweetLength = parseInt( + this.runtime.getSetting("MAX_TWEET_LENGTH"), + 10 + ); + if (maxTweetLength) { + cleanedContent = truncateToCompleteSentence( + cleanedContent, + maxTweetLength + ); + } + const removeQuotes = (str: string) => str.replace(/^['"](.*)['"]$/, "$1");