Skip to content

Instantly share code, notes, and snippets.

@ryantology
Last active December 28, 2015 20:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryantology/7558189 to your computer and use it in GitHub Desktop.
Save ryantology/7558189 to your computer and use it in GitHub Desktop.
MineCraft + HipChat notification though nodejs. This is a quick little snippet that will let people in your hipchat server know that users have joined the minecraft server. Not sure what happens when the log file rotates.
Tail = require('tail').Tail;
tail = new Tail("latest.log");
HipChatClient = require('node-hipchat')
hipchat = new HipChatClient("*************************");
var loginPattern = /.*\[Server thread\/INFO\]: (.*) joined the game/;
tail.on("line", function(data) {
var loginMatch = data.match(loginPattern);
if (loginMatch) {
console.log(loginMatch[1]);
hipchat.postMessage({
'room': '297355',
'from': 'MineCraft',
'message': 'Looks like '+loginMatch[1]+' just logged in.',
'notify': 0
});
}
});
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment