npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

irc-connect

v2.2.0

Published

Minimal IRC connection that simply emits event objects. Plugin modules can do the rest.

Downloads

43

Readme

irc-connect

Ok, enough with the giant modules that provide more features than you need for a simple bot.

This module gives you the minimal IRC connection and simply emits event objects. It only includes what it takes to connect and stay connected.

Plugin modules can (and should) do the rest.

Now you can whip up a lightweight bot without all the baggage.

Channel support can be added with the irc-channels module!

Install it

npm install irc-connect

Use it

var irc = require("irc-connect");
var ircOptions = {
	//[port] if not provided defaults to 6667 (or if secure, 6697)
	port: 6667,
	//[secure] can be true/false or 'semi' for lazy CA checking (self-signed, obscure CA, etc)
	secure: false,
	//[nick] is the desired nickname, if not provided one will be generated (you can always use nick() later)
	nick: 'WernerB',
	//[realname] is the "real name" shown in WHOIS results
	realname: 'Werner Brandes',
	//[ident] is the user part of your hostmask (before the @), if not provided 'irc-cnct' will be used
	// note this may either be prefixed with a ~ on some servers, if you don't have an 'identd' service
	// if you do have such a service, most servers will use what is obtained there and ignore this
	ident: 'wbrandes'
}
var freenode = irc.connect('irc.freenode.net', ircOptions)
	//include some plugins
	.use(irc.pong, irc.names, irc.motd)
	//fires when the servers sends the welcome message (RPL_WELCOME)
	.on('welcome', function (msg) {
		console.log(msg);
		this.nick('pokey', 'pa$$word', function(err){
			console.log('There was a problem setting your NICK:', err);
		});
	})
	//fires after the server confirms password
	.on('identified', function (nick) {
		this.send('JOIN #node.js');
	})
	//fires only when YOUR nick changes
	.on('nick', function (nick) {
		console.log('Your nick is now:', nick);
	})
	.on('NOTICE', function (event) {
		console.log('NOTICE:', event.params[1]);
	})
	.on('JOIN', function (event) {
		console.log(event.nick, 'joined');
	})
	.on('PRIVMSG', function (event) {
		var params = event.params;
		console.log('message from: '+event.nick, 'to: '+params[0], params[1]);
	})
	//from the `names` plugin.
	.on('names', function (cname, names) {
		console.log(cname, names);
	})
	//from the `motd` plugin.
	.on('motd', function (event) {
		console.log(this.motd);
		console.log(this.support);
	})
;

Events

All data from the server is parsed and emitted using the data's command as the event name. Numeric events (as defined by RFC 1459) are converted to their string codes. The full list can be viewed in the irc-replies module.

All events follow this distinct pattern:

  • UPPERCASE events are direct IRC events. They are always passed the parsed event object.
  • lowercase events are custom events from irc-connect or a pluggin.

Event:'connect'

Event:'close'

Event:'error'

These are directly from the underlying socket connection.

Debug

This module uses Visionmedia's debug module.

Show everything:

$ DEBUG=irc:connect* node app.js

Show only connect/disconnect messages

$ DEBUG=irc:connect node app.js

Show raw incoming data:

$ DEBUG=irc:connect-raw node app.js

Show parsed incoming data as JSON:

$ DEBUG=irc:connect-parsed node app.js

Show outgoing data:

$ DEBUG=irc:connect-out node app.js

Plugins

As mentioned above, this module's goal is to allow plugins to be added that provide richer features.

connection.use(handler)

Plugins can export a __irc function for use to call. The function will be passed a reference to the connection. The plugin should wire any listeners needed and augment it with helper functions/properties needed.

irc.pong

IRC does a PING - PONG game to verify the client is still alive. Use this plugin to automatically reply to the server's PINGs and stay connected.

irc.names

Parses replies from a NAMES command and emits a names event with the results as an object.

irc.motd

Parses replies from a MOTD command and emits a motd event with the results as an object.

irc.nick(nick [,password [,onerror]])

Sets a NICK with an optional password and a error callback. This only works properly if your server has a NickServ or similar service which requires a password to register your nick, and sends a success NOTICE. On a vanilla ircd you may need to send your own NICK command, the events will still work the same.

Event:'nick'

Emitted anytime your nick is changed.

license

MIT