A Discord bot that monitors channels and publishes content to social media
Project description
discopilot
A Discord bot that monitors channels and publishes content to social media platforms.
Features
- 🤖 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
Installation
From PyPI
pip install discopilot
From Source
git clone https://github.com/twinko-ai/discopilot.git
cd discopilot
uv venv .venv
source .venv/bin/activate
uv pip install -e .
Configuration
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
Configuration Options
| 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) |
Usage
-
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.
Running on a Server (24/7)
Using Systemd (Linux)
-
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
Using Docker
-
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
Extending
Adding New Social Media Platforms
- 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
Development
Running Tests
# Install development dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=discopilot
Deployment
AWS Lightsail Deployment
To 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:
edit-config
orsudo nano /home/botuser/.config/discopilot/config.yaml
- Start the service:
sudo systemctl start discopilot
Maintenance Commands
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
Manual Script Usage
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file discopilot-0.1.0.tar.gz.
File metadata
- Download URL: discopilot-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ead4d6f5c3db391bbd69cf6048bfe4ddd253d2a42e055de03f0b5c81ff1c117
|
|
| MD5 |
a68f4f36d89a31e6b5b2143d608e8016
|
|
| BLAKE2b-256 |
10aca44a69f07197785cb946850cb93331d562a33dafe9fb821c609063f4c18e
|
File details
Details for the file discopilot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: discopilot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
697897b0ae2cd414332674a902719550798c53ad8604941b1c8acd444915c360
|
|
| MD5 |
c4d2a917a4ef398b8cf4d157467fc28c
|
|
| BLAKE2b-256 |
5d6340e4437f68b89e7f7178c50a1ef6d8c391af6b87e8cfc776f771c41a7e24
|