[−][src]Module ttv_chat::irc
IRC message parsing.
Twitch's chat is based on IRC, but not strictly conformant to the RFC-1459 and RFC-2812 specs.
This provides a Twitch-flavored IRC parser and types.
Parsing
You can use this crate to parse Twitch (IRC) messages from a &str
.
This will just borrow from the input &str
.
With the parsed type, you can further refine it into specific Twitch-oriented messages.
use twitchchat::{IrcMessage, MessageError}; // a raw message from the server let input = "@key1=val;key2=true :user!user@user PRIVMSG #some_channel :\x01ACTION hello world\x01\r\n"; type MsgResult<'a> = Result<IrcMessage<'a>, MessageError>; // this'll return an iterator over any messages in the `input` string. let mut messages: Vec<MsgResult<'_>> = twitchchat::irc::parse(input).collect(); // we should have only gotten 1 message assert_eq!(messages.len(), 1); // and unwrap whether it was an invalid message or not messages.pop().unwrap();
Structs
IrcMessage | A raw irc message |
IrcParserIter | An iterator over a |
Prefix | Prefix is the sender of a message |
TagIndices | Pre-computed tag indices |
Tags | Tags are IRCv3 message tags. Twitch uses them extensively. |
TagsIter | An iterator over the Tags |
Enums
MessageError | An invalid message was either provided, or could not be parsed |
PrefixIndex | Prefix is the sender of a message |
Traits
FromIrcMessage | A trait to convert an |
IntoIrcMessage | A trait to convert a |
Functions
parse | Parses a string and returns an iterator over the |
parse_one | Attempts to parse one message. |