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

snarl

v0.3.3

Published

Simple chat bot for Slack, extensible with plugins.

Downloads

20

Readme

snarl snarl

NPM version Build Status

Simple chat bot (currently for Slack), extensible with plugins.

Despite his name, snarl is just a fuzzy and friendly goofball. He's been with us for several years, since the beginning of the Coding Soundtrack community. He's an awesome automaton that helps us with a great many things, so be nice to him.

Avatar for snarl is by @yiyinglu, who designed the original avatars for tuntable.fm.

If you'd like to test him out, join us on the Maki Slack, where snarl helps us develop the Maki Framework.

Quick Start

You'll need to create a Bot User for your Slack organization, generally found at https://YOUR-TEAM-NAME.slack.com/services/new/bot. Once the integration is added, you'll be given an API token: place this token into config/index.json. For more help, Slack has great documentation on bot users.

  1. Install via npm install snarl -g, or simply clone1 this repository and run npm install as usual.
  2. Modify config/index.json to contain your Slack token (see paragraph above).
  3. Execute npm start in the source directory, or snarl if you installed globally.

That's it. You'll see snarl come online! If you install snarl globally via npm install snarl -g, you can also simply type snarl at any time (for example, inside of a screen or a tmux session) to run the bot.

1: if you want to make modifications, you should fork it first!

Naming Your Bot

If you want to give snarl a different name, you can configure it via Slack (see link above), or add a name property to config/index.json.

Plugins

snarl supports plugins. We've kept the default list short but fun. We'd love to see even more contributions!

Plugins for snarl can add commands or other functionality. For example, the included karma plugin lets snarl keep track of karma for various users.

Using Plugins

Plugins can be autoloaded from either a single file in ./plugins/plugin-name.js or an NPM module named snarl-plugin-name. To autoload a plugin, add the plugin name to the plugins array in config/index.json:

{
  "name": "snarl",
  "plugins": ["erm", "karma"],
  "store": "data/store",
  "slack": {
    "token": "some-token-xxxooooo",
  },
}

...and simply call autoload():

var Snarl = require('snarl');
var snarl = new Snarl();

// autoload plugins found in `config/index.json`
snarl.autoload();

// start snarl, as normal
snarl.start();

To use another plugin, simply require it, as follows:

var Snarl = require('snarl');
var snarl = new Snarl();

// import the karma plugin
var karma = require('./plugins/karma');

// use the karma plugin we required above
snarl.use(karma);

// start snarl, as normal
snarl.start();

Included Plugins

The list of available plugins (via ./plugins/plugin-name) is as follows:

  • karma, which keeps track of user karma, as incremented by @username++.
  • facts, which provides !TopologyFacts (mathematical topology facts), !SmiffFacts (facts about Will Smith), and !InterstellaFacts (facts about Interstella 5555)
  • meetups, which responds with a simple message telling your community about in-person meetups.
  • erm, which transforms the text of a user message into ERMEGERD speech using martindale/erm.
  • beer-lookup, which provides !brew <beerName> to look up and describe a beer via BreweryDB.

Other Plugins

  • snarl-eliza is a simple AI using the ELIZA self-help chatbot created by Joseph Weizenbaum between 1964 and 1966.

Writing Plugins

To write a snarl plugin, create a new NPM module that exports a map of triggers your bot will respond to. You can use either a simple message string, or a function that expects a callback:

module.exports = {
  'test': 'Hello, world'
};

For more complex functionality, use the callback feature:

module.exports = {
  'test': function(msg, done) {
    // simulate an asynchronous task...
    setTimeout(function() {
      // error is first parameter, response is second
      done(null, 'Your message was: ' + msg.text + '\nYour triggers were:' + msg.triggers);
    }, 1000);
  };
}

We ask that you publish your plugins via npm, name them snarl-yourplugin, and add both the snarl and slack keywords to your package.json.

Thanks! We hope you enjoy.