Skip to content

Commit ee80445

Browse files
authored
Merge branch 'develop' into fix/remove-redundant-uuid-conversion
2 parents 6361419 + 263f87b commit ee80445

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

.vscode/settings.json

+11
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,16 @@
4343
},
4444
"[shellscript]": {
4545
"editor.defaultFormatter": "foxundermoon.shell-format"
46+
},
47+
"explorer.fileNesting.enabled": true,
48+
"explorer.fileNesting.patterns": {
49+
"*.ts": "${capture}.js",
50+
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
51+
"*.jsx": "${capture}.js",
52+
"*.tsx": "${capture}.ts",
53+
"tsconfig.json": "tsconfig.*.json",
54+
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb,pnpm-workspace.yaml",
55+
"README.md": "*.md",
56+
"Dockerfile": "docker-compose-docs.yaml,docker-compose.yaml,Dockerfile.docs"
4657
}
4758
}

packages/client-twitter/src/utils.ts

+32-2
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,18 @@ export async function sendTweet(
212212
})
213213
);
214214
}
215+
216+
const cleanChunk = deduplicateMentions(chunk.trim())
217+
215218
const result = await client.requestQueue.add(async () =>
216219
isLongTweet
217220
? client.twitterClient.sendLongTweet(
218-
chunk.trim(),
221+
cleanChunk,
219222
previousTweetId,
220223
mediaData
221224
)
222225
: client.twitterClient.sendTweet(
223-
chunk.trim(),
226+
cleanChunk,
224227
previousTweetId,
225228
mediaData
226229
)
@@ -397,6 +400,33 @@ function splitSentencesAndWords(text: string, maxLength: number): string[] {
397400
return chunks;
398401
}
399402

403+
function deduplicateMentions(paragraph: string) {
404+
// Regex to match mentions at the beginning of the string
405+
const mentionRegex = /^@(\w+)(?:\s+@(\w+))*(\s+|$)/;
406+
407+
// Find all matches
408+
const matches = paragraph.match(mentionRegex);
409+
410+
if (!matches) {
411+
return paragraph; // If no matches, return the original string
412+
}
413+
414+
// Extract mentions from the match groups
415+
let mentions = matches.slice(1).filter(Boolean) as string[];
416+
417+
// Deduplicate mentions
418+
mentions = [...new Set(mentions)];
419+
420+
// Reconstruct the string with deduplicated mentions
421+
const uniqueMentionsString = `@${mentions.join(' ')}`;
422+
423+
// Find where the mentions end in the original string
424+
const endOfMentions = paragraph.indexOf(matches[0]) + matches[0].length;
425+
426+
// Construct the result by combining unique mentions with the rest of the string
427+
return uniqueMentionsString + paragraph.slice(endOfMentions);
428+
}
429+
400430
function restoreUrls(
401431
chunks: string[],
402432
placeholderMap: Map<string, string>

packages/plugin-tts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"dependencies": {
2222
"@elizaos/core": "workspace:*",
2323
"tsup": "8.3.5",
24+
"langdetect": "0.2.1",
2425
"whatwg-url": "7.1.0"
2526
},
2627
"scripts": {

0 commit comments

Comments
 (0)