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

feat: improve Twitter client with action processing #1007

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

dorianjanezic
Copy link
Contributor

Risks

Low - This PR primarily adds functionality to handle tweet generation and processing with proper error handling and rate limiting in place. Main risks:

  • Potential rate limiting from Twitter API if intervals not properly configured
  • Memory usage from caching tweets and processing actions

Background

What does this PR do?

Implements a Twitter post client that:

  • Generates and posts new tweets on configurable intervals
  • Processes tweet actions (likes, retweets, quotes, replies) based on agent personality
  • Handles proper truncation of tweets to fit character limits
  • Implements caching and rate limiting
  • Provides error handling and logging

What kind of change is this?

Features (non-breaking change which adds functionality)

  • Adds new TwitterPostClient class
  • Implements tweet generation and action processing
  • Adds caching and rate limiting controls

Documentation changes needed?

My changes require a change to the project documentation to document:

  • Configuration options for post intervals and action processing
  • Template customization for tweets and actions
  • Rate limiting and caching behavior

Testing

  1. Configure Twitter credentials in .env
  2. Initialize client:
const client = new TwitterPostClient(baseClient, runtime);
await client.start();
  1. Verify tweet generation:
  • Check logs for "Generating new tweet"
  • Confirm tweet appears on Twitter
  • Verify proper truncation to 240 chars
  1. Test action processing:
  • Check logs for "Processing tweet actions"
  • Verify likes/retweets/quotes/replies execute
  • Confirm rate limiting works
  1. Verify error handling:
  • Test with invalid credentials
  • Check error logging
  • Confirm graceful failure

Deployment instructions

Requires the following environment variables:

ACTION_INTERVAL
ENABLE_ACTION_PROCESSING

Discord username

dorianjanezic

…al, remove double debug logs, revert truncateToCompleteSentence function
@dorianjanezic
Copy link
Contributor Author

@odilitime thanks for noticing. Issues resolved.

@odilitime odilitime merged commit c411c2f into elizaOS:develop Dec 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants