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: Support wildcard in TWITTER_TARGET_USERS 1883 #1884

Merged

Conversation

augchan42
Copy link
Contributor

Support wildcard in TWITTER_TARGET_USERS

Fixes enhancement request #1883

Summary

Added support for wildcard * in TWITTER_TARGET_USERS configuration to allow monitoring all users. This change enables broader interaction patterns while maintaining existing username validation rules.

Changes Made

  • Updated username validation in twitterUsernameSchema to allow * as a special case
  • Username regex now allows:
    • Leading digits (e.g., "123user")
    • Standard alphanumeric + underscore
    • Wildcard "*" character
  • Added test cases to verify wildcard and numeric username support

Code Changes

// Updated username validation
.refine((username) => {
    // Allow wildcard '*' as a special case
    if (username === '*') return true;
    
    // Twitter usernames can:
    // - Start with digits now
    // - Contain letters, numbers, underscores
    return /^[A-Za-z0-9_]+$/.test(username);
}, "An X Username can only contain letters, numbers, and underscores");

Testing

  • Added test cases for:
    • Wildcard "*"
    • Usernames starting with digits
    • Traditional alphanumeric usernames
    • Invalid username patterns

Related

  • Supports broader monitoring capabilities
  • Maintains backward compatibility with existing username patterns

Fix for elizaOS#1556
- Added support for Twitter usernames starting with numbers
- Added support for wildcard '*' in TWITTER_TARGET_USERS
- Fixed test discovery in test.sh to find all .test.ts files
- Updated Jest config for better ESM support

The main change allows Twitter target usernames to start with numbers and
use wildcards, matching current Twitter/X username rules. Test infrastructure
was improved to properly handle ESM modules and find all test files.

Changes:
- Updated username validation regex in Twitter client
- Added test cases for numeric usernames and wildcards
- Switched test.sh to use find for reliable test discovery
- Simplified Jest config to focus on ESM support
@shakkernerd shakkernerd changed the base branch from main to develop January 6, 2025 00:47
@augchan42
Copy link
Contributor Author

Oh to run the new test do pnpm i, pnpm build, then:

pnpm test client-twitter

@shakkernerd shakkernerd merged commit 0df24b5 into elizaOS:develop Jan 6, 2025
2 of 3 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