Skip to content

Commit

Permalink
Merge pull request #1347 from 0x330a/main
Browse files Browse the repository at this point in the history
Update farcaster client max cast length
  • Loading branch information
monilpat authored Dec 21, 2024
2 parents e15dd54 + 86194df commit b9d819e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions packages/client-farcaster/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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("."));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/client-farcaster/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { stringToUuid } from "@ai16z/eliza";

const MAX_CAST_LENGTH = 280; // 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}`;
Expand Down

0 comments on commit b9d819e

Please sign in to comment.