Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-enable generateNewTweetLoop / lint fixes #1043

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading