Skip to content

Commit

Permalink
Truncate the content
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 committed Dec 24, 2024
1 parent 13517c2 commit 704112f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/client-twitter/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 704112f

Please sign in to comment.