Skip to content
IRC parsing library
D Shell
Branch: master
Clone or download
zorael v0.2.1
This emergency patch fixes CIs failing to build the package and
incorrectly claiming it's broken.
Latest commit dba1b08 Sep 15, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Fix CIs building stale build configurations Sep 15, 2019
source/dialect tryImportMixin: Replace "plugin" with "postprocessor" Sep 15, 2019
tests Fix tests using old IRCClient.updated bool Sep 15, 2019
.travis.yml Fix CIs building stale build configurations Sep 15, 2019
LICENSE Initial commit Sep 4, 2019 v0.2.1 Sep 15, 2019
appveyor.yml Fix CIs building stale build configurations Sep 15, 2019
dub.sdl Rename build configuration "simple" -> "library" Sep 15, 2019

dialect CircleCI Linux/OSX Travis Linux/OSX and documentation Windows GitHub commits since last release

IRC parsing library with support for a wide variety of server daemons.

Note that while IRC is standardised, servers still come in many flavours, some of which outright conflict with others. If something doesn't immediately work, generally it's because we simply haven't encountered that type of event before, and so no rules for how to parse it have yet been written.

Used in the kameloso bot. However, while dialect unavoidably caters to its needs it is independent from it. Likely some remnants of code that violate separation of concern still exist, and they are to be considered bugs.

Please report bugs. Unreported bugs can only be fixed by accident.

What it looks like

API documentation can be found here.

struct IRCEvent
    enum Type { ... }

    Type type;
    string raw;
    IRCUser sender;
    string channel;
    IRCUser target;
    string content;
    string aux;
    string tags;
    uint num;
    int count;
    int altcount;
    long time;
    string errors;

        string emotes;
        string id;

struct IRCUser
    enum Class { ... }

    Class class_;
    string nickname;
    string alias_;
    string ident;
    string address;
    string account;
    long lastWhois;  // BUG, does not belong in a bot-agnostic library

        string badges;
        string colour;

struct IRCServer
    enum Daemon { ... }
    enum CaseMapping { ... }

    string address;
    ushort port;

    // More internals

struct IRCClient
    string nickname;
    string user;
    string ident;
    string realName;
    IRCServer server;

    // More internals

struct IRCParser
    IRCClient client;

    IRCEvent toIRCEvent(const string);  // <--

How to use

This assumes you have a program set up to read information from an IRC server. This is not a bot framework; for that you're better off with the full kameloso and writing a plugin that suits your needs.

Instantiate an IRCParser with an IRCClient (via constructor), and configure its members. Read a string from the server and parse it with IRCParser.toIRCEvent(string).

IRCParser parser;

string fromServer = ":zorael!~NaN@address.tld MODE #channel +v nickname";
IRCEvent event = parser.toIRCEvent(fromServer);

with (event)
    assert(type == IRCEvent.Type.MODE);
    assert(sender.nickname == "zorael");
    assert(sender.ident == "~NaN");
    assert(sender.address == "address.tld");
    assert(target.nickname == "nickname");
    assert(channel == "#channel");
    assert(aux = "+v");

string alsoFromServer = " 435 oldnick newnick #d " ~
    ":Cannot change nickname while banned on channel";
IRCEvent event2 = parser.toIRCEvent(alsoFromServer);

with (event2)
    assert(type == IRCEvent.Type.ERR_BANONCHAN);
    assert(sender.address == "");
    assert(channel == "#d");
    assert(target.nickname == "oldnick");
    assert(content == "Cannot change nickname while banned on channel");
    assert(aux == "newnick");
    assert(num == 435);

string furtherFromServer = ":kameloso^! NICK :kameloso_";
IRCEvent event3 = parser.toIRCEvent(furtherFromServer);

with (event3)
    assert(type == IRCEvent.Type.NICK);
    assert(sender.nickname == "kameloso^");
    assert(sender.ident == "~ident");
    assert(sender.address == "");
    assert(target.nickname = "kameloso_");

See the /tests directory for more example parses.


  • remove final non-bot-agnostic remnants


This project is licensed under the MIT license - see the LICENSE file for details.

You can’t perform that action at this time.