Skip to content

Commit

Permalink
Merge pull request #1043 from odilitime/rest-upgrade
Browse files Browse the repository at this point in the history
fix: re-enable generateNewTweetLoop / lint fixes
  • Loading branch information
odilitime authored Dec 13, 2024
2 parents ccd70d4 + d2cf25e commit aa51205
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/client-twitter/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export class TwitterPostClient {
};



const processActionsLoop = async () => {
const actionInterval = parseInt(
this.runtime.getSetting("ACTION_INTERVAL")
Expand Down Expand Up @@ -172,6 +171,7 @@ export class TwitterPostClient {
if (postImmediately) {
await this.generateNewTweet();
}
generateNewTweetLoop();

// Add check for ENABLE_ACTION_PROCESSING before starting the loop
const enableActionProcessing = parseBooleanFromText(
Expand Down Expand Up @@ -250,6 +250,7 @@ export class TwitterPostClient {
cleanedContent = parsedResponse;
}
} catch (error) {
error.linted = true; // make linter happy since catch needs a variable
// If not JSON, clean the raw content
cleanedContent = newTweetContent
.replace(/^\s*{?\s*"text":\s*"|"\s*}?\s*$/g, '') // Remove JSON-like wrapper
Expand Down Expand Up @@ -374,7 +375,7 @@ export class TwitterPostClient {
console.log("generate tweet content response:\n" + response);

// First clean up any markdown and newlines
let cleanedResponse = response
const cleanedResponse = response
.replace(/```json\s*/g, '') // Remove ```json
.replace(/```\s*/g, '') // Remove any remaining ```
.replaceAll(/\\n/g, "\n")
Expand All @@ -393,6 +394,8 @@ export class TwitterPostClient {
}
}
} catch (error) {
error.linted = true; // make linter happy since catch needs a variable

// If JSON parsing fails, treat as plain text
elizaLogger.debug('Response is not JSON, treating as plain text');
}
Expand Down

0 comments on commit aa51205

Please sign in to comment.