A comprehensive Twitter bot that helps you manage your Twitter account. The project starts with automatic tweet deletion functionality and will progressively add more features, including advanced AI capabilities.
- Basic project setup
- Documentation (README and LICENSE)
- Environment configuration
- Tweet deletion functionality
- Deleted tweets tracking system
- Rate limiting implementation
- Error handling system
- AI features implementation
- Model integration setup
- Additional tweet management features
- User interaction features
- Automatic deletion of oldest tweets
- Tracking of deleted tweets to avoid duplicates
- Respect for Twitter API rate limits
- Colorful console output for better visibility
- Progress tracking and status updates
- Caching of fetched tweets for better performance
- JSON-based storage system
- Like and retweet management
- Tweet scheduling
- List management
- Statistics analysis
- Engagement metrics
- Performance tracking
- Mention interactions
- Direct message handling
- Follower management
- Automatic tweet generation with GPT
- Content optimization
- Hashtag suggestions
- Tweet sentiment analysis
- Trend analysis
- Content recommendations
- Automatic inappropriate content detection
- Spam detection
- Content filtering
- Personalized automatic responses
- Smart scheduling
- Automatic tweet categorization
- Python 3.6 or higher
- Git
- Twitter Developer Account with API access
- Twitter API v2 credentials
- OpenAI API key (for GPT features)
- Clone the repository:
git clone https://github.com/yourusername/twitter-bot.git
cd twitter-bot- Install required dependencies:
pip install requests requests-oauthlib python-dotenv openai transformers torch pandas numpy scikit-learn- Create a
.envfile in the root directory with your credentials:
# Twitter API
API_KEY=your_api_key
API_SECRET=your_api_secret
ACCESS_TOKEN=your_access_token
ACCESS_TOKEN_SECRET=your_access_token_secret
# OpenAI API
OPENAI_API_KEY=your_openai_api_keypython delete_tweets.pypython generate_tweets.pypython analyze_sentiment.pyThe script contains several constants that can be modified in delete_tweets.py:
MAX_DELETIONS: Maximum number of tweets to delete per run (default: 17)DELETED_FILE: File to store deleted tweet IDs (default: "deleted_tweets.json")FETCHED_TWEETS_FILE: File to cache fetched tweets (default: "fetched_tweets.json")
The bot will use several AI models:
- GPT for content generation
- BERT for sentiment analysis
- Classification models for categorization
- Inappropriate content detection models
- The script includes a 1-second delay between deletions to respect Twitter's rate limits
- Deleted tweets are tracked to prevent attempting to delete the same tweet twice
- The script uses Twitter API v2, which requires elevated access
- AI features will require a valid OpenAI API key
- Missing environment variables
- API authentication issues
- Rate limiting
- Network errors
- File system errors
- AI generation errors
- Classification issues
- Model loading errors
- Fork the project
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.