diff --git a/packages/client-twitter/src/utils.ts b/packages/client-twitter/src/utils.ts index 469f26627b..2344576455 100644 --- a/packages/client-twitter/src/utils.ts +++ b/packages/client-twitter/src/utils.ts @@ -5,8 +5,6 @@ import { stringToUuid } from "@ai16z/eliza"; import { ClientBase } from "./base"; import { elizaLogger } from "@ai16z/eliza"; -const MAX_TWEET_LENGTH = 280; // Updated to Twitter's current character limit - export const wait = (minTime: number = 1000, maxTime: number = 3000) => { const waitTime = Math.floor(Math.random() * (maxTime - minTime + 1)) + minTime; @@ -170,7 +168,10 @@ export async function sendTweet( twitterUsername: string, inReplyTo: string ): Promise { - const tweetChunks = splitTweetContent(content.text); + const tweetChunks = splitTweetContent( + content.text, + Number(client.runtime.getSetting("MAX_TWEET_LENGTH")) + ); const sentTweets: Tweet[] = []; let previousTweetId = inReplyTo; @@ -236,8 +237,7 @@ export async function sendTweet( return memories; } -function splitTweetContent(content: string): string[] { - const maxLength = MAX_TWEET_LENGTH; +function splitTweetContent(content: string, maxLength: number): string[] { const paragraphs = content.split("\n\n").map((p) => p.trim()); const tweets: string[] = []; let currentTweet = "";