Coder Social home page Coder Social logo

irc-message's Introduction

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.
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).

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

irc-message's People

Contributors

havvy avatar rodms10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

irc-message's Issues

Error handling needs drastic improvement

Currently, the parser is a mix of returns and error throwing. #7 highlighted lack of proper error handling in irc-message, this needs to be sorted. Not sure how I should go about it; ideas welcome.

Join/Part

Don't seem to be getting join and part messages.

Remove 'name' suffix from hostmask object keys.

Since to use the hostmask, you must already know that those three properties are all names, it would be nice to not have to say 'nickname' or 'hostname' or 'username' when referring to them. No useful information is stored in the common suffix.

Change 'command' to 'name' or 'type'

Probably going to be closed, but command is a weird name for the fact that it's a declaration of what type of message it is, and not a declaration to do something.

3.0.0 checklist

  • make sure irc-prefix-parser works as expected (fixing #13)
  • rewrite tests
  • deprecate irc-message-stream, I'm pushing streams now (stream all the things!)
  • debug line splitting issue
  • manually merge #14

What to use it with?

Nice module, I'm currently looking for a good node irc module to use, and I see lots of people that have forked node-irc and made their own modifications, but haven't seen any collaboration of merging of those branches to a new fork of the project.

I was wondering if you had any suggestions as to what npm module to use for IRC interfacing?

Fix parsing of commands with no params

> new IrcMessage('nick!user@host AWAY');
{ tags: {}, 
  prefix: 'nick!user@host', 
  command: 'AWA', 
  params: [ 'nick!user@host AWAY' ] } 

Is returned when params should be equal to '', like so;

> new IrcMessage('nick!user@host AWAY :');
{ tags: {}, 
  prefix: 'nick!user@host', 
  command: 'AWAY', 
  params: [ '' ] } 

IRC message write?

paring IRC messages is working great. what is the recommended method to build IRC messages to send back to the server? Is there a popular serialization library (for example), or is there support in this library for writing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.