Skip to content

overlay5/irc-parse-line

Repository files navigation

IRC Message Parser

License: MIT

The simplest possible IRC message parser, with the most extensible suite of tests.

Usage:

const { parseIrcLine } = require('irc-parse-line')
parseIrcLine('@tag1=value1;tag2;vendor1/tag3=value2;vendor2/tag4 COMMAND param1 param2 :param3 param3"')
/* Returns the following:
 *    {
 *      tags: [
 *        [ 'tag1', 'value1' ],
 *        [ 'tag2', '' ],
 *        [ 'vendor1/tag3', 'value2' ],
 *        [ 'vendor2/tag4', '' ]
 *      ],
 *      verb: 'COMMAND',
 *      params: [ 'param1', 'param2', 'param3 param3"' ]
 *    }
 */

The object returned by parseIrcLine(line: string) has the following fields:

field name and type description
verb: string command used
servername: string server name (when specified)
source: string source of the message, often the user nick name
user: string user sending the message
host: string source host for this message
tags: [string, string][] IRC message tags
params: [string] IRC message parameters, including trailing parameter