discord invite link.
- python / py
- cpp / c++
- C
- javascript / js (node.js)
- go
- Java
- php (cli does not give you files back currently)
more languages can easily be added by adding a procedure for the language in Codescord.Common.languages.Languages
, pointing to that procedure in Codescord.Server.server.Server.languages (in its init)
and update the docker image to contain the runtime/compilers necessary.
PRs are welcome :)
There are two ways to execute highlighted code blocks. This is a setting and can be changed
with /codescord auto-run on.
OBS! The first text after the tipple ``` is what determines how the code will be run on the server side.
```python for python ```c++ for c++ etc.
OBS! a new line after the language name is required. see usage and example bellow.
If disabled it can be re-enabled with /codescord auto-run off
To execute a highlighted code block in this setting simply use:
/run```py
print("hello world")
```
Manual run can also accept system arguments:
/run 123 456 789```py
import sys
print(sys.argv[1:] if len(sys.argv) > 1 else "No sys args")
```
To enable this feature run: /codescord auto-run on in one of your servers
text channels the bot can read. When it is enabled
simply send a discord message with a highlighted code block.
My code is so cool!
```python
print("hello world!")
```
My code is so cool!
/run```py
print("hello world")
```
My code is so cool!
/run
print("hello world!")hello world!
- python3.8+
- python packages:
- discord.py
- tortoise-orm
- aiosqlite
- docker
- install python3.8+ (source from official python site or deadsnakes ppa)
- install docker
- set the environment variable
DISCORD_CODESCORDwith the value of your bot token.
OBS! must be visible to sudo.
add in for example/etc/environmentwith a new line at the bottomexport DISCORD_CODESCORD="your token" - make sure localhost is able to go through your desired port range for the application. for each docker container
that is started one port in the range is used and another container will be queued to open until the process in some
already running container is done and the used port is freed. each container uses about 30 MB of RAM.
the default port range is 6090:6096 but can be changed with the
-poption formain.py.
git clone https://github.com/EliasEriksson/Codescord.gitcd Codescordpython3.x -m venv venvsource ven/bin/activatepython -m pip install -r requirements.txtsudo venv/bin/python main.py build-docker-imagepython main.py create-databasesudo venv/bin/python main.py
(this runs the client with the default arguments:
sudo venv/bin/python main.py -p 6090:6096 client)
- modify the provided service file to your system/needs.
As a minimum the path to python and
main.pyneeds to be changed. ifCodescord/is located in/home/<user>/Apps/tha paths in ExecStart should be:
ExecStart=/home/<user>/Apps/Codescord/venv/bin/python /home/<user>/Apps/Codescord/main.py sudo cp codescord.service /lib/systemd/systemsudo systemctl daemon-reload- to enable on system startup:
sudo systemctl enable codescord.service sudo systemctl start codescord.service- to stop:
sudo systemctl stop codescord.service - to remove from startup:
sudo systemctl disable codescord.service