|
8 | 8 | } from "@ai16z/eliza";
|
9 | 9 | import { FarcasterClient } from "./client";
|
10 | 10 | import { formatTimeline, postTemplate } from "./prompts";
|
11 |
| -import { castUuid } from "./utils"; |
| 11 | +import {castUuid, MAX_CAST_LENGTH} from "./utils"; |
12 | 12 | import { createCastMemory } from "./memory";
|
13 | 13 | import { sendCast } from "./actions";
|
14 | 14 |
|
@@ -100,22 +100,20 @@ export class FarcasterPostManager {
|
100 | 100 |
|
101 | 101 | const slice = newContent.replaceAll(/\\n/g, "\n").trim();
|
102 | 102 |
|
103 |
| - const contentLength = 240; |
| 103 | + let content = slice.slice(0, MAX_CAST_LENGTH); |
104 | 104 |
|
105 |
| - let content = slice.slice(0, contentLength); |
106 |
| - |
107 |
| - // if its bigger than 280, delete the last line |
108 |
| - if (content.length > 280) { |
| 105 | + // if it's bigger than the max limit, delete the last line |
| 106 | + if (content.length > MAX_CAST_LENGTH) { |
109 | 107 | content = content.slice(0, content.lastIndexOf("\n"));
|
110 | 108 | }
|
111 | 109 |
|
112 |
| - if (content.length > contentLength) { |
| 110 | + if (content.length > MAX_CAST_LENGTH) { |
113 | 111 | // slice at the last period
|
114 | 112 | content = content.slice(0, content.lastIndexOf("."));
|
115 | 113 | }
|
116 | 114 |
|
117 | 115 | // if it's still too long, get the period before the last period
|
118 |
| - if (content.length > contentLength) { |
| 116 | + if (content.length > MAX_CAST_LENGTH) { |
119 | 117 | content = content.slice(0, content.lastIndexOf("."));
|
120 | 118 | }
|
121 | 119 |
|
|
0 commit comments