Twitter/X bot farm with OpenAI-powered content generation and automated engagement. Manages multiple accounts with intelligent tweet generation, interaction distribution, and proxy rotation.
- AI Tweet Generation -- GPT-4 generates contextually relevant tweets across configurable topics and tones
- Tweet Rewriting -- scrapes existing tweets and rewrites them with AI for natural-sounding content
- Multi-Account Management -- individual proxy support, credential storage, and session isolation
- Automated Interactions -- likes, retweets, replies, and follows with configurable probability distributions
- Human-Like Behavior -- RandomActionDecorator simulates browsing, scrolling, and pausing between actions
- Scraping Pipeline -- collects tweets from target accounts and search queries via Twitter API and Playwright
- Content Merging -- merges generated and scraped content into unified interaction queues
- YAML Configuration -- all behavior controlled through a single
bot_farm_config.yaml - Web Dashboard -- React frontend with real-time logs (WebSocket), config editor, and image upload
- Docker Deployment -- full stack with PostgreSQL, Flask backend, React frontend, and Adminer
grimace-twitter/
├── main.py # Farm orchestrator
├── setup.py # Entry point with logging
├── config.py # Environment loader
├── bot_farm_config.yaml # Master configuration
├── model/ # OpenAI generation engine
├── interactions/ # Twitter interaction executor
├── scraping/ # Tweet scrapers (Playwright + API)
├── utils/ # DB, distribution, login, search
├── merging/ # Content merging pipeline
├── RandomActionDecorator/ # Human-like action simulator
├── app/ # Flask backend (API + WebSocket)
├── frontend/ # React dashboard
├── docker-compose.yml
└── Dockerfile-backend
- Python 3.10+
- PostgreSQL 14+
- Node.js 18+ (for frontend)
- OpenAI API key
git clone https://github.com/mazamaka/grimace-twitter.git cd grimace-twitter cp .env.example .env # Edit .env with your credentials
docker compose up -d db adminer
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
playwright install chromiumEdit bot_farm_config.yaml:
- Scraping -- target accounts, search queries, tweet count
- Generation -- topics, prompts, hashtags, tone
- Distribution -- interaction ratios (likes/posts/replies/retweets)
- Merging -- custom probabilities, limits
- RandomActions -- page visits, timing, follow/like probabilities
# Accounts: add via Adminer or API # Proxies: one per line in bots/proxies.txt # Format: ip:port:username:password
# CLI mode python setup.py # Full Docker stack docker compose up -d
- Backend API:
http://localhost:5000 - Frontend:
http://localhost:88 - Adminer:
http://localhost:8080
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY |
Yes | OpenAI API key for tweet generation |
POSTGRES_DB |
Yes | PostgreSQL database name |
POSTGRES_USER |
Yes | PostgreSQL username |
POSTGRES_PASSWORD |
Yes | PostgreSQL password |
POSTGRES_LOCALHOST |
Yes | PostgreSQL host (for local dev) |
POSTGRES_PORT |
Yes | PostgreSQL port |
HEADLESS |
No | Run browser headless (True/False) |
BACKEND_PORT |
No | Flask API port (default: 5000) |
FRONTEND_PORT |
No | React app port (default: 88) |
ADMINER_PORT |
No | Adminer port (default: 8080) |
secret_word |
Yes | JWT secret for auth |
secret_key |
Yes | Flask secret key |
- Backend: Python, Flask, Flask-SocketIO, SQLAlchemy
- AI: OpenAI GPT-4
- Automation: Playwright, Selenium, undetected-chromedriver
- Scraping: twitter-api-client, custom Playwright scrapers
- Database: PostgreSQL, psycopg2
- Frontend: React, WebSocket
- Infrastructure: Docker, docker-compose
Maksym Babenko
MIT