Skip to content

Latest commit

History

71 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

irc-message Build Status

Performant, streaming IRC message parser

irc-message provides an object stream capable of parsing RFC1459-compliant IRC messages, with support for IRCv3 message tags. This also includes server-to-server protocols such as TS6, Spanning Tree, and the UnrealIRCd protocol.

Installation

npm install irc-message

Usage

createStream(options)

Returns an object stream, taking in Buffers/Strings of raw IRC data. Data should not be line-buffered, this stream handles splitting and buffering automatically. and pushing objects containing the following keys.

  • raw - unparsed IRC message (string)
  • tags - IRCv3 message tags
  • prefix - message prefix/source
  • command - message command/verb
  • params - an array of middle and trailing parameters

Optional options object supports

  • parsePrefix - replace the prefix with an object generated by irc-prefix-parser. Defaults to false.
  • convertTimestamp - if the message has a time tag, convert it into a JavaScript Date object (see server-time spec for reference). Defaults to false.
varnet=require('net')varircMsg=require('irc-message')net.connect(6667,'irc.freenode.net').pipe(ircMsg.createStream()).on('data',function(message){console.log(message)})

parse(data)

You can also access the message parser directly. The parser function expects a string without any CRLF sequences. If the string is malformed, null is returned. Otherwise, an object representing the message is returned (see createStream() for format).

varparse=require('irc-message').parseconsole.log(parse(':hello!sir@madam PRIVMSG #test :Hello, world!'))/* {  * raw: ':hello!sir@madam PRIVMSG #test :Hello, world!', * tags: {},  * prefix: 'hello!sir@madam',  * command: 'PRIVMSG', * params: ['#test', 'Hello, world!'] * } */

About

Performant, streaming IRC message parser

Resources

Stars

93 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages