A Discord bot that monitors channels and publishes content to social media platforms.
- 🤖 Monitor Discord channels for specific emoji reactions
- 📢 Publish messages to Twitter (X) and other social media platforms
- 🔄 Smart rate limiting to prevent API throttling
- 🧙♂️ Named after Hedwig from Harry Potter - your magical messenger
pip install discopilot
git clone https://github.com/twinko-ai/discopilot.git
cd discopilot
uv venv .venv
source .venv/bin/activate
uv pip install -e .
DiscoPilot requires a configuration file to run. You can set up your configuration in one of these ways:
-
Automatic setup:
discopilot-setupThis will create a configuration file at
~/.config/discopilot/config.yaml. -
Manual setup:
- Copy the example configuration from
examples/config.example.yaml - Place it in one of these locations:
- The current working directory as
config.yaml - Your home directory at
~/.config/discopilot/config.yaml
- The current working directory as
- Edit the file with your Discord token and other settings
- Copy the example configuration from
-
Environment variable:
- Set the
DISCOPILOT_CONFIGenvironment variable to the path of your config file
export DISCOPILOT_CONFIG=/path/to/your/config.yaml - Set the
| Option | Description | Required |
|---|---|---|
discord.token |
Your Discord bot token | Yes |
discord.server_ids |
List of server IDs the bot should listen to (empty = all servers) | No |
admin_ids |
List of Discord user IDs that can trigger publishing | Yes |
triggers.emoji |
The emoji that triggers publishing | No (default: 📢) |
twitter.api_key |
Twitter API key | Yes (for Twitter) |
twitter.api_secret |
Twitter API secret | Yes (for Twitter) |
twitter.access_token |
Twitter access token | Yes (for Twitter) |
twitter.access_secret |
Twitter access token secret | Yes (for Twitter) |
twitter.bearer_token |
Twitter bearer token | Yes (for Twitter) |
-
Invite your bot to your Discord server using the OAuth2 URL from the Discord Developer Portal.
-
Send a message in any channel where the bot has access.
-
React to the message with the configured emoji (default: 📢). Note: Only users listed in
admin_idscan trigger publishing. -
The bot will publish the message to configured social media platforms and reply with the results.
-
Create a systemd service file:
sudo nano /etc/systemd/system/discopilot.service
-
Add the following content (adjust paths as needed):
[Unit] Description=DiscoPilot Discord Bot After=network.target [Service] User=yourusername WorkingDirectory=/path/to/working/directory ExecStart=/path/to/python -m discopilot.scripts.run_bot Restart=always RestartSec=10 StandardOutput=syslog StandardError=syslog SyslogIdentifier=discopilot [Install] WantedBy=multi-user.target -
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable discopilot sudo systemctl start discopilot
-
Create a Dockerfile:
FROM python:3.11-slim WORKDIR /app COPY . . RUN pip install -e . CMD ["python", "-m", "discopilot.scripts.run_bot"]
-
Build and run:
docker build -t discopilot . docker run -d --name discopilot --restart unless-stopped \ -v /path/to/config.yaml:/root/.config/discopilot/config.yaml discopilot
- Create a new publisher class in
discopilot/publishers/ - Implement the
publish()andcheck_rate_limit()methods - Add your publisher to the bot's
setup_publishers()method
# Install development dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=discopilotTo deploy DiscoPilot on AWS Lightsail:
- Go to the AWS Lightsail console
- Click "Create instance"
- Choose a location (AWS Region) close to you
- Select "Linux/Unix" platform
- Choose "Ubuntu 24.04 LTS" as the blueprint
- Click "Add launch script" and paste the content of
scripts/deployment/lightsail_launch.sh - Use default SSH key or create a new one
- Enable automatic snapshots
- Select network type
- Select the instance plan like $5/month
- Name your instance (e.g., "discopilot")
- Click "Create instance"
After the instance is created:
- Connect to your instance via SSH
- Update the configuration file:
or
edit-config
sudo nano /home/botuser/.config/discopilot/config.yaml
- Start the service:
sudo systemctl start discopilot
The following commands are available after deployment:
update-bot: Pull the latest code from GitHub, update scripts, reinstall dependencies, and restart the botrestart-bot: Restart the bot without updatingbot-logs: View the bot's logs in real-timeedit-config: Edit the bot configuration file
If you prefer to run the scripts directly instead of using the aliases:
/usr/local/bin/update_discopilot.sh: Update the bot from GitHub and restart/usr/local/bin/restart_discopilot.sh: Restart the bot without updating/usr/local/bin/run_discopilot.sh: Run the bot manually (used by the systemd service)/usr/local/bin/update-discopilot-scripts.sh: Update the scripts in /usr/local/bin with the latest versions from the repository