WatchBuddies is a Discord bot which enables groups of friends to collaborate on a movie watchlist.
- WatchBuddies depends on the Discord API. Before running the script you will need to run
pip3 install discord.py
. - If you want to use the optional web server which is used to trigger the bot to restart in response to a call to a webhook, you will need to run
pip3 install flask
.
- Clone the repository and install the dependencies.
- Create a text file called
.env
in the WatchBuddies folder. This file should have 2 lines:TOKEN=replace-this-with-your-discord-api-key TMDB_API_KEY=replace-this-with-your-tmdb-api-key
The TMDB_API_KEY is not currently used, so you may choose to provide a dummy value instead. Note that future updates may integrate TMDB functionality, in which case you will need to update your .env file to include an API key.
- Configure a new Discord bot with the appropriate permissions.
There are 2 ways to run the program.
Run the program manually. Note that this will attach the script to your shell session, which may present an issue if you want to use this as a 24/7, always-on bot.
./WatchBuddies.py
Run it as a systemd service with an associated Flask server to restart the WatchBuddies script in response to a webhook. This is the recommended method.
- Create a systemd service file for the Flask server.
sudo nano /etc/systemd/system/FlaskServer.service
- Add the following content to the systemd service file, being sure to replace
path-to-repository
with the actual path on your system:[Unit] Description=Flask Server for tracking changes to WatchBuddies After=network.target [Service] User=your_username WorkingDirectory=/path-to-repository/WatchBuddies/ ExecStart=/usr/bin/python3 /path-to-repository/WatchBuddies/flask_server.py Restart=always [Install] WantedBy=multi-user.target
- Enable and start the service, then verify it's running.
sudo systemctl enable FlaskServer.service sudo systemctl start FlaskServer.service sudo systemctl status FlaskServer.service
- Create a systemd service file:
sudo nano /etc/systemd/system/WatchBuddies.service
- Add the following content to the systemd service file, being sure to replace
path-to-repository
with the actual path on your system:[Unit] Description=WatchBuddies Service After=multi-user.target [Service] Type=simple ExecStart=/usr/bin/python3 /path-to-repository/WatchBuddies/WatchBuddies.py Restart=on-abort [Install] WantedBy=multi-user.target
- Enable and start the service, then verify it's running.
sudo systemctl enable WatchBuddies.service sudo systemctl start WatchBuddies.service sudo systemctl status WatchBuddies.service
- Set up your version control system to POST a webhook to your server when there are updates to the repository. For example, if your server's IP is 1.1.1.1, you would have the webhook call http://1.1.1.1:5000/webhook.