2021-05-10 14:35:41 +02:00
|
|
|
# Compiler for Discord
|
2019-03-12 10:09:46 +01:00
|
|
|
|
2021-05-10 14:35:41 +02:00
|
|
|
Sandboxed code execution Discord bot.
|
2019-03-12 10:09:46 +01:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2019-09-05 16:32:26 +02:00
|
|
|
````cpp
|
2020-06-19 15:18:29 +02:00
|
|
|
$>```cpp
|
2019-03-15 02:58:43 +01:00
|
|
|
#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
|
2020-06-19 15:18:29 +02: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
|
|
|
|
2020-06-17 10:38:20 +02:00
|
|
|
A supported language code 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-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/)
|
2020-06-17 10:38:20 +02:00
|
|
|
2. Install [Node 14+](https://nodejs.org/)
|
2021-05-10 14:35:41 +02:00
|
|
|
3. Install [Myriad](https://github.com/1Computer1/myriad/)
|
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-05-21 02:26:28 +02:00
|
|
|
|
2019-07-11 08:27:17 +02:00
|
|
|
## Running
|
|
|
|
|
2021-05-10 14:35:41 +02:00
|
|
|
1. Run `myriad --config /path/to/config.yaml --languages /path/to/languages/`
|
2019-09-05 05:58:40 +02:00
|
|
|
2. Run `node .`
|