# @madebydanny.uk / claude-bot # Bluesky Claude Bot (Python) A Python-based Bluesky bot that listens for mentions of `@claude.altq.net` and responds using the Claude API. # WORKS FOR altq.net PDS ONLY **PLEASE EDIT CODE TO WORK WITH YOUR PDS** ## Features - Listens for mentions on Bluesky - Uses Claude API (Claude Sonnet 4.5) to generate responses - Automatically replies to mentions - Handles long responses by splitting into thread replies - Tracks processed posts to avoid duplicates - Uses your custom prompt template for Claude responses ## Setup ### 1. Install Dependencies ```bash cd bot-python pip install -r requirements.txt ``` Or if you prefer using a virtual environment: ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt ``` ### 2. Configure Environment Variables Copy the example environment file and fill in your credentials: ```bash cp .env.example .env ``` Edit `.env` and add: - `BLUESKY_HANDLE`: Your Bluesky handle (e.g., `claude.altq.net`) - `BLUESKY_PASSWORD`: Your Bluesky app password (create one at https://bsky.app/settings/app-passwords) - `ANTHROPIC_API_KEY`: Your Anthropic API key (get one at https://console.anthropic.com/) - `BOT_HANDLE`: The handle the bot listens for (default: `claude.altq.net`) **⚠️ Security Warning:** Never commit your `.env` file to git! The `.env.example` file should only contain placeholder values. ### 3. Create a Bluesky App Password 1. Go to https://bsky.app/settings/app-passwords 2. Create a new app password 3. Use this password in the `BLUESKY_PASSWORD` environment variable ### 4. Run the Bot ```bash python bot.py ``` The bot will: 1. Log in to Bluesky 2. Start polling for mentions every 10 seconds 3. Respond to any mentions of `@claude.altq.net` (or your configured `BOT_HANDLE`) ## How It Works 1. The bot logs into Bluesky using your credentials 2. It polls for notifications every 10 seconds 3. When it finds a mention of `@claude.altq.net`, it: - Extracts the question from the post - Sends it to the Claude API with your custom prompt - Posts the response as a reply 4. Long responses are automatically split into thread replies ## Claude Prompt The bot uses a custom prompt that instructs Claude to: - Keep responses short and concise (1-2 sentences) - Write in a casual, friendly tone - Stay on topic - Avoid controversial or inappropriate content - Write suitable for direct posting on Bluesky You can modify the prompt in the `get_claude_response()` function in `bot.py`. ## Troubleshooting ### Bot not responding to mentions - Check that your credentials are correct in `.env` - Verify the bot is running and check console logs - Make sure `BOT_HANDLE` matches the handle people are mentioning - Check that your Bluesky account has permission to post replies ### API Errors - Verify your Anthropic API key is correct and has credits - Check that your Bluesky app password is valid - Ensure your Bluesky account is in good standing ### Import Errors - Make sure all dependencies are installed: `pip install -r requirements.txt` - Check that you're using Python 3.8 or higher ## Production Deployment For production, consider: - Using a process manager like `systemd`, `supervisor`, or `pm2` - Setting up monitoring and logging - Running on a cloud service (AWS, Heroku, Fly.io, etc.) - Setting up environment variables securely - Using a virtual environment ## License MIT