From d0b6b935f7c1f79798117d74f65f11bb0f2b5dee Mon Sep 17 00:00:00 2001 From: Devium <108692136+devium335@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:27:41 -0400 Subject: [PATCH 1/6] Fixed Typo in README Made `sercet` into `secret` --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9fe53bf..efdec99 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Start your bot with `python main.py` TOKEN = XXXXXXXXXXXXXXXXXXXXXXXX.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXX CLIENT_ID = 123456789012345678 CLIENT_SECRET_ID = XXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXX -SERCET_KEY = DASHBOARD_SERCET_KEY +SECRET_KEY = DASHBOARD_SECRET_KEY BUG_REPORT_CHANNEL_ID = 123456789012345678 @@ -68,7 +68,7 @@ MONGODB_NAME = Vocard | TOKEN | Your Discord bot token [(Discord Portal)](https://discord.com/developers/applications) | | CLIENT_ID | Your Discord bot client id [(Discord Portal)](https://discord.com/developers/applications) | | CLIENT_SECRET_ID | Your Discord bot client secret id [(Discord Portal)](https://discord.com/developers/applications) ***(optional)*** | -| SERCET_KEY | Secret key for dashboard ***(optional)*** | +| SECRET_KEY | Secret key for dashboard ***(optional)*** | | BUG_REPORT_CHANNEL_ID | All the error messages will send to this text channel ***(optional)*** | | SPOTIFY_CLIENT_ID | Your Spoity client id [(Spotify Portal)](https://developer.spotify.com/dashboard/applications) ***(optional)*** | | SPOTIFY_CLIENT_SECRET | Your Spoity client sercret id [(Spotify Portal)](https://developer.spotify.com/dashboard/applications) ***(optional)*** | From 3b259e400301ef1cfb001c53317a6566bbc6c990 Mon Sep 17 00:00:00 2001 From: devium335 <108692136+devium335@users.noreply.github.com> Date: Tue, 16 Jul 2024 23:21:40 -0400 Subject: [PATCH 2/6] Fixed all instances of typo Fixed all instances of the typo (`sercet` to `secret`) --- .env Example | 2 +- addons/settings.py | 2 +- main.py | 2 +- web/README.md | 4 ++-- web/ipc/client.py | 2 +- web/ipc/server.py | 10 +++++----- web/webapp.py | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.env Example b/.env Example index 697b709..93877a1 100644 --- a/.env Example +++ b/.env Example @@ -1,7 +1,7 @@ TOKEN = YOUR_BOT_TOKEN CLIENT_ID = YOUR_BOT_CLIENT_ID CLIENT_SECRET_ID = YOUR_BOT_CLIENT_SECRET_ID -SERCET_KEY = DASHBOARD_SERCET_KEY +SECRET_KEY = DASHBOARD_SECRET_KEY BUG_REPORT_CHANNEL_ID = YOUR_DISCORD_CHANNEL_ID diff --git a/addons/settings.py b/addons/settings.py index b0c8f4f..c702e7b 100644 --- a/addons/settings.py +++ b/addons/settings.py @@ -25,7 +25,7 @@ class TOKENS: self.token = os.getenv("TOKEN") self.client_id = os.getenv("CLIENT_ID") self.client_secret_id = os.getenv("CLIENT_SECRET_ID") - self.sercet_key = os.getenv("SERCET_KEY") + self.secret_key = os.getenv("SECRET_KEY") self.bug_report_channel_id = int(os.getenv("BUG_REPORT_CHANNEL_ID")) self.spotify_client_id = os.getenv("SPOTIFY_CLIENT_ID") self.spotify_client_secret = os.getenv("SPOTIFY_CLIENT_SECRET") diff --git a/main.py b/main.py index 324e7a8..329682e 100644 --- a/main.py +++ b/main.py @@ -33,7 +33,7 @@ class Vocard(commands.Bot): self, host=func.settings.ipc_server["host"], port=func.settings.ipc_server["port"], - sercet_key=func.tokens.sercet_key + secret_key=func.tokens.secret_key ) async def on_message(self, message: discord.Message, /) -> None: diff --git a/web/README.md b/web/README.md index a9c1ba1..3f28090 100644 --- a/web/README.md +++ b/web/README.md @@ -4,12 +4,12 @@ Click on the image below to watch the tutorial on Youtube. [![Dashboard](https://img.youtube.com/vi/5Y5GPO95uxE/maxresdefault.jpg)](https://youtu.be/5Y5GPO95uxE) ## Configuration -1. **Fill in `CLIENT_SECRET_ID` and `SERCET_KEY` values in `.env`** +1. **Fill in `CLIENT_SECRET_ID` and `SECRET_KEY` values in `.env`** | Values | Description | | --- | --- | | CLIENT_SECRET_ID | Your Discord bot client secret id [(Discord Portal)](https://discord.com/developers/applications) ***(optional)*** | -| SERCET_KEY | Secret key for dashboard ***(optional)*** | +| SECRET_KEY | Secret key for dashboard ***(optional)*** | 2. **Add `ipc_server` configuration in `settings.json`** ```json diff --git a/web/ipc/client.py b/web/ipc/client.py index 6c67878..3162925 100644 --- a/web/ipc/client.py +++ b/web/ipc/client.py @@ -40,7 +40,7 @@ class IPCClient: data = json.loads(message) payload = { - "sercet": self.secret_key, + "secret": self.secret_key, "data": data | {"user_id": user.id, "guild_id": user.guild_id} } diff --git a/web/ipc/server.py b/web/ipc/server.py index df0894b..ecaf140 100644 --- a/web/ipc/server.py +++ b/web/ipc/server.py @@ -16,20 +16,20 @@ class IPCServer: bot: commands.Bot, host: str = "127.0.0.1", port: int = 8000, - sercet_key: Optional[str] = None + secret_key: Optional[str] = None ): self.bot = bot self.host = host self.port = port - self.sercet_key = sercet_key + self.secret_key = secret_key self.user = {} self.connections = set() def is_secure(self, data: dict) -> bool: - if (key := data.get("sercet")): - return str(key) == str(self.sercet_key) - return bool(self.sercet_key is None) + if (key := data.get("secret")): + return str(key) == str(self.secret_key) + return bool(self.secret_key is None) async def start(self): try: diff --git a/web/webapp.py b/web/webapp.py index 7f43a69..2d95bd2 100644 --- a/web/webapp.py +++ b/web/webapp.py @@ -14,7 +14,7 @@ import functools load_dotenv() app = Flask(__name__) -app.secret_key = os.getenv("SERCET_KEY") +app.secret_key = os.getenv("SECRET_KEY") socketio = SocketIO(app) # Discord OAuth2 credentials From 74bb22ccd324cd80611258d5ac12331d8c60702e Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:02:28 +0800 Subject: [PATCH 3/6] Added dashboard docker configuration --- .env Example | 3 +++ .gitignore | 3 ++- Dockerfile | 11 +++++--- docker-compose.yml | 61 +++++++++++++++++++++++++++++-------------- requirements.txt | 1 + settings Example.json | 4 +-- supervisord.conf | 17 ++++++++++++ web/webapp.py | 6 +++-- 8 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 supervisord.conf diff --git a/.env Example b/.env Example index 93877a1..606b0a7 100644 --- a/.env Example +++ b/.env Example @@ -12,3 +12,6 @@ GENIUS_TOKEN = YOUR_GENIUS_TOKEN MONGODB_URL = YOUR_MONGODB_URL MONGODB_NAME = YOUR_MONGODB_DB_NAME + +DASHBOARD_HOST = 0.0.0.0 +DASHBOARD_PORT = 5555 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8c2cfa7..51c14c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ Vocard.rar .env *.pyc -settings.json \ No newline at end of file +settings.json +logs \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 37223ce..d500667 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Use an official Python runtime as a base image FROM python:3.12-slim -# Install build dependencies -RUN apt-get update -y && apt-get install -y gcc python3-dev +# Install build dependencies and supervisor +RUN apt-get update -y && apt-get install -y gcc python3-dev supervisor # Set the working directory to /app WORKDIR /app @@ -13,5 +13,8 @@ COPY . /app # Install any needed packages specified in requirements.txt RUN pip install --no-cache-dir -r requirements.txt -# Run main.py when the container launches -CMD ["python", "-u", "main.py"] +# Copy the supervisor configuration file +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Run supervisor to manage both processes main.py and webapp.py +CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a4060f5..d7cec01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,13 @@ services: environment: - _JAVA_OPTIONS=-Xmx1G - SERVER_PORT=2333 + - LAVALINK_SERVER_PASSWORD=youshallnotpass + healthcheck: + test: 'curl -H "Authorization: youshallnotpass" -s http://localhost:2333/version' + interval: 10s + timeout: 10s + retries: 5 + start_period: 10s volumes: - ./application.yml:/opt/Lavalink/application.yml networks: @@ -15,21 +22,21 @@ services: expose: - "2333" - mongo: - image: mongo:latest - container_name: mongo - restart: unless-stopped - volumes: - - ./data/mongo/db:/data/db - - ./data/mongo/conf:/data/configdb - environment: - - MONGO_INITDB_ROOT_USERNAME=admin - - MONGO_INITDB_ROOT_PASSWORD=admin - expose: - - "27017" - networks: - - local - command: ["mongod", "--oplogSize=1024", "--wiredTigerCacheSizeGB=1", "--auth", "--noscripting"] + # mongo: + # image: mongo:latest + # container_name: mongo + # restart: unless-stopped + # volumes: + # - ./data/mongo/db:/data/db + # - ./data/mongo/conf:/data/configdb + # environment: + # - MONGO_INITDB_ROOT_USERNAME=admin + # - MONGO_INITDB_ROOT_PASSWORD=admin + # expose: + # - "27017" + # networks: + # - local + # command: ["mongod", "--oplogSize=1024", "--wiredTigerCacheSizeGB=1", "--auth", "--noscripting"] vocard: image: vocard @@ -38,12 +45,28 @@ services: dockerfile: ./Dockerfile volumes: - ./settings.json:/app/settings.json - - ./.env:/app/.env + - ./logs/supervisor/:/var/log + environment: + - TOKEN=YOUR_BOT_TOKEN + - CLIENT_ID=YOUR_BOT_CLIENT_ID + - CLIENT_SECRET_ID=YOUR_BOT_CLIENT_SECRET_ID + - SECRET_KEY=DASHBOARD_SECRET_KEY + - BUG_REPORT_CHANNEL_ID=YOUR_DISCORD_CHANNEL_ID + - SPOTIFY_CLIENT_ID=YOUR_SPOTIFY_CLIENT_ID + - SPOTIFY_CLIENT_SECRET=YOUR_SPOTIFY_CLIENT_SECRET + - GENIUS_TOKEN=YOUR_GENIUS_TOKEN + - MONGODB_URL=YOUR_MONGODB_URL + - MONGODB_NAME=YOUR_MONGODB_DB_NAME + - DASHBOARD_HOST=0.0.0.0 + - DASHBOARD_PORT=5555 + depends_on: lavalink: - condition: service_started - mongo: - condition: service_started + condition: service_healthy + # mongo: + # condition: service_started + ports: + - "5555:5555" networks: - local diff --git a/requirements.txt b/requirements.txt index 41d4156..49db6db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,3 +10,4 @@ websockets==10.4 Flask==2.2.3 Flask-SocketIO==5.3.2 psutil==5.9.5 +werkzeug==2.2.2 diff --git a/settings Example.json b/settings Example.json index e3750ce..2920f03 100644 --- a/settings Example.json +++ b/settings Example.json @@ -1,9 +1,9 @@ { "nodes": { "DEFAULT": { - "host": "127.0.0.1", + "host": "lavalink", "port": 2333, - "password": "password", + "password": "youshallnotpass", "secure": false, "identifier": "DEFAULT" } diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..3a75ad4 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,17 @@ +[supervisord] +nodaemon=true +user=root + +[program:main] +command=python -u /app/main.py +autostart=true +autorestart=true +stderr_logfile=/var/log/main.err.log +stdout_logfile=/var/log/main.out.log + +[program:webapp] +command=python -u /app/web/webapp.py +autostart=true +autorestart=true +stderr_logfile=/var/log/webapp.err.log +stdout_logfile=/var/log/webapp.out.log \ No newline at end of file diff --git a/web/webapp.py b/web/webapp.py index 2d95bd2..a2111bb 100644 --- a/web/webapp.py +++ b/web/webapp.py @@ -20,7 +20,9 @@ socketio = SocketIO(app) # Discord OAuth2 credentials CLIENT_ID = os.getenv("CLIENT_ID") CLIENT_SECRET = os.getenv("CLIENT_SECRET_ID") -REDIRECT_URI = 'http://127.0.0.1:5000/callback' +HOST = os.getenv("DASHBOARD_HOST") +PORT = os.getenv("DASHBOARD_PORT") +REDIRECT_URI = f'http://{HOST}:{PORT}/callback' DISCORD_API_BASE_URL = 'https://discord.com/api' USERS = {} @@ -208,4 +210,4 @@ def handle_message(user: User, msg): asyncio.run(ipc_client.send(msg, user)) if __name__ == '__main__': - socketio.run(app, host="127.0.0.1", port=5000) + socketio.run(app, host=HOST, port=PORT, allow_unsafe_werkzeug=True) From be63b29396e9581756aed316eed9d2fad5bc6300 Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:52:11 +0800 Subject: [PATCH 4/6] v2.6.8a update --- .env Example | 5 +- .replit | 89 ------------------------- README.md | 162 ++------------------------------------------- docker-compose.yml | 15 +---- update.py | 2 +- web/webapp.py | 9 ++- 6 files changed, 16 insertions(+), 266 deletions(-) delete mode 100644 .replit diff --git a/.env Example b/.env Example index 606b0a7..58a944f 100644 --- a/.env Example +++ b/.env Example @@ -1,7 +1,6 @@ TOKEN = YOUR_BOT_TOKEN CLIENT_ID = YOUR_BOT_CLIENT_ID CLIENT_SECRET_ID = YOUR_BOT_CLIENT_SECRET_ID -SECRET_KEY = DASHBOARD_SECRET_KEY BUG_REPORT_CHANNEL_ID = YOUR_DISCORD_CHANNEL_ID @@ -14,4 +13,6 @@ MONGODB_URL = YOUR_MONGODB_URL MONGODB_NAME = YOUR_MONGODB_DB_NAME DASHBOARD_HOST = 0.0.0.0 -DASHBOARD_PORT = 5555 \ No newline at end of file +DASHBOARD_PORT = 5555 +DASHBOARD_SERCET_KEY = DASHBOARD_SECRET_KEY +DASHBOARD_SECURE = False \ No newline at end of file diff --git a/.replit b/.replit deleted file mode 100644 index d56db40..0000000 --- a/.replit +++ /dev/null @@ -1,89 +0,0 @@ -run = "python3 main.py" - -# The primary language of the repl. There can be others, though! -language = "python3" -# A list of globs that specify which files and directories should -# be hidden in the workspace. -hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"] - -# Specifies which nix channel to use when building the environment. -[nix] -channel = "stable-22_11" - -[env] -VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv" -PATH = "${VIRTUAL_ENV}/bin" -PYTHONPATH = "${VIRTUAL_ENV}/lib/python3.10/site-packages" -REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/" -MPLBACKEND = "TkAgg" -POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry" - -# Enable unit tests. This is only supported for a few languages. -[unitTest] -language = "python3" - -# Add a debugger! -[debugger] -support = true - - # How to start the debugger. - [debugger.interactive] - transport = "localhost:0" - startCommand = ["dap-python", "main.py"] - - # How to communicate with the debugger. - [debugger.interactive.integratedAdapter] - dapTcpAddress = "localhost:0" - - # How to tell the debugger to start a debugging session. - [debugger.interactive.initializeMessage] - command = "initialize" - type = "request" - - [debugger.interactive.initializeMessage.arguments] - adapterID = "debugpy" - clientID = "replit" - clientName = "replit.com" - columnsStartAt1 = true - linesStartAt1 = true - locale = "en-us" - pathFormat = "path" - supportsInvalidatedEvent = true - supportsProgressReporting = true - supportsRunInTerminalRequest = true - supportsVariablePaging = true - supportsVariableType = true - - # How to tell the debugger to start the debuggee application. - [debugger.interactive.launchMessage] - command = "attach" - type = "request" - - [debugger.interactive.launchMessage.arguments] - logging = {} - -# Configures the packager. -[packager] -language = "python3" -ignoredPackages = ["unit_tests"] - - [packager.features] - enabledForHosting = false - # Enable searching packages from the sidebar. - packageSearch = true - # Enable guessing what packages are needed from the code. - guessImports = true - -# These are the files that need to be preserved when this -# language template is used as the base language template -# for Python repos imported from GitHub -[gitHubImport] -requiredFiles = [".replit", "replit.nix", ".config", "venv"] - -[languages] - -[languages.python3] -pattern = "**/*.py" - -[languages.python3.languageServer] -start = "pylsp" diff --git a/README.md b/README.md index efdec99..4d76fcc 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,8 @@ Click on the image below to watch the tutorial on Youtube. -## Run the Projects -[![Run on Repl.it](https://replit.com/badge/github/ChocoMeow/Vocard)](https://replit.com/new/github/ChocoMeow/Vocard) - ## Requirements * [Python 3.10+](https://www.python.org/downloads/) -* [Modules in requirements](https://github.com/ChocoMeow/Vocard/blob/main/requirements.txt) * [Lavalink Server (Requires 4.0.0+)](https://github.com/freyacodes/Lavalink) ## Quick Start @@ -42,161 +38,13 @@ git clone https://github.com/ChocoMeow/Vocard.git #Clone the repository cd Vocard #Go to the directory python -m pip install -r requirements.txt #Install required packages ``` -After installing all packages, you must configure the bot before to start! [How To Configure](https://github.com/ChocoMeow/Vocard#configuration)
+After installing all packages, you must configure the bot before to start! [How To Configure](https://docs.vocard.xyz/configuration/)
Start your bot with `python main.py` ## Configuration -1. **Rename `.env Example` to `.env` and fill all the values** -```sh -TOKEN = XXXXXXXXXXXXXXXXXXXXXXXX.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXX -CLIENT_ID = 123456789012345678 -CLIENT_SECRET_ID = XXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXX -SECRET_KEY = DASHBOARD_SECRET_KEY - -BUG_REPORT_CHANNEL_ID = 123456789012345678 - -SPOTIFY_CLIENT_ID = 0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -SPOTIFY_CLIENT_SECRET = 0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - -GENIUS_TOKEN = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - -MONGODB_URL = mongodb+srv://user:password@clusterURL -MONGODB_NAME = Vocard -``` -| Values | Description | -| --- | --- | -| TOKEN | Your Discord bot token [(Discord Portal)](https://discord.com/developers/applications) | -| CLIENT_ID | Your Discord bot client id [(Discord Portal)](https://discord.com/developers/applications) | -| CLIENT_SECRET_ID | Your Discord bot client secret id [(Discord Portal)](https://discord.com/developers/applications) ***(optional)*** | -| SECRET_KEY | Secret key for dashboard ***(optional)*** | -| BUG_REPORT_CHANNEL_ID | All the error messages will send to this text channel ***(optional)*** | -| SPOTIFY_CLIENT_ID | Your Spoity client id [(Spotify Portal)](https://developer.spotify.com/dashboard/applications) ***(optional)*** | -| SPOTIFY_CLIENT_SECRET | Your Spoity client sercret id [(Spotify Portal)](https://developer.spotify.com/dashboard/applications) ***(optional)*** | -| GENIUS_TOKEN | Your genius api key [(Genius Lyrics API)](https://genius.com/api-clients) ***(optional)*** | -| MONGODB_URL | Your Mongo datebase url [(Mongodb)](https://www.mongodb.com/) | -| MONGODB_NAME | The datebase name that you created on [Mongodb](https://www.mongodb.com/) | - -2. **Rename `settings Example.json` to `settings.json` and customize your settings** -***(Note: Do not change any keys from `settings.json`)*** -```json -{ - "nodes": { - "DEFAULT": { - "host": "127.0.0.1", - "port": 2333, - "password": "password", - "secure": false, - "identifier": "DEFAULT" - } - }, - "prefix": "?", - "activity":[ - {"listen": "/help"} - ], - "bot_access_user": [], - "embed_color":"0xb3b3b3", - "default_max_queue": 1000, - "lyrics_platform": "A_ZLyrics", - "ipc_server": { - "host": "127.0.0.1", - "port": 8000, - "enable": false - }, - "sources_settings": { - "youtube": { - "emoji": "<:youtube:826661982760992778>", - "color": "0xFF0000" - }, - "youtube music": { - "emoji": "<:youtube:826661982760992778>", - "color": "0xFF0000" - }, - "spotify": { - "emoji": "<:spotify:826661996615172146>", - "color": "0x1DB954" - }, - "soundcloud": { - "emoji": "<:soundcloud:852729280027033632>", - "color": "0xFF7700" - }, - "twitch": { - "emoji": "<:twitch:852729278285086741>", - "color": "0x9B4AFF" - }, - "bandcamp": { - "emoji": "<:bandcamp:864694003811221526>", - "color": "0x6F98A7" - }, - "vimeo": { - "emoji": "<:vimeo:864694001919721473>", - "color": "0x1ABCEA" - }, - "apple": { - "emoji": "<:applemusic:994844332374884413>", - "color": "0xE298C4" - }, - "reddit": { - "emoji": "<:reddit:996007566863773717>", - "color": "0xFF5700" - }, - "tiktok": { - "emoji": "<:tiktok:996007689798811698>", - "color": "0x74ECE9" - } - }, - "default_controller": { - "embeds": { - "active": { - "description": "**Now Playing: ```[@@track_name@@]```\nLink: [Click Me](@@track_url@@) | Requester: @@requester@@ | DJ: @@dj@@**", - "footer": { - "text": "Queue Length: @@queue_length@@ | Duration: @@track_duration@@ | Volume: @@volume@@% {{loop_mode != 'Off' ?? | Repeat: @@loop_mode@@}}" - }, - "image": "@@track_thumbnail@@", - "author": { - "name": "Music Controller | @@channel_name@@", - "icon_url": "@@bot_icon@@" - }, - "color": "@@track_color@@" - }, - "inactive": { - "header": { - "title": "There are no songs playing right now" - }, - "description": "[Support](@@server_invite_link@@) | [Invite](@@invite_link@@) | [Questionnaire](https://forms.gle/Qm8vjBfg2kp13YGD7)", - "image": "https://i.imgur.com/dIFBwU7.png", - "color": "@@default_embed_color@@" - } - }, - "default_buttons": [ - ["back", "resume", "skip", {"stop": "red"}, "add"], - ["tracks"] - ], - "disableButtonText": false - }, - "cooldowns": { - "connect": [2, 30], - "playlist view": [1, 30] - }, - "aliases": { - "connect": ["join"], - "leave": ["stop", "bye"], - "play": ["p"], - "view": ["v"] - } -} -``` -* For `nodes` you have to provide host, port, password and identifier of the [Lavalink Server](https://github.com/freyacodes/Lavalink) -* For `prefix` you can set the prefix of the bot. (If you don't provide any prefix, the bot will disable the message command). -* For `activity` you can set the activity of the bot. [Example Here](https://github.com/ChocoMeow/Vocard/blob/main/PLACEHOLDERS.md#bot-activity-activity-are-updated-every-10-minutes) -* For `bot_access_user` you can pass the [discord user id](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-). Example: `[123456789012345678]` -* For `embed_color` you must pass a [Hexadecimal color code](https://htmlcolorcodes.com/) and add `0x` before the color code. Example: `"0xb3b3b3"` -* For `default_max_queue` you can set a default maximum number of tracks that can be added to the queue. -* For `lyrics_platform` you can set lyrics search engine (e.g. `A_ZLyrics`, `Genius`, `lyrist`)
**NOTE: If you are using Genius as your lyrics search engine, you must install the lyricsgenius module (`pip install lyricsgenius`)** -* For `ipc_server` you can set the host, password and enable of the ipc server. -* For `emoji_source_raw` you can change the source emoji of the track with discord emoji like `<:EMOJI_NAME:EMOJI_ID>` -* For `cooldowns` you can set a custom cooldown in the command. Example: `"command_name": [The total number of tokens available, The length of the cooldown period in seconds]` -* For `aliases` you can set custom aliases in the command. Example: `"command_name": [alias1, alias2, ...]` -* For `default_controller` you can set custom embeds and buttons in controller, [Example Here](https://github.com/ChocoMeow/Vocard/blob/main/PLACEHOLDERS.md#controller-embeds) +1. Rename `.env Example` to `.env` and [customize your env](https://docs.vocard.xyz/configuration/#settings-up-env). +2. Rename `settings Example.json` to `settings.json` and [customize your settings](https://docs.vocard.xyz/configuration/#settings-up-settingsjson). +3. Now, you can start your bot with `python main.py`. ## How to update? (For Windows and Linux) ***Note: Make sure there are no personal files in the directory! Otherwise it will be deleted.*** @@ -212,4 +60,4 @@ python update.py -v VERSION # Install the beta version python update.py -b -``` +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d7cec01..58601f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -45,21 +45,8 @@ services: dockerfile: ./Dockerfile volumes: - ./settings.json:/app/settings.json + - ./.env:/app/.env - ./logs/supervisor/:/var/log - environment: - - TOKEN=YOUR_BOT_TOKEN - - CLIENT_ID=YOUR_BOT_CLIENT_ID - - CLIENT_SECRET_ID=YOUR_BOT_CLIENT_SECRET_ID - - SECRET_KEY=DASHBOARD_SECRET_KEY - - BUG_REPORT_CHANNEL_ID=YOUR_DISCORD_CHANNEL_ID - - SPOTIFY_CLIENT_ID=YOUR_SPOTIFY_CLIENT_ID - - SPOTIFY_CLIENT_SECRET=YOUR_SPOTIFY_CLIENT_SECRET - - GENIUS_TOKEN=YOUR_GENIUS_TOKEN - - MONGODB_URL=YOUR_MONGODB_URL - - MONGODB_NAME=YOUR_MONGODB_DB_NAME - - DASHBOARD_HOST=0.0.0.0 - - DASHBOARD_PORT=5555 - depends_on: lavalink: condition: service_healthy diff --git a/update.py b/update.py index 2342263..482af02 100644 --- a/update.py +++ b/update.py @@ -2,7 +2,7 @@ import requests, zipfile, os, shutil, argparse from io import BytesIO ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) -__version__ = "v2.6.8" +__version__ = "v2.6.8a" GITHUB_API_URL = "https://api.github.com/repos/ChocoMeow/Vocard/releases/latest" VOCARD_URL = "https://github.com/ChocoMeow/Vocard/archive/" diff --git a/web/webapp.py b/web/webapp.py index a2111bb..d273bd1 100644 --- a/web/webapp.py +++ b/web/webapp.py @@ -1,4 +1,4 @@ -from flask import Flask, redirect, url_for, session, request, render_template, abort, Response, stream_with_context +from flask import Flask, redirect, url_for, session, request, render_template, Response, stream_with_context from flask_socketio import SocketIO, emit, join_room, leave_room, rooms, disconnect from ipc import IPCClient from objects import User @@ -14,7 +14,7 @@ import functools load_dotenv() app = Flask(__name__) -app.secret_key = os.getenv("SECRET_KEY") +app.secret_key = os.getenv("DASHBOARD_SERCET_KEY") socketio = SocketIO(app) # Discord OAuth2 credentials @@ -22,7 +22,10 @@ CLIENT_ID = os.getenv("CLIENT_ID") CLIENT_SECRET = os.getenv("CLIENT_SECRET_ID") HOST = os.getenv("DASHBOARD_HOST") PORT = os.getenv("DASHBOARD_PORT") -REDIRECT_URI = f'http://{HOST}:{PORT}/callback' +IS_SECURE = os.getenv("DASHBOARD_SECURE", "False").lower() == "true" + +print(IS_SECURE, HOST, PORT) +REDIRECT_URI = f'http{'s' if IS_SECURE else ''}://{HOST}:{PORT}/callback' DISCORD_API_BASE_URL = 'https://discord.com/api' USERS = {} From f1e1ad9cbec96b919a8deb20f2d565840f93b405 Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:01:55 +0800 Subject: [PATCH 5/6] Update webapp.py --- web/webapp.py | 1 - 1 file changed, 1 deletion(-) diff --git a/web/webapp.py b/web/webapp.py index d273bd1..6fea2dd 100644 --- a/web/webapp.py +++ b/web/webapp.py @@ -24,7 +24,6 @@ HOST = os.getenv("DASHBOARD_HOST") PORT = os.getenv("DASHBOARD_PORT") IS_SECURE = os.getenv("DASHBOARD_SECURE", "False").lower() == "true" -print(IS_SECURE, HOST, PORT) REDIRECT_URI = f'http{'s' if IS_SECURE else ''}://{HOST}:{PORT}/callback' DISCORD_API_BASE_URL = 'https://discord.com/api' From 0af452b590a428f07600861364196676f9076b9c Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:43:05 +0800 Subject: [PATCH 6/6] Update webapp.py --- web/webapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/webapp.py b/web/webapp.py index 6fea2dd..835f498 100644 --- a/web/webapp.py +++ b/web/webapp.py @@ -212,4 +212,4 @@ def handle_message(user: User, msg): asyncio.run(ipc_client.send(msg, user)) if __name__ == '__main__': - socketio.run(app, host=HOST, port=PORT, allow_unsafe_werkzeug=True) + socketio.run(app, host="0.0.0.0", port=PORT, allow_unsafe_werkzeug=True)