eliza icon indicating copy to clipboard operation
eliza copied to clipboard

feat: improve Twitter client with action processing

Open dorianjanezic opened this issue 1 year ago • 1 comments

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

dorianjanezic avatar Dec 12 '24 08:12 dorianjanezic

@odilitime thanks for noticing. Issues resolved.

dorianjanezic avatar Dec 12 '24 09:12 dorianjanezic