Skip to content

Commit 30ebbcc

Browse files
authored
feat(): Dockerized toxicbot (#25)
* feat(): Dockerized toxicbot * docs(): Added Docker build documentation * fix(): Typo in documentation * fixed bash script * Updated documentation * Update README.rst * Update .env.example
1 parent 7322ba5 commit 30ebbcc

File tree

11 files changed

+156
-8
lines changed

11 files changed

+156
-8
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ToxicBot/dump/
2+
ToxicBot/env/
3+
ToxicBot/venv/
4+
ToxicBot/*.ini
5+
ToxicBot/*.log

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
PYTHON_VERSION=3.8
2+
POSTGRES_VERSION=13-alpine
3+
WORKDIR=app
4+
SECRET_DIR=secret
5+
SECRET_FILE=secret.ini
6+
IMAGE_NAME=sid200026/toxicbot
7+
IMAGE_TAG=
8+
POSTGRES_PASSWORD=
9+
POSTGRES_USER=
10+
POSTGRES_DB=
11+
POSTGRES_PORT=

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ secret.ini
66
*.log
77
dump/
88
.vscode/
9-
__pycache__/
9+
__pycache__/
10+
secret/
11+
.env

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@ All notable changes to this project will be documented in this file.
44

55
### Released
66

7+
- 2.0.0 : https://github.com/Sid200026/ToxicBot/releases/tag/v2.0.0
8+
9+
- Allows removal of users based on server limits
10+
- Allows admin to set bot configurations
11+
- Allows admin to generate server reports
12+
- Improved toxicity detection ability
13+
714
- 1.0.0 : https://github.com/Sid200026/ToxicBot/releases/tag/v1.0.0
815
- Discord Bot to detect and delete toxic messages
916

1017
### Unreleased
1118

1219
-0.0.2: https://github.com/Sid200026/ToxicBot/releases/tag/v1.0.0
13-
- Saved files for toxic comment classification ( LATEST )
20+
21+
- Saved files for toxic comment classification ( LATEST )
1422

1523
-0.0.1: https://github.com/Sid200026/ToxicBot/releases/tag/v0.0.1
16-
- Saved files for toxic comment classification ( OUTDATED )
24+
25+
- Saved files for toxic comment classification ( OUTDATED )

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ARG PYTHON_VERSION
2+
ARG WORKDIR
3+
FROM python:$PYTHON_VERSION
4+
WORKDIR /$WORKDIR
5+
COPY binary_download.sh .
6+
RUN sh binary_download.sh
7+
COPY ToxicBot/requirements.txt .
8+
RUN pip install --no-cache-dir -r requirements.txt
9+
COPY ToxicBot/ .
10+
CMD python app.py

README.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
ToxicBot
33
========
44

5+
|platform| |version| |code_style|
6+
57
**Discord bot for detecting and deleting toxic messages**
68

79
..
@@ -51,6 +53,15 @@ Prerequisites
5153
- ``pip``
5254
- Discord Developer Account
5355

56+
Docker
57+
---------
58+
59+
.. code-block:: bash
60+
61+
$ sh secret_create.sh
62+
$ docker-compose build
63+
$ docker-compose up -d
64+
5465
macOS/Linux
5566
---------
5667

@@ -65,7 +76,7 @@ Then run ``setup.sh`` in your local ``ToxicBot`` repository:
6576
.. code-block:: bash
6677
6778
$ cd ToxicBot
68-
$ bash setup.sh
79+
$ sh setup.sh
6980
7081
Source the ``activate`` file and launch the ``app.py`` Python script:
7182

@@ -162,3 +173,18 @@ Links
162173

163174
- **GitHub:** https://github.com/ToxicBot-Discord/ToxicBot/
164175
- **Discord:** https://discord.com/
176+
177+
.. |platform| image:: https://img.shields.io/badge/platform-discord-purple
178+
:alt: Platform
179+
:scale: 100%
180+
:target: https://img.shields.io/badge/platform-discord-purple
181+
182+
.. |version| image:: https://img.shields.io/badge/version-2.0.0-yellow
183+
:alt: Version
184+
:scale: 100%
185+
:target: https://img.shields.io/badge/version-2.0.0-yellow
186+
187+
.. |code_style| image:: https://img.shields.io/badge/code%20style-black-black
188+
:alt: Code Style
189+
:scale: 100%
190+
:target: https://img.shields.io/badge/code%20style-black-black

ToxicBot/commands/admin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ async def toptoxic(self, ctx, arg=None):
174174
member = ctx.author
175175
server_config = ServerConfig()
176176
SERVER_OWNER_ID = str(member.id)
177-
SERVER_ID = 0
177+
SERVER_ID = "-1"
178178
try:
179179
# Get the server config for servers that the user is an admin
180-
SERVER_ID = await server_config.getConfigFromUser(SERVER_OWNER_ID)
180+
record = server_config.getConfigFromUser(SERVER_OWNER_ID)
181+
SERVER_ID = str(record[0])
181182
except AttributeError: # Admin of multiple servers
182183
index, records = await self.askSpecificServer(ctx, server_config)
183184
if index == -1:

ToxicBot/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
discord.py==1.5.0
22
tensorflow==2.3.1
3-
Keras==2.4.3
4-
psycopg2-binary==2.8.6
3+
psycopg2-binary==2.8.6
4+
Keras==2.4.3

binary_download.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
mkdir -p dump
4+
cd dump/
5+
wget https://github.com/ToxicBot-Discord/ToxicBot/releases/download/v0.0.2/ToxicBot_GloVeEmbedding.json
6+
wget https://github.com/ToxicBot-Discord/ToxicBot/releases/download/v0.0.2/ToxicBot_Tokenizer.pickle
7+
wget https://github.com/ToxicBot-Discord/ToxicBot/releases/download/v0.0.2/ToxicBot_Weights.h5

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: "3.8"
2+
3+
services:
4+
bot:
5+
build:
6+
context: .
7+
args:
8+
PYTHON_VERSION: ${PYTHON_VERSION}
9+
WORKDIR: ${WORKDIR}
10+
image: ${IMAGE_NAME}:${IMAGE_TAG}
11+
volumes:
12+
- ./${SECRET_DIR}/${SECRET_FILE}:/${SECRET_FILE}:ro
13+
db:
14+
image: postgres:${POSTGRES_VERSION}
15+
ports:
16+
- ${POSTGRES_PORT}:${POSTGRES_PORT}
17+
environment:
18+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
19+
POSTGRES_USER: ${POSTGRES_USER}
20+
POSTGRES_DB: ${POSTGRES_DB}
21+
restart: always

0 commit comments

Comments
 (0)