[][src]Module irc::client

A simple, thread-safe, and async-friendly IRC client library.

This API provides the ability to connect to an IRC server via the Client type. The Client trait that Client implements provides methods for communicating with the server.

Examples

Using these APIs, we can connect to a server and send a one-off message (in this case, identifying with the server).

use irc::client::prelude::Client;

let client = Client::new("config.toml").await?;
client.identify()?;

We can then use functions from Client to receive messages from the server in a blocking fashion and perform any desired actions in response. The following code performs a simple call-and-response when the bot's name is mentioned in a channel.

use irc::client::prelude::*;
use futures::*;

let mut client = Client::new("config.toml").await?;
let mut stream = client.stream()?;
client.identify()?;

while let Some(message) = stream.next().await.transpose()? {
    if let Command::PRIVMSG(channel, message) = message.command {
        if message.contains(client.current_nickname()) {
            client.send_privmsg(&channel, "beep boop").unwrap();
        }
    }
}

Modules

conn

A module providing IRC connections for use by IrcServers.

data

Data related to IRC functionality.

prelude

A client-side IRC prelude, re-exporting the complete high-level IRC client API.

transport

An IRC transport that wraps an IRC-framed stream to provide a number of features including automatic PING replies, automatic sending of PINGs, and message rate-limiting. This can be used as the basis for implementing a more full IRC client.

Structs

Client

The canonical implementation of a connection to an IRC server.

ClientStream

A stream of Messages received from an IRC server via an Client.

Outgoing

Future to handle outgoing messages.

Sender

Thread-safe sender that can be used with the client.