Expand description
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.
- Invalid
Json Error - Error returned when the passed Json did not have the required structure.
- Parse
Config Group Error - Error returned when a string could not be parsed as a
ConfigGroup. - Parse
Event Type Error - Error returned when a string could not be parsed as an
EventType. - Receive
Error - 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§
- Config
Group - The type of config that should be retrieved.
- Connection
- A connection enum that encapsulates TCP and Unix sockets.
- Error
- Event
Type - 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§
- DaZeus
Client - 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 Aliases§
- Command
- A
Stringindicating the name of some command. - Listener
Handle - An identifier for unsubscribing an event listener.
- Message
- A
Stringcontaining the message to be sent. - Network
- A
Stringfor the target IRC network. - Plugin
Name - A
Stringindicating the name of the plugin. This is used for retrieving configuration. - Plugin
Version - A
Stringindicating the version of the protocol used by the bindings. - Target
- A
Stringcontaining the target (receiver) of some command or message.