diff --git a/Dockerfile b/Dockerfile index 8f33420..5f2b28d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ ARG ARCH= FROM python:3.11-slim-bullseye AS python-builder ENV DEBIAN_FRONTEND=noninteractive -WORKDIR /botamusique +WORKDIR /bragi RUN apt-get update \ && apt-get install --no-install-recommends -y gcc g++ ffmpeg libjpeg-dev libmagic-dev opus-tools zlib1g-dev \ && rm -rf /var/lib/apt/lists/* -COPY . /botamusique +COPY . /bragi RUN python3 -m venv venv \ && venv/bin/pip install wheel \ && venv/bin/pip install -r requirements.txt @@ -17,9 +17,9 @@ EXPOSE 8181 RUN apt update && \ apt install --no-install-recommends -y opus-tools ffmpeg libmagic-dev curl tar && \ rm -rf /var/lib/apt/lists/* -COPY --from=python-builder /botamusique /botamusique -WORKDIR /botamusique +COPY --from=python-builder /bragi /bragi +WORKDIR /bragi RUN chmod +x entrypoint.sh -ENTRYPOINT [ "/botamusique/entrypoint.sh" ] +ENTRYPOINT [ "/bragi/entrypoint.sh" ] CMD ["venv/bin/python", "mumbleBot.py"] diff --git a/Dockerfile.local b/Dockerfile.local index 4eb40be..a79a04d 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -3,18 +3,18 @@ ARG ARCH= FROM ${ARCH}python:3-slim-bullseye AS source ARG VERSION=master ENV DEBIAN_FRONTEND=noninteractive -WORKDIR /botamusique +WORKDIR /bragi RUN apt-get update && apt-get install -y git -RUN git clone --recurse-submodules https://github.com/azlux/botamusique.git . && git checkout $VERSION +RUN git clone --recurse-submodules https://github.com/azlux/bragi.git . && git checkout $VERSION FROM ${ARCH}python:3-slim-bullseye AS python-builder ENV DEBIAN_FRONTEND=noninteractive -WORKDIR /botamusique +WORKDIR /bragi RUN apt-get update \ && apt-get install -y gcc ffmpeg libjpeg-dev libmagic-dev opus-tools zlib1g-dev \ && rm -rf /var/lib/apt/lists/* -COPY --from=source /botamusique . +COPY --from=source /bragi . RUN python3 -m venv venv \ && venv/bin/pip install wheel \ && venv/bin/pip install -r requirements.txt @@ -22,30 +22,30 @@ RUN python3 -m venv venv \ FROM ${ARCH}node:14-bullseye-slim AS node-builder ENV DEBIAN_FRONTEND=noninteractive -WORKDIR /botamusique/web -COPY --from=source /botamusique/web . +WORKDIR /bragi/web +COPY --from=source /bragi/web . RUN npm install RUN npm run build FROM ${ARCH}python:3-slim-bullseye AS template-builder ENV DEBIAN_FRONTEND=noninteractive -WORKDIR /botamusique -COPY --from=python-builder /botamusique . -COPY --from=node-builder /botamusique/templates templates -RUN venv/bin/python scripts/translate_templates.py --lang-dir /botamusique/lang --template-dir /botamusique/web/templates +WORKDIR /bragi +COPY --from=python-builder /bragi . +COPY --from=node-builder /bragi/templates templates +RUN venv/bin/python scripts/translate_templates.py --lang-dir /bragi/lang --template-dir /bragi/web/templates FROM ${ARCH}python:3-slim-bullseye ENV DEBIAN_FRONTEND=noninteractive EXPOSE 8181 -WORKDIR /botamusique +WORKDIR /bragi RUN apt-get update \ && apt-get install -y ffmpeg libmagic-dev opus-tools zlib1g \ && rm -rf /var/lib/apt/lists/* -COPY --from=python-builder /botamusique . -COPY --from=node-builder /botamusique/static static -COPY --from=template-builder /botamusique/templates templates +COPY --from=python-builder /bragi . +COPY --from=node-builder /bragi/static static +COPY --from=template-builder /bragi/templates templates RUN chmod +x entrypoint.sh -ENTRYPOINT [ "/botamusique/entrypoint.sh" ] -CMD ["/botamusique/venv/bin/python", "/botamusique/mumbleBot.py"] +ENTRYPOINT [ "/bragi/entrypoint.sh" ] +CMD ["/bragi/venv/bin/python", "/bragi/mumbleBot.py"] diff --git a/command.py b/command.py index ca14d32..be5f4d3 100644 --- a/command.py +++ b/command.py @@ -1,4 +1,8 @@ # coding=utf-8 +# +# Bragi - A Mumble music bot +# Forked from botamusique by azlux (https://github.com/azlux/botamusque) +# import logging import secrets import datetime @@ -8,7 +12,6 @@ import pymumble_py3 as pymumble from constants import tr_cli as tr from constants import commands -import interface import util import variables as var from pyradios import RadioBrowser @@ -53,7 +56,6 @@ def register_all_commands(bot): bot.register_command(commands('remove'), cmd_remove) bot.register_command(commands('remove_tag'), cmd_remove_tag) bot.register_command(commands('repeat'), cmd_repeat) - bot.register_command(commands('requests_webinterface_access'), cmd_web_access) bot.register_command(commands('rescan'), cmd_refresh_cache, no_partial_match=True) bot.register_command(commands('search'), cmd_search_library) bot.register_command(commands('skip'), cmd_skip) @@ -65,13 +67,9 @@ def register_all_commands(bot): bot.register_command(commands('yt_search'), cmd_yt_search) # admin command - bot.register_command(commands('add_webinterface_user'), cmd_web_user_add, admin=True) bot.register_command(commands('drop_database'), cmd_drop_database, no_partial_match=True, admin=True) bot.register_command(commands('kill'), cmd_kill, admin=True) - bot.register_command(commands('list_webinterface_user'), cmd_web_user_list, admin=True) - bot.register_command(commands('remove_webinterface_user'), cmd_web_user_remove, admin=True) bot.register_command(commands('max_volume'), cmd_max_volume, admin=True) - bot.register_command(commands('update'), cmd_update, no_partial_match=True, admin=True) bot.register_command(commands('url_ban'), cmd_url_ban, no_partial_match=True, admin=True) bot.register_command(commands('url_ban_list'), cmd_url_ban_list, no_partial_match=True, admin=True) bot.register_command(commands('url_unban'), cmd_url_unban, no_partial_match=True, admin=True) @@ -647,17 +645,6 @@ def cmd_kill(bot, user, text, command, parameter): bot.exit = True -def cmd_update(bot, user, text, command, parameter): - global log - - if bot.is_admin(user): - bot.mumble.users[text.actor].send_text_message( - tr('start_updating')) - msg = util.update(bot.version) - bot.mumble.users[text.actor].send_text_message(msg) - else: - bot.mumble.users[text.actor].send_text_message( - tr('not_admin')) def cmd_stop_and_getout(bot, user, text, command, parameter): @@ -1249,88 +1236,6 @@ def cmd_refresh_cache(bot, user, text, command, parameter): bot.mumble.users[text.actor].send_text_message(tr('not_admin')) -def cmd_web_access(bot, user, text, command, parameter): - auth_method = var.config.get("webinterface", "auth_method") - - if auth_method == 'token': - interface.banned_ip = [] - interface.bad_access_count = {} - - user_info = var.db.get("user", user, fallback='{}') - user_dict = json.loads(user_info) - if 'token' in user_dict: - var.db.remove_option("web_token", user_dict['token']) - - token = secrets.token_urlsafe(5) - user_dict['token'] = token - user_dict['token_created'] = str(datetime.datetime.now()) - user_dict['last_ip'] = '' - var.db.set("web_token", token, user) - var.db.set("user", user, json.dumps(user_dict)) - - access_address = var.config.get("webinterface", "access_address") + "/?token=" + token - else: - access_address = var.config.get("webinterface", "access_address") - - bot.send_msg(tr('webpage_address', address=access_address), text) - - -def cmd_user_password(bot, user, text, command, parameter): - if not parameter: - bot.send_msg(tr('bad_parameter', command=command), text) - return - - user_info = var.db.get("user", user, fallback='{}') - user_dict = json.loads(user_info) - user_dict['password'], user_dict['salt'] = util.get_salted_password_hash(parameter) - - var.db.set("user", user, json.dumps(user_dict)) - - bot.send_msg(tr('user_password_set'), text) - - -def cmd_web_user_add(bot, user, text, command, parameter): - if not parameter: - bot.send_msg(tr('bad_parameter', command=command), text) - return - - auth_method = var.config.get("webinterface", "auth_method") - - if auth_method == 'password': - web_users = json.loads(var.db.get("privilege", "web_access", fallback='[]')) - if parameter not in web_users: - web_users.append(parameter) - var.db.set("privilege", "web_access", json.dumps(web_users)) - bot.send_msg(tr('web_user_list', users=", ".join(web_users)), text) - else: - bot.send_msg(tr('command_disabled', command=command), text) - - -def cmd_web_user_remove(bot, user, text, command, parameter): - if not parameter: - bot.send_msg(tr('bad_parameter', command=command), text) - return - - auth_method = var.config.get("webinterface", "auth_method") - - if auth_method == 'password': - web_users = json.loads(var.db.get("privilege", "web_access", fallback='[]')) - if parameter in web_users: - web_users.remove(parameter) - var.db.set("privilege", "web_access", json.dumps(web_users)) - bot.send_msg(tr('web_user_list', users=", ".join(web_users)), text) - else: - bot.send_msg(tr('command_disabled', command=command), text) - - -def cmd_web_user_list(bot, user, text, command, parameter): - auth_method = var.config.get("webinterface", "auth_method") - - if auth_method == 'password': - web_users = json.loads(var.db.get("privilege", "web_access", fallback='[]')) - bot.send_msg(tr('web_user_list', users=", ".join(web_users)), text) - else: - bot.send_msg(tr('command_disabled', command=command), text) def cmd_version(bot, user, text, command, parameter): diff --git a/configuration.default.ini b/configuration.default.ini index a4c4144..a5f6399 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -1,5 +1,6 @@ # ======================================================== -# botamusique Default Configuration File +# Bragi Default Configuration File +# Forked from botamusique by azlux # Version 6 # ======================================================== # WARNING: @@ -31,7 +32,6 @@ admin = allow_other_channel_message = False allow_private_message = True announce_current_music = True -auto_check_update = True autoplay_length = 5 avatar = bandwidth = 96000 @@ -59,28 +59,13 @@ refresh_cache_on_startup = True save_music_library = True save_playlist = True stereo = True -target_version = git tmp_folder = /tmp/ tmp_folder_max_size = 10 -username = botamusique +username = bragi volume = 0.8 when_nobody_in_channel = nothing when_nobody_in_channel_ignore = -[webinterface] -access_address = http://127.0.0.1:8181 -auth_method = none -enabled = False -flask_secret = ChangeThisPassword -is_web_proxified = True -listening_addr = 127.0.0.1 -listening_port = 8181 -max_attempts = 10 -max_upload_file_size = 30M -password = -upload_enabled = True -user = -web_logfile = [debug] ffmpeg = False @@ -102,7 +87,6 @@ user_agent = [commands] add_from_shortlist = shortlist, sl add_tag = addtag -add_webinterface_user = webuseradd change_user_password = password clear = clear command_symbol = !:! @@ -118,7 +102,6 @@ joinme = joinme kill = kill last = last list_file = listfile -list_webinterface_user = webuserlist max_volume = maxvolume mode = mode pause = pause @@ -135,16 +118,13 @@ rb_play = rbplay rb_query = rbquery remove = rm remove_tag = untag -remove_webinterface_user = webuserdel repeat = repeat -requests_webinterface_access = web rescan = rescan search = search skip = skip split_username_at_space = False stop = stop stop_and_getout = oust -update = update url_ban = urlban url_ban_list = urlbanlist url_unban = urlunban diff --git a/configuration.example.ini b/configuration.example.ini index 490b905..164f865 100644 --- a/configuration.example.ini +++ b/configuration.example.ini @@ -1,5 +1,6 @@ # ======================================================== -# botamusique example configuration file +# Bragi example configuration file +# Forked from botamusique by azlux # Version 6 # ======================================================== # Rename this file to configuration.ini after editing. @@ -22,7 +23,7 @@ port = 64738 # 'username': The bot's username. # 'comment': Comment displayed on the bot's profile. # 'avatar': Path to an image used for the bot's avatar (PNG recommended, 128 KB max). -#username = botamusique +#username = bragi #comment = "Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!" #avatar = @@ -155,46 +156,7 @@ port = 64738 # query youtube", you should provide a value here. #youtube_query_cookie = {"CONSENT": "paste your CONSENT cookie value here"} -# The [webinterface] section stores settings related to the web interface. -[webinterface] -# 'enabled': Whether to enable the web interface to allow managing your playlist, -# uploading tracks, etc. -# The web interface is disabled by default for security and performance reasons. -# 'access_address': URL provided to users when the public URL for the -# web interface is requested. -#enabled = False -#listening_addr = 127.0.0.1 -#listening_port = 8181 -#is_web_proxified = True -#access_address = http://127.0.0.1:8181 - -# 'web_logfile': If this is provided, web server access logs are written to this file. -#web_logfile = - -# 'auth_method': Method used to authenticate users accessing the web interface. -# One of 'none', 'password' or 'token'. If this is set to 'token', a unique token -# is used for authentication. -# 'max_attempts': Amount of incorrect login attempts needed before being banned. -# Regenerating a token or rebooting the bot will reset this number. -#auth_method = token -#max_attempts = 10 - -# 'user', 'password': If auth_method is set to 'password', you'll need to set -# the default username and password, which is set by these two options. -# You can add more users using the '!webadduser' command. -#user = botamusique -#password = mumble - -# 'flask_secret': To use a token, Flask needs a password to encrypt/sign cookies. -# This is absolutely necessary if auth_method is 'token'! -#flask_secret = ChangeThisPassword - -# 'upload_enabled': Whether to enable the upload function of the web interface. -# If this is False, only admins can upload files. -# 'maximum_upload_file_size': Maximum file size allowed for uploads. -# Can be specified in B, KB, MB, GB, or TB. -#upload_enabled = True -#max_upload_file_size = 30MB +# Web interface has been removed from Bragi # The [debug] section contains settings to enable debugging messaages. [debug] diff --git a/constants.py b/constants.py index 47c50b4..05b04d9 100644 --- a/constants.py +++ b/constants.py @@ -1,3 +1,8 @@ +# +# Bragi - A Mumble music bot +# Forked from botamusique by azlux (https://github.com/azlux/botamusque) +# + import os import json diff --git a/database.py b/database.py index b791244..ab64932 100644 --- a/database.py +++ b/database.py @@ -1,3 +1,8 @@ +# +# Bragi - A Mumble music bot +# Forked from botamusique by azlux (https://github.com/azlux/botamusque) +# + import os import re import sqlite3 diff --git a/entrypoint.sh b/entrypoint.sh index 01bb01c..89e8ba5 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -51,14 +51,14 @@ fi if [ -n "$BAM_CONFIG_file" ]; then if [ ! -f "$BAM_CONFIG_file" ]; then - cp "/botamusique/configuration.example.ini" "$BAM_CONFIG_file" + cp "/bragi/configuration.example.ini" "$BAM_CONFIG_file" fi command+=( "--config" "$BAM_CONFIG_file" ) else - if [ ! -f "/botamusique/configuration.ini" ]; then - cp "/botamusique/configuration.example.ini" "/botamusique/configuration.ini" + if [ ! -f "/bragi/configuration.ini" ]; then + cp "/bragi/configuration.example.ini" "/bragi/configuration.ini" fi - command+=( "--config" "/botamusique/configuration.ini" ) + command+=( "--config" "/bragi/configuration.ini" ) fi exec "${command[@]}" diff --git a/lang/en_US.json b/lang/en_US.json index 645acec..0b96ed9 100644 --- a/lang/en_US.json +++ b/lang/en_US.json @@ -36,7 +36,7 @@ "multiple_file_deleted": "Multiple items deleted from the library:", "multiple_file_found": "Found:", "multiple_matches": "File not found! Possible candidates:", - "new_version_found": "