Skip to content

Commit

Permalink
fix: use MAX_TWEET_LENGTH from setting
Browse files Browse the repository at this point in the history
  • Loading branch information
oxSaturn committed Dec 10, 2024
1 parent 9c7a080 commit ba06423
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/client-twitter/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -170,7 +168,10 @@ export async function sendTweet(
twitterUsername: string,
inReplyTo: string
): Promise<Memory[]> {
const tweetChunks = splitTweetContent(content.text);
const tweetChunks = splitTweetContent(
content.text,
Number(client.runtime.getSetting("MAX_TWEET_LENGTH"))
);
const sentTweets: Tweet[] = [];
let previousTweetId = inReplyTo;

Expand Down Expand Up @@ -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 = "";
Expand Down

0 comments on commit ba06423

Please sign in to comment.