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

node-irc-framework

v1.0.1

Published

A small boilerplate wrapping node-irc package in a comfortable easy and fast to start with template

Downloads

2

Readme

Node IRC Framework npm version

How To Use It

  • create a new config:
{
    "host": "chat.freenode.net",
    "port": 6697,
    "useSSL": true,
    "useSASL": false,
    "autoRejoin": false,
    "nick": "whiterabbit",
    "admins": [
        "neo",
        "trinity"
    ],
    "blacklist": [
        "agentsmith"
    ],
    "channels": [
        "#matrix"
    ],
    "nickserv": false,
    "nickservPassword": "foobar",
    "nickservEmail": "[email protected]",
    "useAdmins": false
}
  • create a new script:
var framework = require('node-irc-framework'),
    path = require('path'),
    cfgPath = path.join(__dirname, 'configFile.json'),
    // initialize config
    config = framework.config(cfgPath),
    // initialize irc client
    irc = framework.irc(cfgPath, {
        // optional irc extensions
    }, function() {
        // optional scoped operations on NodeIRC.Client
        this.on('error', function(err) {
            console.log("[IRC]", err);
        });
        this.on('registered', function() {
            console.log('[IRC]', 'connected.');
        });
        this.on('pm', function(f, m) {
            console.log('[IRC]', `new private message from ${f}: ${m}`);
        });
    });

// add kill listeners to graceful shutdown irc client
process.on('SIGTERM', function() { irc.shutdown('SIGTERM'); });
process.on('SIGINT', function() { irc.shutdown('SIGINT'); });

// now you can connect
irc.connect();
  • run it:
$ node ./YourScript.js 

How To Customize It

If you plan on working with this Frawork you might want to customize the behavior of the IRC Client in this package. You can do so by extending the client and add events or operate on the client itself.

For this you can write the following code:

// when initializing the client you can append an object and a callback
var framework = require('node-irc-framework'),
    tools = framework.tools,
    irc = framework.irc(cfgPath, {
        // optional irc extensions
        knownClients: new tools.UniqueArray(),
        greetKnown: function(message) {
            this.knownClients.forEach(function(client) {
                this.say(client, message);
            }, this);
        }
    }, function() {
        // optional scoped operations on NodeIRC.Client
        // here you can run ioperations which are scoped on the client itself:
        
        // hook error event of IRC Client
        this.on('error', function(err) {
            // do something with the error
            console.log("[IRC]", err);
        });

        this.on('message', (from) => {
            this.knownClients.add(from);
            if (m == '!greet') {
                this.greetKnown('hey! I`m just saying hello, because '+from+' ran the command `!greet`');
            }
        });
    });

What Is Shipped With This Module?

This module consists of 3 parts:

  • irc - the smart and customizable irc client
  • config - a preconfigured and defaulting configuration provider including Union-Array lists for special settings
  • tools - a set of core tools which provide helping functions

Which Are Valid Settings?

A full configuration of this framework consists of the following settings:

  • host: ip or domain which IRC Client shall connect to
  • port: port on which IRC Client shall connect to
  • useSSL: Wheter to use SSL protocol
  • useSASL: Wheter to use SASL Authentication
  • autoRejoin: Wheter to rejoin on channels after being kicked or not
  • nick: That's the name of your client in the chat ;)
  • admins: A list of admins who are eliglible for issueing commands
  • blacklist: A list of clients who shall be ignored
  • channels: A list of channels IRC Client shall join / rejoin
  • nickserv: Whether to auto identify with nickserv (using given credentials)
  • nickservPassword: Password to use for Nickserv authentication
  • nickservEmail: Email to use for Nickserv authentication
  • useAdmins: Enable or Disable restricted command access