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

ah-hipchat-server-plugin

v0.0.9

Published

I connect actionhero to HipChat

Downloads

35

Readme

ah-hipchat-server-plugin

This plugin adds a "hipchat" server, allowing you to communicate with actionhero from your hipchat chat client!

This is inteded to show how simple it is to use actionhero as a hubot replacement.

You can run actions from any room that the bot is connected to.

Actions

When crafing actions which use the hipchat server, there are a few things to keep in mind:

Config

Copy config/servers/hipchat.js into your own project. Create a hipchat user you want this server to conncet as (the bot user). Visit https://www.hipchat.com/account/xmpp to learn the jabber conncetion information for this user.

In order to tell which messages in rooms are meant to be actions, we need to set a 'delimiter'. The first word in the message needs to start with this charecter, and then will become the action. So if you have a delimiter of / and you said the stanza /myAction 123 abc, the action myAction would be invoked.

Params

  • The params you get from the server are action, words, room and from. So a stanza like /ping hello bot would produce the params:
{
  action: 'ping',
  room:   '12345_the_room',
  from:   'evan',
  words:  ['hello', 'bot'],
}
  • You can send key-value pairs as well. You can set the breaker for key-value pairs (which defaults to '=') in the config. So a stanza like /ping thing=stuff would produce:
{
  action: 'ping',
  room:   '12345_the_room',
  from:   'evan',
  words:  ['thing=stuff']
  thing:  'stuff',
}

An example action, ping, is provided to test this out.

Regexp matchers

Somtimes you want to match the plain text content of an incomming message to map to an action, rather than relying on / commands. You can append a new property to your actions, action.matchers = [] which contains a collection of regexps which will attempt to be matched to call this action. So, if you wanted to match "ship it" to show a random image, your action would look likt:

exports.action = {
  name:                   'shipit',
  description:            'shipit',
  blockedConnectionTypes: [],
  outputExample:          {},
  matchExtensionMimeType: false,
  version:                1.0,
  toDocument:             true,
  middleware:             [],
  matchers: [
    'ship it',
    'shipit',
    'SHIP IT',
    'SHIPIT'
  ],

  inputs: {},

  run: function(api, data, next){
    var images = [
      "https://img.skitch.com/20111026-r2wsngtu4jftwxmsytdke6arwd.png",
      "http://images.cheezburger.com/completestore/2011/11/2/aa83c0c4-2123-4bd3-8097-966c9461b30c.jpg",
      "http://images.cheezburger.com/completestore/2011/11/2/46e81db3-bead-4e2e-a157-8edd0339192f.jpg",
      "http://28.media.tumblr.com/tumblr_lybw63nzPp1r5bvcto1_500.jpg",
      "http://i.imgur.com/DPVM1.png",
      "http://gifs.gifbin.com/092010/1285616410_ship-launch-floods-street.gif",
      "http://d2f8dzk2mhcqts.cloudfront.net/0772_PEW_Roundup/09_Squirrel.jpg",
      "http://www.cybersalt.org/images/funnypictures/s/supersquirrel.jpg",
      "http://www.zmescience.com/wp-content/uploads/2010/09/squirrel.jpg",
      "http://img70.imageshack.us/img70/4853/cutesquirrels27rn9.jpg",
      "http://img70.imageshack.us/img70/9615/cutesquirrels15ac7.jpg",
      "http://1.bp.blogspot.com/_v0neUj-VDa4/TFBEbqFQcII/AAAAAAAAFBU/E8kPNmF1h1E/s640/squirrelbacca-thumb.jpg",
      "https://dl.dropboxusercontent.com/u/602885/github/soldier-squirrel.jpg",
      "https://dl.dropboxusercontent.com/u/602885/github/squirrelmobster.jpeg"
    ];

    data.response.message = images[Math.floor(Math.random()*images.length)];

    next();
  }
};

Security

You can be sure that any actions coming in via the hipchat server are from users truly logged into your company's hipchat account. That said, remmeber that you can access actions via other methods (http, websocket, etc) in actionhero. Be sure to add a layer of authentication if you expect to user your actionhero server for more than just hipchat.

One simple thing to do is add an authentication middleware (which your actions can opt into) which checks for the method of connection:

// From initializaers/auth.js

module.exports = {
  initialize: function(api, next){

    var authMiddleware = {
      name: 'authMiddleware',
      global: false,
      preProcessor: function(data, next){
        if( data.connection.type === 'hipchat' ){
          next(); // OK
        }else{
          next( new Error('GO AWAY.  NOT FOR YOU.') );
        }
      }
    };

    api.actions.addMiddleware(authMiddleware);

    next();
  },
};

TODO:

  • figure out how to get "online" presence right within hipchat
  • work in private chats