Go to file
2022-07-30 15:11:16 +01:00
.github/workflows Create rust.yml 2022-07-30 15:08:40 +01:00
src Remove needless main() definition from example 2022-07-30 15:11:16 +01:00
.editorconfig Initial commit 2022-07-29 22:04:23 +01:00
.gitignore Initial commit 2022-07-29 22:04:23 +01:00
Cargo.toml Create initial implementation 2022-07-30 02:04:45 +01:00
CODE_OF_CONDUCT.md Initial commit 2022-07-29 22:04:23 +01:00
LICENSE Initial commit 2022-07-29 22:04:23 +01:00
README.md Add documentation 2022-07-30 15:06:05 +01:00

ircparser

An IRC (RFC1459) parser and formatter, built in Rust.

Setup

To use the latest stable version of ircparser, add it to your Cargo.toml file like so:

[dependencies]
ircparser = "^0.1"

You can also use the latest development version by specifying the following:

[dependencies]
ircparser = { git = "https://github.com/parafoxia/ircparser" }

Usage

ircparser currently only has one public function — parse. This function takes a line of an IRC message, and parses it into an easy-to-use Line object.

use ircparser;

fn main() {
    let msg = "@id=123;name=rick :nick!user@host.tmi.twitch.tv PRIVMSG #rickastley :Never gonna give you up!";
    match ircparser::parse(msg) {
        Ok(x) => {
            let line = x;

            assert_eq!(&line.tags["id"], "123");
            if line.source.is_some() {
                assert_eq!(line.source.unwrap(), ":nick!user@host.tmi.twitch.tv");
            }
            assert_eq!(line.command, "PRIVMSG");
            assert_eq!(line.params[0], "#rickastley");
            assert_eq!(line.params[1], "Never gonna give you up!");
        }
        Err(e) => {
            println!("A parsing error occured: {e}");
            return;
        }
    };
}

License

The ircparser crate for Rust is licensed under the BSD 3-Clause License.