A library that makes it easy to write bots for HipChat!
HipBot uses the XMPP API to listen to incoming private messages and uses the HipChat REST API v2 to send outgoing private messages.
Source is available at https://bitbucket.org/shamid/hipbot.
Note: This is a work in progress, contributions welcome :)
In your project folder:
npm install hipbot --save
Once you create a user to be your bot, you will need to:
- Get the bot user's Jabber ID from https://atlassian.hipchat.com/account/xmpp
- Create an API token using https://atlassian.hipchat.com/account/api
In your project's JS file create a HipBot:
var HipBot = require('hipbot');
var hipBot = new HipBot({
jabberid: "1234_5678@chat.hipchat.com",
password: "secret",
token: "abc123",
status: "How can I help?"
});
hipBot.hears('hi').thenSays('hello');
hipBot.hears('hello').thenSays('hi');
hipBot.hears(/gday .*/).thenSays('gday mate');
hipBot.hears(/where is (.*)\?/).then(function(responder, msg, matches) {
var place = matches[1];
responder.say(place + ' is in the building');
});
hipBot.hears(/what is (.*)\?/).then(function(responder, msg, matches) {
var thing = matches[1];
responder.sayHtml('Google has a few things to say about: <a href="https://www.google.com.au/search?q=' + thing + '">' + thing + '</a>');
});
hipBot.hears().thenSays("Sorry I'm not smart enough to understand that :(");
You can try out the examples by running examples/basic.js
Here's what the output could look like: