Skip to content

Commit

Permalink
Fix double spaced tweets in Post.ts
Browse files Browse the repository at this point in the history
Currently, despite the prompting stating to use "\\n\\n (double spaces" between statements the tweets always output new statements with just a single newline, making tweets look blocky. 

For example, tweets previous would look like (despite the prompt): 
"Dobby is so excited to start this new year, full of possibilities and chances to make a difference!
Dobby has big plans to help his dear friends and make the wizarding world an even brighter place."

This ensures the double spaces requested in prompting is applied to the tweets with the tweets now looking like: 
"Dobby must remind all friends to be cautious of dark magic lurking in the shadows.

Dobby's heart aches at the thought of anyone falling prey to its deceitful powers."

This allows agents to tweet better-formatted posts that ease visilibty.
  • Loading branch information
suicidalgoofy authored Jan 1, 2025
1 parent 76d4f42 commit d12603b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/client-twitter/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export class TwitterPostClient {
.replace(/^\s*{?\s*"text":\s*"|"\s*}?\s*$/g, "") // Remove JSON-like wrapper
.replace(/^['"](.*)['"]$/g, "$1") // Remove quotes
.replace(/\\"/g, '"') // Unescape quotes
.replace(/\\n/g, "\n") // Unescape newlines
.replace(/\\n/g, "\n\n") // Unescape newlines, ensures double spaces
.trim();
}

Expand All @@ -486,7 +486,7 @@ export class TwitterPostClient {
const removeQuotes = (str: string) =>
str.replace(/^['"](.*)['"]$/, "$1");

const fixNewLines = (str: string) => str.replaceAll(/\\n/g, "\n");
const fixNewLines = (str: string) => str.replaceAll(/\\n/g, "\n\n"); //ensures double spaces

// Final cleaning
cleanedContent = removeQuotes(fixNewLines(cleanedContent));
Expand Down

0 comments on commit d12603b

Please sign in to comment.