-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from r-Norge/dev
Update bot with lots of new features.
- Loading branch information
Showing
49 changed files
with
2,215 additions
and
1,594 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,17 @@ name: Test And Build BOT | |
on: [push, pull_request] | ||
|
||
jobs: | ||
flake8: | ||
lint: | ||
runs-on: ubuntu-latest | ||
env: | ||
CheckFiles: "bot.py musicbot/" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v1 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4.2.0 | ||
with: | ||
python-version: 3.8 | ||
python-version: 3.10.7 | ||
|
||
- name: Lint with flake8 | ||
run: | | ||
|
@@ -24,23 +24,27 @@ jobs: | |
pip install isort | ||
isort --check --sp setup.cfg ${CheckFiles} | ||
- name: Sort with Isort | ||
if: failure() | ||
run: | | ||
isort --sp setup.cfg ${CheckFiles} | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Create Pull Request | ||
if: failure() | ||
uses: peter-evans/create-pull-request@v2 | ||
- name: Set up Python 3.10 | ||
uses: actions/[email protected] | ||
with: | ||
token: ${{ secrets.GH_TOKEN }} | ||
branch: actions/auto | ||
commit-message: Changes done by tests | ||
committer: Roxedus <[email protected]> | ||
title: Linter changed files | ||
python-version: 3.10.7 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install pytest | ||
pip install -r requirements.txt | ||
- name: Run pytest | ||
run: | | ||
pytest | ||
build-and-push: | ||
needs: flake8 | ||
needs: [lint, test] | ||
runs-on: ubuntu-latest | ||
if: github.event_name != 'pull_request' && contains(github.ref, 'actions') != 'true' | ||
env: | ||
|
@@ -60,17 +64,6 @@ jobs: | |
echo "::set-output name=username::$(echo ${_username} | cut -d/ -f1 | tr '[:upper:]' '[:lower:]')" | ||
echo "::set-output name=repo::$(echo ${_repo} | tr '[:upper:]' '[:lower:]')" | ||
- name: Bump TAG | ||
if: github.ref == 'refs/heads/master' | ||
id: tagger | ||
run: | | ||
version=$(grep -i bot_version musicbot/utils/bot_version.py | cut -d" " -f3 | tr -d \") | ||
a=(${version//./ }) | ||
((a[2]++)) | ||
new_version=$(echo "${a[0]}.${a[1]}.${a[2]}") | ||
sed -i "s/${version}/${new_version}/g" musicbot/utils/bot_version.py | ||
echo "::set-output name=tag::${new_version}" | ||
- name: Push changed files, and tags | ||
if: github.ref == 'refs/heads/master' | ||
uses: EndBug/add-and-commit@v4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM amd64/python:3.8.3-alpine | ||
FROM python:3.10.7-alpine | ||
|
||
LABEL maintainer="Roxedus" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,113 @@ | ||
# WIP - Shite Music Bot | ||
# Shite Music Bot | ||
|
||
[](https://jenkins.roxedus.net/job/MusicBot/job/dev/) | ||
[](https://microbadger.com/images/rnorge/music:dev-amd64 "Get your own image badge on microbadger.com") | ||
A discord music bot you can host yourself! | ||
|
||
## Features | ||
|
||
- Translations, get the bot in your preferred langauge! Works for both commands and replies. | ||
- Round Robin style queue, you won't have to wait forever for your songs to play. | ||
- Interactive menus | ||
- Translations, get the bot in your preferred language! Works for both commands and replies. | ||
- Noice per server customization options, including per server localization. | ||
- Toit embeds. | ||
- DJ roles. Grants members in the role some more control over the queue. | ||
- Sound-manipulation features, bass boost and nightcore. | ||
- Lyrics command that sometimes gives the correct lyrics | ||
- DJ roles | ||
|
||
### Setup | ||
### Fair queue behavior | ||
|
||
Each user has their own queue and the bot mixes them together for fair time sharing. | ||
|
||
 | ||
|
||
### Interactive menus | ||
|
||
 | ||
|
||
 | ||
|
||
## Requirements | ||
|
||
- Python 3.10 or greater | ||
- A [lavalink](https://github.com/Freyacodes/Lavalink) server | ||
|
||
## Setup | ||
|
||
1. Change or copy data/config.yaml.example to config.yaml | ||
2. Create or find a [lavalink](https://github.com/Frederikam/Lavalink) server you can use. | ||
3. Add your bot token and lavalink server to the bot settings in your config.yaml. | ||
4. Edit any other settings you want. | ||
5. (Optional but recommended) Create a virtual environment and activate it. | ||
6. install requirements `python -m pip install -r requirements.txt` | ||
7. run the bot `python bot.py` :) | ||
- If using docker, the config file will be moved into `/data` on the first run. | ||
2. Configure Lavalink | ||
- When self-hosting: | ||
- Get a `application.yml` file from your lavalink distribution, to provide lavalink. | ||
- Secure the instance by changing the password. | ||
- This bot is written with the Youtube, Soundcloud, Bandcamp and Vimeo source in mind. Others might work | ||
- Self-hosted and hosted: | ||
- Configure the bot to connect to your nodes. | ||
- If you wish to pre-seed the bot with lavalink nodes, you can do so in `data/config.yml` | ||
|
||
```yml | ||
lavalink nodes: | ||
- host: localhost | ||
port: 2333 | ||
password: youshallnotpass | ||
region: eu | ||
name: main | ||
``` | ||
3. Add your bot token to `config.yaml`. | ||
4. Prepare your environment: | ||
- Native install: | ||
- Clone, and enter the repository. | ||
- `git clone https://github.com/r-Norge/ShiteMusicBot.git && cd ShiteMusicBot` | ||
- (Recommended) Create a virtual environment and activate it. | ||
- `python3 -m pip venv .venv && . .venv/bin/activate` | ||
- Install requirements `python3 -m pip install -r requirements.txt` | ||
- Docker Compose: | ||
- Copy the example that fits your needs | ||
- Change the volume path(s) to store persistent data on your host. | ||
- `docker compose pull` | ||
5. Run the bot: | ||
- Native install: | ||
- `python3 bot.py` | ||
- Docker Compose: | ||
- `docker compose run -d` | ||
6. Make sure the bot responds, by invoking the info command. `@ShiteMusicBot info`, substitute `ShiteMusicBot` with the name of your bot. | ||
|
||
### Docker | ||
### Docker Compose Example | ||
|
||
### Compose Example | ||
#### Self-hosted lavalink | ||
|
||
````yaml | ||
```yaml | ||
version: '3' | ||
networks: | ||
internal: | ||
driver: bridge | ||
services: | ||
backbone: | ||
lavalink: | ||
hostname: lavalink | ||
image: fredboat/lavalink:dev | ||
ports: | ||
- 2333:2333 | ||
networks: | ||
internal: | ||
aliases: | ||
- lavalink | ||
- internal | ||
volumes: | ||
- /compose/BottStack/lavalink/application.yml:/opt/Lavalink/application.yml | ||
- ./application.yml:/opt/Lavalink/application.yml | ||
bot: | ||
container_name: ProdMaster | ||
container_name: ShiteMusicBot | ||
image: rnorge/music | ||
networks: | ||
- internal | ||
command: python3 bot.py | ||
volumes: | ||
- /compose/BottStack/ProdBetaMaster/script:/diks | ||
- /compose/BottStack/ProdBetaMaster/data:/app/data | ||
```` | ||
- ./data:/app/data | ||
``` | ||
|
||
#### Hosted lavalink | ||
|
||
```yaml | ||
version: '3' | ||
services: | ||
bot: | ||
container_name: ShiteMusicBot | ||
image: rnorge/music | ||
command: python3 bot.py | ||
volumes: | ||
- ./data:/app/data | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
env_name := "venv" | ||
python := "./" + env_name+'/bin/python3' | ||
|
||
default: | ||
@just --list | ||
|
||
# Make a new virtual environment | ||
[private] | ||
make_venv: | ||
python3.10 -m venv {{env_name}} | ||
{{python}} -m pip install --upgrade pip | ||
{{python}} -m pip install -r requirements.txt | ||
{{python}} -m pip install flake8 | ||
{{python}} -m pip install isort | ||
{{python}} -m pip install pytest | ||
|
||
# Make the environment if it does not exit | ||
[private] | ||
@venv: | ||
[ -d {{env_name}} ] || just make_venv | ||
|
||
# Run the bot | ||
run: venv | ||
{{python}} bot.py | ||
|
||
# Run with debug logging enabled | ||
debug: run | ||
--debug | ||
|
||
clean: | ||
rm -rf {{env_name}} | ||
# Lint with flake8 | ||
flake: venv | ||
{{python}} -m flake8 bot.py musicbot | ||
|
||
# Fix import order with isort | ||
isort: venv | ||
{{python}} -m isort --sp setup.cfg bot.py musicbot | ||
|
||
# Run both isort and flake8 | ||
lint: venv | ||
just isort | ||
just flake | ||
|
||
# Run tests | ||
test: venv | ||
{{python}} -m pytest | ||
|
||
# Run lints and test | ||
pre_commit: venv | ||
just lint | ||
just test | ||
|
Oops, something went wrong.