parseTypestring

Takes a slice of a raw IRC string and continues parsing it into an IRCEvent struct.

This function only focuses on the *typestring*; the part that tells what kind of event happened, like PRIVMSG or MODE or NICK or KICK, etc; in string format.

The IRCEvent is not finished at the end of this function.

private pure @safe
void
parseTypestring
(,,
ref string slice
)

Parameters

parser IRCParser

Reference to the current IRCParser.

event IRCEvent

Reference to the IRCEvent to continue working on.

slice string

Reference to the slice of the raw IRC string.

Throws

IRCParseException if conversion from typestring to IRCEvent.Type or typestring to a number failed.

Examples

import lu.conv : Enum;
import std.conv : to;

IRCParser parser;

IRCEvent e1;
with (e1)
{
    raw = /*":port80b.se.quakenet.org */"421 kameloso åäö :Unknown command";
    string slice = raw;  // mutable
    parser.parseTypestring(e1, slice);
    assert((type == IRCEvent.Type.ERR_UNKNOWNCOMMAND), Enum!(IRCEvent.Type).toString(type));
    assert((num == 421), num.to!string);
}

IRCEvent e2;
with (e2)
{
    raw = /*":port80b.se.quakenet.org */"353 kameloso = #garderoben :@kameloso'";
    string slice = raw;  // mutable
    parser.parseTypestring(e2, slice);
    assert((type == IRCEvent.Type.RPL_NAMREPLY), Enum!(IRCEvent.Type).toString(type));
    assert((num == 353), num.to!string);
}

IRCEvent e3;
with (e3)
{
    raw = /*":zorael!~NaN@ns3363704.ip-94-23-253.eu */"PRIVMSG kameloso^ :test test content";
    string slice = raw;  // mutable
    parser.parseTypestring(e3, slice);
    assert((type == IRCEvent.Type.PRIVMSG), Enum!(IRCEvent.Type).toString(type));
}

IRCEvent e4;
with (e4)
{
    raw = /*`:zorael!~NaN@ns3363704.ip-94-23-253.eu */`PART #flerrp :"WeeChat 1.6"`;
    string slice = raw;  // mutable
    parser.parseTypestring(e4, slice);
    assert((type == IRCEvent.Type.PART), Enum!(IRCEvent.Type).toString(type));
}