Compare commits

...

8 commits

Author SHA1 Message Date
a
43ba83cf72 feature: webhook notify on systemd service start/stop 2025-03-11 22:57:02 -05:00
a
e12477369d Fix cookies loading 2024-12-20 07:23:52 +00:00
a
0dc1a5c63e Fix: Load EnvironmentFile 2024-12-01 08:26:53 +00:00
a
317885e78e Update README.md 2024-12-01 08:22:17 +00:00
a
daadc9c82d Add systemd template service unit 2024-12-01 08:13:27 +00:00
a
1bc39bc8c9 Change to using cookies bc OAuth is getting patched out 2024-11-13 23:28:05 +00:00
a
1d8121b642 Delete config/cookies.txt 2024-11-13 23:27:13 +00:00
a
a313c15911 Add config/cookies.txt 2024-11-13 23:26:47 +00:00
4 changed files with 52 additions and 14 deletions

View file

@ -22,33 +22,49 @@ Copy `.env.example` to `.env`:
- Settings > Advanced > Developer Mode: enabled
- Right click the guild and select "Copy ID"
- `DISCORD_STATUS_WEBHOOK_URL` (optional) is used to monitor when the bot fails
- Channel Settings > Integrations > New Webhook (don't forget to save changes)
- Copy Webhook URL
- `DISCORD_BOT_ADMIN_ROLE_ID` for reloading cogs
- `DISCORD_BOT_ADMIN_USER_ID` for reloading cogs
- `DISCORD_VCJOIN_CHANNEL` for the VCJoin cog
## Setup
### ...with PDM
### with systemd
```sh
pdm install --prod
pdm run python app.py
```
mkdir -p /srv/discord
cd /srv/discord
### ...with requirements.txt and virtualenv
sudo useradd --system -s /srv/discord discord
sudo chown -R discord:discord /srv/discord
```sh
virtualenv .venv
source .venv/bin/activate
pip install -r requirements.txt
python app.py
sudo -Hu discord git clone https://git.trwnh.com/a/umi.git
python -m venv .venv
.venv/bin/pip install -r umi/requirements.txt
sudo cp umi/umi@.service /etc/systemd/system/umi@.service
sudo systemctl daemon-reload
sudo systemctl start umi@umi
```
### ...with Docker Compose
```sh
docker compose build
docker compose up -d
mkdir -p /srv/discord
cd /srv/discord
sudo useradd --system -s /srv/discord discord
sudo chown -R discord:discord /srv/discord
sudo -Hu discord git clone https://git.trwnh.com/a/umi.git
cd umi
sudo docker compose build
sudo docker compose up -d
```
## Log into YouTube

View file

@ -923,8 +923,8 @@ ytdl_format_options = {
"default_search": "auto",
# "source_address": "0.0.0.0", # Bind to ipv4 since ipv6 addresses cause issues
"extract_flat": True, # massive speedup for fetching metadata, at the cost of no upload date
#"cookiefile": "cookies.txt",
"cookiefile": "config/cookies.txt",
"cachedir": "cache",
"usenetrc": True
#"usenetrc": True,
}
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

7
contrib/notify.sh Normal file
View file

@ -0,0 +1,7 @@
#!/usr/bin/bash
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{"username": "system", "content": "'"$1"'"}' \
$DISCORD_STATUS_WEBHOOK_URL

15
contrib/umi@.service Normal file
View file

@ -0,0 +1,15 @@
[Unit]
Description=Discord bot for logging VC joins and playing music
After=network.target
[Service]
Restart=on-failure
User=discord
WorkingDirectory=/srv/discord/%I
EnvironmentFile=/srv/discord/%I/.env
ExecStart=/srv/discord/.venv/bin/python -u app.py
ExecStopPost=/srv/discord/%I/notify.sh "umi instance stopped: `%i`"
ExecStartPost=/srv/discord/%I/notify.sh "umi instance started: `%i`"
[Install]
WantedBy=multi-user.target