This is a bot for discord servers, which can compile and run small code blocks and return you a result.
It is using docker for running user code. Bot is written on Rust using serenity crate.
Bot has only one command - ~run
After ~run
you need to pass the multiline code block like this:
It is important to write the name of language that you are using.
After that the bot will reply on your message with output of this code like this:
By default all user programs is running with 2 seconds timeout
Default supported languages is:
python
orpy
- python3rust
orrs
- usesrustc
to compile codejavascript
orjs
- usesnodejs
c
- usesgcc
cpp
- usesg++
lua
- useslua5.3
You can extend this list by modificating docker image and adding keys to src/languages.rs
file.
Docker image is built on top of debian image.
Container runs without internet (it is connected to none
network)
Firstly, you need to install docker and rust. After that, clone this repo on your machine.
Now you need to compile the docker image.
Go to docker-image
folder inside your cloned repo, and run this command:
docker build -t ds-code-user-code .
Now you need to create .env
file inside the root folder of repository and fill it with this lines:
DOCKER_HOST=<URL_TO_DOCKER_HOST>
DISCORD_TOKEN=<YOUR_BOT_TOKEN>
Where DOCKER_HOST
- url for your docker host (as for me it is unix:///user/1000/docker.sock)
And DISCORD_TOKEN
- token of your bot.
After that steps, finally you can run project with command cargo run