Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 2.03 KB

README.md

File metadata and controls

55 lines (40 loc) · 2.03 KB

DS-CODE

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.

Usage

Bot has only one command - ~run After ~run you need to pass the multiline code block like this:

image

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:

image

By default all user programs is running with 2 seconds timeout

Default supported languages

Default supported languages is:

  • python or py - python3
  • rust or rs - uses rustc to compile code
  • javascript or js - uses nodejs
  • c - uses gcc
  • cpp - uses g++
  • lua - uses lua5.3

You can extend this list by modificating docker image and adding keys to src/languages.rs file.

Docker container settings

Docker image is built on top of debian image. Container runs without internet (it is connected to none network)

Installation

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