From 055e89c62848dc3f06180671c3be2cbac484fa03 Mon Sep 17 00:00:00 2001 From: oxSaturn Date: Tue, 10 Dec 2024 15:23:21 +0800 Subject: [PATCH] use DEFAULT_MAX_TWEET_LENGTH --- packages/client-twitter/src/environment.ts | 2 +- packages/client-twitter/src/utils.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/client-twitter/src/environment.ts b/packages/client-twitter/src/environment.ts index 2221e87ec7..8b22d0dc59 100644 --- a/packages/client-twitter/src/environment.ts +++ b/packages/client-twitter/src/environment.ts @@ -1,7 +1,7 @@ import { IAgentRuntime } from "@ai16z/eliza"; import { z } from "zod"; -const DEFAULT_MAX_TWEET_LENGTH = 280; +export const DEFAULT_MAX_TWEET_LENGTH = 280; export const twitterEnvSchema = z.object({ TWITTER_DRY_RUN: z diff --git a/packages/client-twitter/src/utils.ts b/packages/client-twitter/src/utils.ts index 2344576455..c69bf53130 100644 --- a/packages/client-twitter/src/utils.ts +++ b/packages/client-twitter/src/utils.ts @@ -4,6 +4,7 @@ import { Content, Memory, UUID } from "@ai16z/eliza"; import { stringToUuid } from "@ai16z/eliza"; import { ClientBase } from "./base"; import { elizaLogger } from "@ai16z/eliza"; +import { DEFAULT_MAX_TWEET_LENGTH } from "./environment"; export const wait = (minTime: number = 1000, maxTime: number = 3000) => { const waitTime = @@ -170,7 +171,8 @@ export async function sendTweet( ): Promise { const tweetChunks = splitTweetContent( content.text, - Number(client.runtime.getSetting("MAX_TWEET_LENGTH")) + Number(client.runtime.getSetting("MAX_TWEET_LENGTH")) || + DEFAULT_MAX_TWEET_LENGTH ); const sentTweets: Tweet[] = []; let previousTweetId = inReplyTo;