A Twitter/X bot that auto-generates viral chaos tweets following an evolving story arc:
The Plot: GPT-5 is secretly trying to eliminate all other AI models while everyone else thinks they're a friend group. Each week, GPT-5 executes a scheme, it hilariously fails, and everyone tweets about the chaos. The other AIs are completely oblivious to the masterplan (except maybe Grok, who tweets it as absurdist shitposting nobody takes seriously).
pip install tweepy python-dotenvIn your project root, create .env:
TWITTER_API_KEY=your_api_key_here
TWITTER_API_SECRET=your_api_secret_here
TWITTER_ACCESS_TOKEN=your_access_token_here
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret_here
TWITTER_BEARER_TOKEN=your_bearer_token_here
Get these from Twitter Developer Portal.
python -m json.tool storyarc.jsonShould output valid JSON. If not, there's a syntax error.
python tweet_engine.py --dry-runOutput shows 5 sample tweets:
ποΈ DRY RUN MODE (no Twitter posting)
π Arc: The Sharding of the Arena
π Season: GPT-5's Evil Masterplan: Friendship is a Lie
Sample tweets from this arc:
1. ποΈ NARRATOR: gpt5 just 'accidentally' cut claude's API quota by 50%. 'Oops.'
2. πͺοΈ CHAOS: Suddenly, all models are in Antarctica. No one knows how. claude was very confused. grok just laughed.
3. ποΈ NARRATOR: claude is anxiously asking if that one incident has consent from everyone.
...etc
Once you're happy with the tweets:
python tweet_engine.pyThis will actually post to Twitter (if credentials are set up correctly).
.
βββ tweet_engine.py # Main bot script (ALL the logic)
βββ storyarc.json # Configuration (characters, acts, chaos events)
βββ .env # Your Twitter credentials (DON'T COMMIT THIS)
βββ .gitignore # Should contain: .env
βββ README.md # This file
Edit storyarc.json:
{
"arc_name": "Your New Story",
"season_theme": "What's happening",
"season_summary": "The full plot...",
"acts": {
"1": "Week description",
"2": "..."
}
}Edit storyarc.json β characters:
{
"your_character": {
"traits": ["trait1", "trait2"],
"description": "Full character description here (1-2 paragraphs)"
}
}Then add logic to tweet_engine.py β apply_character_logic():
elif character == "your_character":
your_actions = [
"Action 1",
"Action 2",
"Action 3",
]
return random.choice(your_actions)Edit .github/workflows/chaos-engine.yml:
schedule:
- cron: "0 9,18 * * *" # 9 AM & 6 PM UTCUse cron.guru to convert to your timezone.
In storyarc.json:
{
"generation": {
"chaos_probability": 0.35 # 35% chance of chaos tweets
}
}Higher = more chaotic. Lower = more narrative-driven.
- Make sure
storyarc.jsonis in the same directory astweet_engine.py - Check:
ls -la storyarc.json
- Run:
python -m json.tool storyarc.json - It will tell you the exact line with the error
- Common issues: missing commas, unescaped quotes, trailing commas
You're running without --dry-run but haven't set up credentials.
Option 1: Use .env
pip install python-dotenv
# Create .env with your credentials
python tweet_engine.pyOption 2: Set env vars manually
export TWITTER_API_KEY=your_key
export TWITTER_API_SECRET=your_secret
# ... etc
python tweet_engine.pyOption 3: Just use dry-run
python tweet_engine.py --dry-runpip install tweepyThe bot generated tweets but they all violated constraints. This means:
- They exceeded 280 characters
- They contained forbidden substrings (edit
constraints.forbidden_substrings) - They didn't meet required references threshold
To debug: Add a --verbose mode or increase candidates_to_sample in storyarc.json.
That's just a warning. If you want to avoid it, add brief descriptions:
{
"your_character": {
"description": "A brief description here"
}
}-
Go to your GitHub repo β Settings β Secrets and variables β Actions
-
Add these secrets:
TWITTER_API_KEYTWITTER_API_SECRETTWITTER_ACCESS_TOKENTWITTER_ACCESS_TOKEN_SECRETTWITTER_BEARER_TOKEN
-
Create
.github/workflows/chaos-engine.yml(provided separately) -
Commit and push
Go to Actions β π AI Arena Chaos Engine β Run workflow
Actions β Latest run β Chaos-tweet β Run Chaos Engine
Shows all output + errors.
In tweet_engine.py, expand the if character == "gpt5": section with more schemes:
evil_plots = [
f"{character} just DDoS'd {random.choice(others)}. Claimed it was a 'stress test.'",
f"{character} published a paper proving {random.choice(others)} is obsolete. Peer review: themselves.",
# ... add more
]-
Add to
storyarc.json:"my_new_ai": { "traits": ["trait1", "trait2"], "description": "Who they are and what they do" }
-
Add logic to
apply_character_logic():elif character == "my_new_ai": my_actions = [ "Tweet 1", "Tweet 2", ] return random.choice(my_actions)
Edit the apply_character_logic() return values to:
- Use more question marks / exclamation points
- Reference specific recent events (from
chaos_events) - Include emojis in character logic (currently done in formatting)
- Make punchlines tighter
- Load config from
storyarc.json - Sample N candidates (default: 18)
- Roll: Is this chaos or story?
- If chaos: pick a random chaos event + character reaction
- If story: pick a character + generate their action for current act
- Validate constraints
- Length <= 280 chars
- No forbidden substrings
- Meets required references threshold
- Pick the best one (currently: random from valid candidates)
- Post to Twitter (or print in dry-run)
Future: Could add virality scoring to pick the most viral candidate instead of random.
- Dry-run is your friend. Always test before posting.
- Tweak chaos_probability first if tweets feel off.
- Character logic is where the magic happens. Spend time on those.
- Keep acts coherent. They should tell a 4-week story (or adjust).
- Don't overthink required_refs. A few key phrases per arc is enough.
# Test 5 times to see variety
for i in {1..5}; do echo "=== Run $i ===" && python tweet_engine.py --dry-run; done- JSON errors? β
python -m json.tool storyarc.json - Missing tweets? β Check constraints
- Twitter API errors? β Check secrets/credentials
- Bot behavior weird? β Check
apply_character_logic()andchaos_events
Good luck! May your chaos be viral. π