compiler-discord/README.md

81 lines
1.8 KiB
Markdown
Raw Normal View History

2019-03-12 10:09:46 +01:00
# Comp_iler
2019-05-17 02:29:24 +02:00
Sandboxed code execution discord bot.
2019-09-05 16:32:26 +02:00
[**Invite the bot!**](https://discordapp.com/oauth2/authorize?client_id=555066722969714728&scope=bot)
*Not all languages are enabled on the public bot.*
2019-03-12 10:09:46 +01:00
## Usage
2019-09-05 16:32:26 +02:00
````cpp
2019-03-15 02:58:43 +01:00
>```cpp
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
}
2019-03-12 10:09:46 +01:00
```
2019-05-15 03:05:12 +02:00
````
2019-03-12 10:09:46 +01:00
2019-09-05 16:32:26 +02:00
```py
2019-03-12 10:09:46 +01:00
>`py print('hello world')`
2019-05-15 03:05:12 +02:00
```
2019-03-12 10:09:46 +01:00
2019-03-15 02:58:43 +01:00
## Supported Languages and Options
2019-03-12 10:09:46 +01:00
2019-03-15 02:58:43 +01:00
One of the following language codes is set in `lang`.
2019-07-22 01:04:52 +02:00
You can see all the possible codes using the `languages` command in the bot.
2019-03-12 10:09:46 +01:00
2019-05-25 21:03:40 +02:00
- `apl` APL
- `bash` Bash
2019-05-23 04:26:55 +02:00
- `bf` Brainfuck
2019-07-11 08:27:17 +02:00
- `c` C
- `clj` Clojure
2019-07-11 08:27:17 +02:00
- `cpp` C++
- `cs` C#
- `elixir` Elixir
2019-07-11 08:27:17 +02:00
- `fs` F#
- `go` Go
2019-07-11 08:27:17 +02:00
- `hs` Haskell
2019-07-22 01:04:52 +02:00
- `idr` Idris
2019-07-11 08:27:17 +02:00
- `java` Java
- `js` JavaScript
- `julia` Julia
- `lisp` Racket
- `lua` Lua
- `ocaml` OCaml
2019-07-11 08:27:17 +02:00
- `pas` Pascal
- `php` PHP
- `pl` Perl5
2019-07-11 08:27:17 +02:00
- `prolog` Prolog
- `py` Python
- `rb` Ruby
- `rs` Rust
2019-05-15 02:24:16 +02:00
## How it Works
2019-07-11 08:27:17 +02:00
For every language there is a docker image which spins up a docker container.
2019-05-15 02:24:16 +02:00
The container is used for all evaluations of code, restarting if something goes wrong.
The container is locked down, so there is no networking, limited memory and CPU usage, and a time limit.
## Setup
2019-09-05 05:58:40 +02:00
1. Install [Docker 18+](https://www.docker.com/)
2. Install [Node 10+](https://nodejs.org/)
3. Install [Myriad](https://github.com/1Computer1/myriad/)
- This will require [GHC and Cabal](https://www.haskell.org/).
2019-07-11 08:27:17 +02:00
- You will also have to configure Myriad, see its repository.
2019-09-05 05:58:40 +02:00
4. Fill out `config.json`
2019-07-11 08:27:17 +02:00
- `owner` The owner(s) of the bot. Use an array for multiple owners.
- `token` The bot token.
- `prefix` The prefix for commands.
- `codePrefix` The prefix for code evaluation.
- `myriad` The port that Myriad is running on.
2019-09-05 05:58:40 +02:00
5. Run `npm i`
2019-07-11 08:27:17 +02:00
## Running
2019-09-05 16:32:26 +02:00
1. Run `myriad --config /path/to/config.dhall --languages /path/to/languages/`
2019-09-05 05:58:40 +02:00
2. Run `node .`