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

boter

v1.0.9

Published

A simple library for writing smooth IRC bots.

Downloads

6

Readme

Boter is a simple library to build your own smooth IRC bot using node.js. It allows you to easily respond to highlights, mentions and PMs.

Boter is built on top of the excellent node-irc and written in CoffeeScript. The name (boter) is obviously derived from the word "bot", and is Dutch for "butter".

Installation

Installation is as simple as:

$ npm install boter

If you want to hack on Boter or check if it works correctly on your system you can clone the repository or copy the files to your path of choice, and then:

$ cd path/to/boter/
$ npm install

You can then run the tests by simple calling:

$ make test

Usage

You can create a Boter bot like your would create a node_irc client:

var boter = require('../path/to/boter/');

var opts = {
    channels: [#bar]
};
var bot = new boter.Boter('irc.server.foo', 'MyBoter', opts);

In addition to the nickname, you can give the bot a few aliasses to which it will respond:

var opts = {
    channels: [#bar],
    aliasses: ['BoterBot', 'Boter']
}
var bot = new boter.Boter('irc.server.foo', 'MyBoter', opts);

To actually listen to messages, Boter emits events you can listen to:

var goodMorning = function(message) {
    if (/^good morning/.test(message.text))
        message.reply("Good morning to you, too, "+message.from+"!");
}
bot.on('highlight', goodMorning);
bot.on('mention', goodMorning);

// <Someone>: BoterBot: Good morning!
// <MyBoter>: Good morning to you, too, Someone!

// <Person>: good morning, boter.
// <MyBoter>: Good morning to you, too, Person!

Note that the 'BoterBot: ' prefix is automatically trimmed from the message, and message.text lower cased. The original text (also trimmed, but not decapitalized) can be found in message.original.

BoterBot emits three kinds of events:

  • It emits 'pm' when a PM (or "query") is received;
  • It emits 'highlight' when the Bot is specifically adressed, e.g. "BoterBot: hey, you!";
  • It emits 'mention' when the bot is mentioned elsewhere in the message. e.g. "Ceterum censeo boterbot delendam est.".

All of these events pass a Message object to the callback, as shown above. Mentions and highlights are triggered on the bot's nick or any of its aliasses, which are matched case insensitively.

More events will follow in a future version (as well as forwarding of all other node-irc events).

Testing

To run the test:

$ cd path/to/boter/
$ make test

In addition, you can:

  • use make build to build the CoffeeScript source to lib/;
  • use make monitor to monitor and run the test when they change, or;
  • use make coverage to generate a code coverage report (which is saved to lib-cov/report.html).

Alternatively, you can use npm [command] instead of make [command] (they're equivalent).

Note: jscoverage is needed to generate a coverage report.

For testing, Boter uses Mocha and should.js. In addition, Mockery is used to test in isolation (with a mock of node_irc).

License

This software is licensed under the Simplified BSD License (see LICENSE).