parseBasic

Parses the most basic of IRC events; PING, ERROR, PONG, NOTICE (plus NOTICE AUTH), and AUTHENTICATE.

They syntactically differ from other events in that they are not prefixed by their sender.

The IRCEvent is finished at the end of this function.

private pure @safe
void
parseBasic

Parameters

parser IRCParser

Reference to the current IRCParser.

event IRCEvent

Reference to the IRCEvent to start working on.

Throws

IRCParseException if an unknown type was encountered.

Examples

import lu.conv : Enum;

IRCParser parser;

IRCEvent e1;
with (e1)
{
    raw = "PING :irc.server.address";
    parser.parseBasic(e1);
    assert((type == IRCEvent.Type.PING), Enum!(IRCEvent.Type).toString(type));
    assert((sender.address == "irc.server.address"), sender.address);
    assert(!sender.nickname.length, sender.nickname);
}

IRCEvent e2;
with (e2)
{
    // QuakeNet and others not having the sending server as prefix
    raw = "NOTICE AUTH :*** Couldn't look up your hostname";
    parser.parseBasic(e2);
    assert((type == IRCEvent.Type.NOTICE), Enum!(IRCEvent.Type).toString(type));
    assert(!sender.nickname.length, sender.nickname);
    assert((content == "*** Couldn't look up your hostname"));
}

IRCEvent e3;
with (e3)
{
    raw = "ERROR :Closing Link: 81-233-105-62-no80.tbcn.telia.com (Quit: kameloso^)";
    parser.parseBasic(e3);
    assert((type == IRCEvent.Type.ERROR), Enum!(IRCEvent.Type).toString(type));
    assert(!sender.nickname.length, sender.nickname);
    assert((content == "Closing Link: 81-233-105-62-no80.tbcn.telia.com (Quit: kameloso^)"), content);
}