Last active
December 28, 2015 20:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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