From 37b1f044dbf57583b1fd6ae24280c9dd71ec7e80 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Sun, 22 Dec 2024 10:17:24 +1100 Subject: [PATCH 1/2] fix: change max cast length to the current max cast length --- packages/client-farcaster/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client-farcaster/src/utils.ts b/packages/client-farcaster/src/utils.ts index 92b99d698f9..a3c591b3203 100644 --- a/packages/client-farcaster/src/utils.ts +++ b/packages/client-farcaster/src/utils.ts @@ -1,6 +1,6 @@ import { stringToUuid } from "@ai16z/eliza"; -const MAX_CAST_LENGTH = 280; // Updated to Twitter's current character limit +const MAX_CAST_LENGTH = 1024; // Updated to Twitter's current character limit export function castId({ hash, agentId }: { hash: string; agentId: string }) { return `${hash}-${agentId}`; From d3030f06a3cf0756e515efae3386b4d94bc8c051 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Sun, 22 Dec 2024 10:28:54 +1100 Subject: [PATCH 2/2] refactor: reference the max cast length in the content trimming process and export as a const so it's available --- packages/client-farcaster/src/post.ts | 14 ++++++-------- packages/client-farcaster/src/utils.ts | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/client-farcaster/src/post.ts b/packages/client-farcaster/src/post.ts index 3cd06605ec4..63cdd000514 100644 --- a/packages/client-farcaster/src/post.ts +++ b/packages/client-farcaster/src/post.ts @@ -8,7 +8,7 @@ import { } from "@ai16z/eliza"; import { FarcasterClient } from "./client"; import { formatTimeline, postTemplate } from "./prompts"; -import { castUuid } from "./utils"; +import {castUuid, MAX_CAST_LENGTH} from "./utils"; import { createCastMemory } from "./memory"; import { sendCast } from "./actions"; @@ -100,22 +100,20 @@ export class FarcasterPostManager { const slice = newContent.replaceAll(/\\n/g, "\n").trim(); - const contentLength = 240; + let content = slice.slice(0, MAX_CAST_LENGTH); - let content = slice.slice(0, contentLength); - - // if its bigger than 280, delete the last line - if (content.length > 280) { + // if it's bigger than the max limit, delete the last line + if (content.length > MAX_CAST_LENGTH) { content = content.slice(0, content.lastIndexOf("\n")); } - if (content.length > contentLength) { + if (content.length > MAX_CAST_LENGTH) { // slice at the last period content = content.slice(0, content.lastIndexOf(".")); } // if it's still too long, get the period before the last period - if (content.length > contentLength) { + if (content.length > MAX_CAST_LENGTH) { content = content.slice(0, content.lastIndexOf(".")); } diff --git a/packages/client-farcaster/src/utils.ts b/packages/client-farcaster/src/utils.ts index a3c591b3203..340881e7951 100644 --- a/packages/client-farcaster/src/utils.ts +++ b/packages/client-farcaster/src/utils.ts @@ -1,6 +1,6 @@ import { stringToUuid } from "@ai16z/eliza"; -const MAX_CAST_LENGTH = 1024; // Updated to Twitter's current character limit +export const MAX_CAST_LENGTH = 1024; // Updated to Twitter's current character limit export function castId({ hash, agentId }: { hash: string; agentId: string }) { return `${hash}-${agentId}`;