omegga 0.2.8

Experimental RPC interface for Omegga
Documentation

omegga-rs

Experimental RPC interface library for Rust.

Usage

To enable support for serializing/deserializing into brickadia-rs save objects, use the optional feature brs:

brickadia = { version = "0.2", features = "brs" }

The following is a sample plugin:

use omegga::{Omegga, rpc};
use serde_json::Value;

#[tokio::main]
async fn main() {
    let omegga = Omegga::new();
    let mut messages = omegga.spawn();

    while let Some(message) = messages.recv().await {
        match message {
            rpc::Message::Request { method, id, .. } if method == "init" || method == "stop" => {
                // just write anything so omegga knows we work
                omegga.write_response(id, None, None);

                if method == "init" {
                    omegga.write_notification("log", Some(Value::String("Hello from omegga-rs!".into())));
                }
            }
            rpc::Message::Notification { method, params, .. } if method == "chatcmd:test" => {
                let params = params.unwrap();
                let user = params.as_array().unwrap().first().unwrap().as_str().unwrap();
                omegga.write_notification("broadcast", Some(Value::String(format!("You ran the test command, {}", user))));
            }
            _ => ()
        }
    }
}

It is recommended to check the Omegga RPC reference as this library provides little abstraction.

Credits

  • voximity - creator, maintainer
  • Meshiest - Omegga