toIRCEvent

Parses an IRC string into an IRCEvent.

Parsing goes through several phases (prefix, typestring, specialcases) and this is the function that calls them, in order.

See the files in /tests for unittest examples.

pure @safe
toIRCEvent
(,
const string raw
)

Parameters

parser IRCParser

Reference to the current IRCParser.

raw string

Raw IRC string to parse.

Return Value

Type: IRCEvent

A finished IRCEvent.

Throws

IRCParseException if an empty string was passed.

Examples

IRCParser parser;

/++
    `parser.toIRCEvent` technically calls
    [IRCParser.toIRCEvent|IRCParser.toIRCEvent], but it in turn just passes
    on to this `.toIRCEvent`
 +/

// See the files in `/tests` for more

{
    immutable event = parser.toIRCEvent(":adams.freenode.net 001 kameloso^ " ~
        ":Welcome to the freenode Internet Relay Chat Network kameloso^");
    with (IRCEvent.Type)
    with (event)
    {
        assert(type == RPL_WELCOME);
        assert(sender.address == "adams.freenode.net"),
        assert(target.nickname == "kameloso^");
        assert(content == "Welcome to the freenode Internet Relay Chat Network kameloso^");
        assert(num == 1);
    }
}
{
    immutable event = parser.toIRCEvent(":irc.portlane.se 020 * :Please wait while we process your connection.");
    with (IRCEvent.Type)
    with (event)
    {
        assert(type == RPL_HELLO);
        assert(sender.address == "irc.portlane.se");
        assert(content == "Please wait while we process your connection.");
        assert(num == 20);
    }
}