diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d820a8c..511cc030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,7 @@ ### 2.5.0 - Fix `rl!new` showing unsuccessful reaction when the message creation was actually successful -- Add support for translations. To translate the bot's responses make a copy of [en-gb.json](https://github.com/eibex/reaction-light/blob/master/files/i18n/en-gb.json) and translate the associated strings. Consider sharing your translation as a pull request ([#74](https://github.com/eibex/reaction-light/issues/74) closed by [#77](https://github.com/eibex/reaction-light/pull/77) by [eibex](https://github.com/eibex), [Edwinexd](https://github.com/Edwinexd), and [d7415](https://github.com/d7415)). +- Add support for translations. To translate the bot's responses make a copy of [en-gb.json](https://github.com/eibex/reaction-light/blob/master/i18n/en-gb.json) and translate the associated strings. Consider sharing your translation as a pull request ([#74](https://github.com/eibex/reaction-light/issues/74) closed by [#77](https://github.com/eibex/reaction-light/pull/77) by [eibex](https://github.com/eibex), [Edwinexd](https://github.com/Edwinexd), and [d7415](https://github.com/d7415)). ### 2.4.3 - Fix deletion of wrong database entries under certain circumstances. Please check that all your messages are working before updating, and restore a backup if necessary ([#73](https://github.com/eibex/reaction-light/issues/73) closed by [#78](https://github.com/eibex/reaction-light/pull/78) by [Edwinexd](https://github.com/Edwinexd)) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0215c88e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.9 + +COPY ./ /bot/ + +RUN python3.9 -m pip install -r /bot/requirements.txt + +# Remove local copies as these files gets mounted instead. +RUN rm -r /bot/files +RUN rm -r /bot/config.ini + +WORKDIR /bot + +CMD ["python3.9", "bot.py"] \ No newline at end of file diff --git a/README.md b/README.md index f2018e35..98ad6523 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,14 @@ Light yet powerful reaction role bot coded in Python. You can host the bot yourself by configuring the `config.ini` file (manually or via `setup.py`). ## Contents -- [Requirements](#requirements) -- [Setup](#setup) -- [Running the bot](#running-the-bot) +- [Deployment](#deployment) + - [Docker](#docker) + - [Git and Zip](#git-and-zip) - [Commands](#commands) - [Usage Example](#usage-example) - [Updating](#updating) - [Update a git install with a command](#update-a-git-install-with-a-command) + - [Manually updating a Docker installation](#manually-updating-a-docker-installation) - [Manually updating a git install](#manually-updating-a-git-install) - [Manually updating a zip install](#manually-updating-a-zip-install) - [Roadmap](#roadmap) @@ -37,17 +38,38 @@ You can host the bot yourself by configuring the `config.ini` file (manually or - [Contribute](#contribute) - [License](#license) -## Requirements -This bot requires [disnake](https://github.com/DisnakeDev/disnake) and Python 3.8+. - -You can get disnake via PyPI or GitHub: -``` -python3 -m pip install -r requirements.txt -``` - -## Setup +## Deployment +### Docker +- Clone the repository using `git clone https://github.com/eibex/reaction-light.git` (or download it as a `*.zip` file and extract it - it is recommended to use git instead of the zip archive) + - `git` comes pre-installed on most Linux-based operating systems. On Windows, if you are not familiar with git, you can use [GitHub Desktop](https://desktop.github.com/) +- Run `setup.py` and follow the instructions or create a `config.ini` file (example provided in `config.ini.sample`) or edit it manually + - Insert the token of your bot (found at: https://discord.com/developers/applications/) + - You can set most of the other values via commands later (set manually `name` and `logo`, which appear in the footer of each embed) +- Activate the message content intent for your bot (found at: https://discord.com/developers/applications/ under the bot section) +- **Optional**: Edit the `activities.csv` file (example provided in `activities.csv.sample`): + - In each row (line), add the activity the bot will display (`playing `). The bot will loop through them every 30 seconds. + - If you want a static activity just add one line. + - Do not use commas `,`. +- Build the Docker image using `docker build -t reaction-light .` +- Create and start a container using +```bash +docker run -d \ + --name reaction-light \ + --restart always \ + -v /path/to/reaction-light/files:/bot/files \ + -v /path/to/reaction-light/config.ini:/bot/config.ini \ + reaction-light +``` +- Invite the bot to your server(s) with enough permissions (Manage Roles, Manage Channels, Send Messages, Manage Messages, Add Reactions) + - You can use this link (need to replace **CLIENT_ID** with your bot's ID, visible under the general information tab): + - `https://discord.com/oauth2/authorize?&client_id=CLIENT_ID&scope=bot%20applications.commands&permissions=2415978560` +- On your Discord server, go to: `Server Settings > Roles` and move `Reaction Light` in a position that is above all roles that it needs to add/remove. The bot only has permission to manage the roles below its own role. +- Run `rl!admin @Role` to give users with that role permission to create reaction-role messages (even administrators need it). You need to be a server administrator to use this command. +### Git and Zip +- Download and install python 3.8+ and pip via your preferred method (e.g. `apt-get install python3 python3-pip`) - Clone the repository using `git clone https://github.com/eibex/reaction-light.git` (or download it as a `*.zip` file and extract it - it is recommended to use git instead of the zip archive) - `git` comes pre-installed on most Linux-based operating systems. On Windows, if you are not familiar with git, you can use [GitHub Desktop](https://desktop.github.com/) +- Install requirements via pip using `python3 -m pip install -r requirements.txt` - Run `setup.py` and follow the instructions or create a `config.ini` file (example provided in `config.ini.sample`) or edit it manually - Insert the token of your bot (found at: https://discord.com/developers/applications/) - You can set most of the other values via commands later (set manually `name` and `logo`, which appear in the footer of each embed) @@ -59,16 +81,14 @@ https://discord.com/oauth2/authorize?&client_id=CLIENT_ID&scope=bot%20applicatio - On your Discord server, go to: `Server Settings > Roles` and move `Reaction Light` (or your bot's name) in a position that is above all roles that it needs to add/remove. The bot only has permission to manage the roles below its own role. - Run `/admin add @Role` to give users with that role permission to create reaction-role messages (even administrators need it). You need to be a server administrator to use this command. -## Running the bot -The bot can be run by using: -``` -python3 bot.py -``` - -To run it as a background task (recommended unless debugging): -``` -nohup python3 bot.py & -``` +- The bot can be run by using: + ``` + python3 bot.py + ``` +- To run it as a background task (recommended unless debugging): + ``` + nohup python3 bot.py & + ``` ## Commands All commands require an admin role which you can set by using `/admin add` (requires administrator permissions on the server). The bot will reply with missing permissions otherwise. Executing a command without any argument will prompt the bot to provide you with instructions on how to use the command effectively. @@ -126,6 +146,21 @@ If you set a system channel in `config.ini`, your bot will check for new version ### Update a git install with a command Type `/bot update` to update the bot and restart it. +### Manually updating a Docker installation +- Navigate to the reaction-light directory +- Run `git pull origin master` +- Stop and delete the reaction-light container using `docker stop reaction-light && docker rm reaction-light` +- Rebuild the Docker image using `docker build -t reaction-light .` +- Create and start a new container using +```bash +docker run -d \ + --name reaction-light \ + --restart always \ + -v /path/to/reaction-light/files:/bot/files \ + -v /path/to/reaction-light/config.ini:/bot/config.ini \ + reaction-light +``` + ### Manually updating a git install - Navigate to the reaction-light directory - Run `git pull origin master` @@ -171,7 +206,7 @@ If you would like to contribute to this project, fork it and then create a pull black --line-length=130 . ``` -Even if you are not a Python programmer, you can contribute to this project by reporting bugs, requesting new features, or translating the bot in your language. To translate the bot simply copy the [English file](https://github.com/eibex/reaction-light/blob/master/files/i18n/en-gb.json) and replace the text inside the second quotes of each line. Do not replace the text within `{}`. Click [here](https://github.com/eibex/reaction-light/blob/master/files/i18n/it-it.json) for an example. +Even if you are not a Python programmer, you can contribute to this project by reporting bugs, requesting new features, or translating the bot in your language. To translate the bot simply copy the [English file](https://github.com/eibex/reaction-light/blob/master/i18n/en-gb.json) and replace the text inside the second quotes of each line. Do not replace the text within `{}`. Click [here](https://github.com/eibex/reaction-light/blob/master/i18n/it-it.json) for an example. ## License [MIT](https://github.com/eibex/reaction-light/blob/master/LICENSE) diff --git a/cogs/utils/i18n.py b/cogs/utils/i18n.py index 7faae468..8110510a 100644 --- a/cogs/utils/i18n.py +++ b/cogs/utils/i18n.py @@ -67,4 +67,4 @@ def get(self, item): language = str(config.get("server", "language", fallback="en-gb")) -response = Response(f"{directory}/files/i18n", language) +response = Response(f"{directory}/i18n", language) diff --git a/files/i18n/en-gb.json b/i18n/en-gb.json similarity index 99% rename from files/i18n/en-gb.json rename to i18n/en-gb.json index 4c65759c..3a181bcd 100644 --- a/files/i18n/en-gb.json +++ b/i18n/en-gb.json @@ -27,7 +27,7 @@ "other-author-error": "I can only edit messages that are created by me, please edit the message in some other way.", "empty-message-error": "You can't use an empty message as role-reaction message.", "edit-permission-error": "I do not have permissions to edit the message.", - "update-notification": "An update is available. Download Reaction Light **v{new_version}** at or simply use `/bot update` (only works with git installations).", + "update-notification": "An update is available. Download Reaction Light **v{new_version}** at or simply use `/bot update` (only works on Docker and git installations).", "version": "I am currently running Reaction Light **v{version}**. The latest available version is **v{latest_version}**.", "new-role-dm": "You now have the following role: **{role_name}**", "removed-role-dm": "You do not have the following role anymore: **{role_name}**", diff --git a/files/i18n/it-it.json b/i18n/it-it.json similarity index 99% rename from files/i18n/it-it.json rename to i18n/it-it.json index 1d8d76f4..58b2a49a 100644 --- a/files/i18n/it-it.json +++ b/i18n/it-it.json @@ -27,7 +27,7 @@ "other-author-error": "Posso solo modificare i messaggi creati da me, modifica il messaggio in un'altra maniera.", "empty-message-error": "Non puoi usare un messaggio vuoto.", "edit-permission-error": "Non ho i permessi per modificare il messaggio.", - "update-notification": "Un aggiornamento è disponibile. Scarica Reaction Light **v{new_version}** su o usa semplicemente `/bot update` (funziona solamente su installazioni create con git).", + "update-notification": "Un aggiornamento è disponibile. Scarica Reaction Light **v{new_version}** su o usa semplicemente `/bot update` (funziona solamente su installazioni create con Docker e git).", "version": "La mia versione attuale è Reaction Light **v{version}**. L'ultima versione disponibile è **v{latest_version}**.", "new-role-dm": "Hai ottenuto il seguente ruolo: **{role_name}**", "removed-role-dm": "Non hai più il seguente ruolo: **{role_name}**",