8 unstable releases (3 breaking)

Uses old Rust 2015

0.4.0 Jul 13, 2015
0.3.3 Jul 13, 2015
0.3.0 May 17, 2015
0.2.1 May 16, 2015
0.1.2 Mar 30, 2015

#40 in #irc

MIT license

72KB
1K SLoC

dazeus-rs

Rust bindings for DaZeus

Documentation

Documentation can be generated by running cargo doc in the project root. It can also be read online here.

Getting started

Unsurprisingly, these bindings require Rust to be compiled. The compiled binary only needs libc.

To create a new plugin using these bindings simply run:

cargo new [plugin-name] --bin

Then in your Cargo.toml add:

[dependencies.dazeus]
git = "https://github.com/dazeus/dazeus-rs.git"

For parsing command line options I would also suggest you use something like docopt, to use it, add this to your Cargo.toml:

[dependencies]
docopt = "0.6"

Then start by using this basic skeleton application in your main.rs:

extern crate dazeus;
extern crate docopt;

use dazeus::{DaZeus, DaZeusClient, EventType, Connection};
use docopt::Docopt;

// Write the Docopt usage string.
static USAGE: &'static str = "
A DaZeus plugin.

Usage:
    dazeus-plugin [options]

Options:
    -h, --help                  Show this help message
    -s SOCKET, --socket=SOCKET  Specify the socket DaZeus is listening to, use
                                `unix:/path/to/socket` or `tcp:host:port`
                                [default: unix:/tmp/dazeus.sock]
";

fn main() {
    let args = Docopt::new(USAGE).and_then(|d| d.parse()).unwrap_or_else(|e| e.exit());
    let socket = args.get_str("--socket");
    let dazeus = DaZeus::new(Connection::from_str(socket).unwrap());
    dazeus.subscribe(EventType::PrivMsg, |evt, dazeus| {
        // reply requires an event, and a message (the third event
        // parameter is the message sent to us)
        dazeus.reply(&evt, &evt[3], true);
    });

    // We unwrap the result, which we will retrieve when listening has failed
    dazeus.listen().unwrap();
}

Once you have set up your dependencies and created this main file you should be ready to go using cargo run, cargo should install all dependencies, compile your project and execute the result. If you don't have DaZeus running on your local machine, or if the default socket location is not what you're looking for, simply use cargo run -- --socket=[your socket].

Dependencies

~490KB
~10K SLoC