A Bluesky and X/Twitter bot that automatically posts fictional Cosmo Kramer quotes every 3 hours and 34 minutes, as if he were commenting on modern life in 2025 with his signature eccentric, high-energy, and scheme-hatching perspective.
- Cross-platform posting: Posts to both Bluesky and Twitter (X)
- Automatic scheduling: Posts every 3 hours and 34 minutes using a scheduler
- AI-generated quotes: Uses Google's Gemini to create unique, in-character Kramer quotes
- Duplicate prevention: Caches recent posts to avoid repeats
- Modern context: Quotes reference current technology (AirPods, TikTok, AI, Zoom, etc.) but with Kramer's unique twist
- Easy deployment: Ready to deploy
- Fallback system: Includes backup quotes if AI generation fails
- "I'm out there, Jerry, and I'm loving every minute of it!"
- "The bus is the only way to fly! You get to see the people, Jerry. The real people!"
- "My friend Bob Sacamano, he eats the whole apple. Core, stem, seeds, everything. He says it's where the power is!"
- "I'm preparing a salad as we speak in the shower! It's a multitasking revolution!"
- "Levels, Jerry! I'm building levels! Carpeted levels!"
- Bluesky Account: You need a Bluesky account and an App Password
- Google Cloud API Key: For generating quotes with Gemini
- Twitter API Access (Optional): For cross-posting to Twitter (X) using API v2
-
Clone the repository:
git clone <your-repo-url> cd Kramer-Bot
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
cp env.example .env
Edit
.envwith your credentials:# Required BLUESKY_HANDLE=your-handle.bsky.social BLUESKY_APP_PASSWORD=your-app-password GEMINI_API_KEY=your-gemini-api-key # Twitter API v2 (Optional) TWITTER_BEARER_TOKEN=your-bearer-token TWITTER_API_KEY=your-api-key TWITTER_API_SECRET=your-api-secret TWITTER_ACCESS_TOKEN=your-access-token TWITTER_ACCESS_SECRET=your-access-secret -
Run the bot:
python kramer_bot.py
- Go to Bluesky Settings
- Navigate to "App Passwords"
- Create a new app password
- Use this password in your
.envfile
- Go to the Twitter Developer Portal
- Create a new Project and App
- Under "User authentication settings":
- Enable OAuth 2.0
- Set App permissions to "Read and Write"
- Set Type of App to "Web App, Automated App or Bot"
- Set Callback URI to
https://localhost - Set Website URL to
https://github.com/Cauchon/Kramer-Bot
- Go to "Keys and tokens" and generate:
- API Key and Secret
- Access Token and Secret
- Bearer Token (under "Authentication Tokens")
-
Run the test script to verify your configuration:
python test_bot.py
-
The bot will test:
- Environment variables
- Gemini API connection
- Fallback quotes
- Twitter API configuration (if provided)
-
Connect your repository to Render.com
-
Create a new Worker Service
-
Configure the service:
- Build Command:
pip install -r requirements.txt - Start Command:
python kramer_bot.py - Environment: Python
- Build Command:
-
Add environment variables in Render dashboard:
BLUESKY_HANDLEBLUESKY_APP_PASSWORDGEMINI_API_KEYTWITTER_BEARER_TOKEN(if using Twitter API v2)TWITTER_API_KEY(if using Twitter API v2)TWITTER_API_SECRET(if using Twitter API v2)TWITTER_ACCESS_TOKEN(if using Twitter API v2)TWITTER_ACCESS_SECRET(if using Twitter API v2)
-
Deploy! The bot will start posting every 3 hours and 34 minutes.
The bot posts every 3 hours and 34 minutes by default. To change this, modify the schedule in kramer_bot.py:
schedule.every(214).minutes.do(self.post_quote)- Character limit: 280 characters (Twitter-compatible)
- AI model: gemini-flash-latest
- Temperature: Default (creative)
- Fallback quotes: 6 pre-written quotes if AI fails
- Cache size: Last 100 posts
- Storage: JSON file (
recent_posts.json) - Retry attempts: Up to 10 attempts for unique quotes
Kramer-Bot/
├── kramer_bot.py # Main bot script
├── test_bot.py # Test script for verification
├── requirements.txt # Python dependencies
├── render.yaml # Render.com deployment config
├── env.example # Environment variables template
├── README.md # This file
└── recent_posts.json # Generated cache file
The bot logs all activities to:
- Console output: Real-time logs
- File:
kramer_bot.log
Edit the get_fallback_quote() method in kramer_bot.py.
Edit the generate_kramer_quote() method to change the quote style or topics.
Modify the scheduler in run_scheduler() method.
- Authentication errors: Check your Bluesky handle and app password
- API rate limits: The bot includes retry logic for Gemini API
- Duplicate posts: Check the
recent_posts.jsoncache file - Deployment issues: Ensure all environment variables are set in Render
Check the logs for detailed error information:
tail -f kramer_bot.logFeel free to submit issues or pull requests to improve the bot!
This project is open source. Feel free to use and modify as needed.
"Giddyup!" - Cosmo Kramer