discord-code-bot

Package to add code evaluation to discord bot


Keywords
python, discord, bot
License
BSD-2-Clause
Install
pip install discord-code-bot==0.1.2

Documentation

Discord Code BOT

Installation

pip install discord-code-bot

Usage

Create a bot with discord.py attach the CodeBot.on_message() method to your bot's on_message

from discord_code_bot import CodeBot, PYTHON  

python_bot = CodeBot(*PYTHON)

# https://discordpy.readthedocs.io/en/stable/api.html#messages
async def on_message( message):
    python_bot.on_message(message)

example

Security concerns

The code the user send is executed in an isolated docker container. There is no chance a malicious code will mess with your system

A timeout of 8 seconds has been set to prevent an unoptimized implementation of fibonacci or a while True from causing damage to the system

to change the timeout limit, provide a timeout= argument

    CodeBot(*PYTHON, timeout=15)

Notes:

works with RUBY, PYTHON, PHP: just import

from discord_code_bot import PYTHON, RUBY, PHP

note the unpacking * in CodeBot(*PYTHON)