Compare commits
2 commits
4db7d375e3
...
83751f37ca
Author | SHA1 | Date | |
---|---|---|---|
83751f37ca | |||
36d04e6cf2 |
4 changed files with 52 additions and 14 deletions
40
README.md
40
README.md
|
@ -22,33 +22,49 @@ Copy `.env.example` to `.env`:
|
||||||
- Settings > Advanced > Developer Mode: enabled
|
- Settings > Advanced > Developer Mode: enabled
|
||||||
- Right click the guild and select "Copy ID"
|
- 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_ROLE_ID` for reloading cogs
|
||||||
- `DISCORD_BOT_ADMIN_USER_ID` for reloading cogs
|
- `DISCORD_BOT_ADMIN_USER_ID` for reloading cogs
|
||||||
- `DISCORD_VCJOIN_CHANNEL` for the VCJoin cog
|
- `DISCORD_VCJOIN_CHANNEL` for the VCJoin cog
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
### ...with PDM
|
### with systemd
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pdm install --prod
|
mkdir -p /srv/discord
|
||||||
pdm run python app.py
|
cd /srv/discord
|
||||||
```
|
|
||||||
|
|
||||||
### ...with requirements.txt and virtualenv
|
sudo useradd --system -s /srv/discord discord
|
||||||
|
sudo chown -R discord:discord /srv/discord
|
||||||
|
|
||||||
```sh
|
sudo -Hu discord git clone https://git.trwnh.com/a/umi.git
|
||||||
virtualenv .venv
|
|
||||||
source .venv/bin/activate
|
python -m venv .venv
|
||||||
pip install -r requirements.txt
|
.venv/bin/pip install -r umi/requirements.txt
|
||||||
python app.py
|
|
||||||
|
sudo cp umi/umi@.service /etc/systemd/system/umi@.service
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl start umi@umi
|
||||||
```
|
```
|
||||||
|
|
||||||
### ...with Docker Compose
|
### ...with Docker Compose
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker compose build
|
mkdir -p /srv/discord
|
||||||
docker compose up -d
|
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
|
## Log into YouTube
|
||||||
|
|
|
@ -923,8 +923,8 @@ ytdl_format_options = {
|
||||||
"default_search": "auto",
|
"default_search": "auto",
|
||||||
# "source_address": "0.0.0.0", # Bind to ipv4 since ipv6 addresses cause issues
|
# "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
|
"extract_flat": True, # massive speedup for fetching metadata, at the cost of no upload date
|
||||||
#"cookiefile": "cookies.txt",
|
"cookiefile": "config/cookies.txt",
|
||||||
"cachedir": "cache",
|
"cachedir": "cache",
|
||||||
"usenetrc": True
|
#"usenetrc": True,
|
||||||
}
|
}
|
||||||
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)
|
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)
|
7
contrib/notify.sh
Normal file
7
contrib/notify.sh
Normal 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
15
contrib/umi@.service
Normal 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
|
Loading…
Add table
Reference in a new issue