Crate dazeus [] [src]

DaZeus IRC bot bindings for Rust.

For using these bindings you will need to setup a dazeus-core instance. For users using OSX and Homebrew, a tap is available.

The best way to get started is by using the connection_from_str function provided. It allows the creation of a Connection, which can be fed directly to the DaZeus::new constructor.

Creating a new connection can now be done using the following basic snippet:

let dazeus = DaZeus::new(Connection::from_str(socket).unwrap());

After having created an instance of DaZeus you can start sending commands using one of the methods provided. Alternatively you can send Request objects directly using the DaZeusClient::send() method, however this is generally not recommended.

You can register new listeners using the DaZeus::subscribe() and DaZeus::subscribe_command() methods. You provide these with functions which will be called every time such an event occurs.

After you have enabled any event subscribers you need to use the DaZeus::listen() method, or check for new events manually using DaZeus::try_next_event().

Examples

The example below creates a simple echo server which responds to some PrivMsg with the exact same reply, only prepending the user that sent the message, so that a highlight is created in IRC clients configured as such.

let socket = "unix:/tmp/dazeus.sock";
let dazeus = DaZeus::new(Connection::from_str(socket).unwrap());
dazeus.subscribe(EventType::PrivMsg, |evt, dazeus| {
    dazeus.reply(&evt, &evt[3], true);
});
dazeus.listen();

The example below creates a connection to the DaZeus server and then immediately joins a channel, and waits for a response until the join was confirmed by the DaZeus core. Note how this is just a short-run command, in contrast to the previous example that will keep running for as long as it can.

let socket = "unix:/tmp/dazeus.sock";
let dazeus = DaZeus::new(Connection::from_str(socket).unwrap());
dazeus.join("local", "#test");

Structs

DaZeus

The base DaZeus struct.

Event

An event received from the DaZeus server.

InvalidJsonError

Error returned when the passed Json did not have the required structure.

ParseConfigGroupError

Error returned when a string could not be parsed as a ConfigGroup.

ParseEventTypeError

Error returned when a string could not be parsed as an EventType.

ReceiveError

Error when an unexpected or invalid response was received from DaZeus

Response

The response from a command send to the DaZeus server.

Scope

A scope for retrieving permissions and properties.

Enums

ConfigGroup

The type of config that should be retrieved.

Connection

A connection enum that encapsulates TCP and Unix sockets.

Error
EventType

The events that could possibly be received from the DaZeus server.

Request

An enum of all requests that can be sent to your DaZeus instance.

Constants

PROTOCOL_VERSION

The version of the DaZeus plugin communication protocol that these bindings understand.

Traits

DaZeusClient

Methods for interaction with the DaZeus server.

Functions

is_event_json

Returns whether or not the given Json data could be a valid event object.

Type Definitions

Command

A String indicating the name of some command.

ListenerHandle

An identifier for unsubscribing an event listener.

Message

A String containing the message to be sent.

Network

A String for the target IRC network.

PluginName

A String indicating the name of the plugin. This is used for retrieving configuration.

PluginVersion

A String indicating the version of the protocol used by the bindings.

Target

A String containing the target (receiver) of some command or message.