# irc-message

> Performant, streaming IRC message parser

Latest version **3.0.2** (published 2015-08-09) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install irc-message
pnpm add irc-message
yarn add irc-message
bun add irc-message
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2015-08-09 |
| First published | 2013-12-01 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Fionn Kelleher |
| Maintainers | expr |
| Keywords | irc, message, parser, chat |

## Links

- npm: https://www.npmjs.com/package/irc-message
- Repository: https://github.com/expr/irc-message
- Issues: https://github.com/expr/irc-message/issues
- npm.io page: https://npm.io/package/irc-message

## Dependencies (3)

- [through2](https://npm.io/package/through2.md) ^0.6.3
- [iso8601-convert](https://npm.io/package/iso8601-convert.md) ^1.0.0
- [irc-prefix-parser](https://npm.io/package/irc-prefix-parser.md) ^1.0.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2015-08-09
- 3.0.1 — 2015-03-01
- 3.0.0 — 2015-02-22
- 2.0.1 — 2014-06-27
- 2.0.0 — 2014-05-29
- 1.0.0 — 2013-12-20
- 0.2.1 — 2013-12-06
- 0.2.0 — 2013-12-04
- 0.1.2 — 2013-12-02
- 0.1.1 — 2013-12-01
- 0.1.0 — 2013-12-01

## README

# irc-message [![Build Status](https://travis-ci.org/expr/irc-message.svg?branch=master)](https://travis-ci.org/expr/irc-message)
> Performant, streaming IRC message parser

irc-message provides an object stream capable of parsing [RFC1459-compliant IRC messages](http://tools.ietf.org/html/rfc2812#section-2.3.1), with support for [IRCv3 message tags](https://github.com/ircv3/ircv3-specifications/blob/master/specification/message-tags-3.2.md). 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 `Buffer`s/`String`s 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](https://github.com/expr/irc-prefix-parser)_. Defaults to `false`.
* `convertTimestamp` - if the message has a _time_ tag, convert it into a JavaScript `Date` object (see _[server-time](https://github.com/ircv3/ircv3-specifications/blob/master/extensions/server-time-3.2.md)_ spec for reference). Defaults to `false`.

```js
var net = require('net')
var ircMsg = 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).

```js
var parse = require('irc-message').parse

console.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!']
 * }
 */
```

---
_Source: https://npm.io/package/irc-message · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
