Skip to content

OpenDreamProject/od-cogs

Repository files navigation

OpenDream Cogs

Overview

A collection of RedBot cogs for the OpenDream project

Cog Description
OD Compile Compiles and runs DM code using OpenDream.

odcompileset - OD Compiler Settings
odcompile - Sends code to a compilation environment and returns the results*
odcompiledebug - Sends code to be compiled using a debug build of OpenDream*

Requires: httpx

* Requires additional setup, check below for more information

Setup

RedBot:

Setup for your RedBot V3 instance is a straightforward process. Ensure that your bot runs on python 3.11 and follow the below steps to add the repo and install the cog(s).

  1. Add this repo with [p]repo add od-cogs https://github.com/OpenDreamProject/od-cogs
  2. Install the cog(s) you want to use, [p]cog install od-cogs odcompile
  3. Load the newly installed cog(s) with [p]load odcompile

To use odcompile's context commands, you'll also need to register the interactions with discord. To do so,

  1. Enable the commands with [p]slash enablecog odcompile
  2. Sync the interactions with [p]slash sync (Note: This can take up to 1-hour for Discord to fully sync the commands)

Replace [p] with your bot's prefix


ODCompile

The ODCompile cog parses provided DM code and sends it to an external environment which will compile, run, and generate an output to be returned in Discord.

In order to use this cog, you will need to either use a preestablished environment or host your own using this listener: https://github.com/OpenDreamProject/od-compiler-bot

Short one-liners can be provided in basic code-markdown, for example: world.log << "Hello, World!"

Multi-line or explicit code must be contained within a codeblock, for example:

world.log << 'Hello,'
world.log << "World!"

If you're using multiple functions, or if your code requires indentation, you must define a /proc/main() as shown below.

/proc/example()
	world.log << "I'm an example function!"

/proc/main()
	example()

Arguments

You can pass extra command line arguments to the compiler by adding them before the codeblock.

Adding --no-parsing before the codeblock will provide the full execution output instead of a parsed version.

Code will always be compiled with the latest version of OpenDream

Example screenshots
  • Quick compile
    • image
  • Compiling with multiple procs
    • image
  • Compiler warnings
    • image
  • Compiler errors
    • image
  • Passing arguments to the compiler
    • image
  • Passing multiple arguments at once and disabling the parsed output
    • image
  • Using the context menu to compile
    • context_compile

Contact:

For questions/concerns, feel free to submit a new issue.

Releases

No releases published

Packages

No packages published

Languages