Skip to content

Instantly share code, notes, and snippets.

@cdeutsch
Last active January 3, 2016 14:39
Show Gist options
  • Select an option

  • Save cdeutsch/8477848 to your computer and use it in GitHub Desktop.

Select an option

Save cdeutsch/8477848 to your computer and use it in GitHub Desktop.
var irc = require("irc");
var pushover = require( 'pushover-notifications' );
// Create the configuration
var ircConfig = {
channels: ["#web", "#dogs"],
server: "irc.company.com",
botName: "nodebot",
watch: 'christopher'
};
var ircOptions = {
userName: 'username',
password: 'pass',
port: 9999,
secure: true,
debug: false,
showErrors: true
};
var push = new pushover( {
user: 'usertoken',
token: 'apptoken',
// update_sounds: true // update the list of sounds every day - will prevent app from exiting.
});
var bot = new irc.Client(ircConfig.server, ircConfig.botName, ircOptions);
// Listen for any message, say to him/her in the room
bot.addListener("message", function(from, to, text, message) {
var args = [''];
if (message && message.args && message.args.length > 0) {
args = message.args;
}
if (args[0] == 'christopher') {
var msg = {
message: text,
title: "Xamarin IRC PM"
//sound: 'magic', // optional
//priority: 1 // optional
};
push.send( msg, function( err, result ) {
if ( err ) {
console.log('Pushover error:');
console.log(err);
}
});
}
else if (text && text.toLowerCase().indexOf("@" + ircConfig.watch) > -1) {
var msg = {
message: text,
title: "Xamarin IRC @Reply"
//sound: 'magic', // optional
//priority: 1 // optional
};
push.send( msg, function( err, result ) {
if ( err ) {
console.log('Pushover error:');
console.log(err);
}
});
}
else if ((args[0] == '#web' || args[0] == '#xamarin') && text && text.toLowerCase().indexOf(ircConfig.watch) > -1) {
var msg = {
message: text,
title: "Xamarin IRC Mention"
//sound: 'magic', // optional
//priority: 1 // optional
};
push.send( msg, function( err, result ) {
if ( err ) {
console.log('Pushover error:');
console.log(err);
}
});
}
// bot.say(config.channels[0], "¿Public que?");
console.log(from + ": " + text);
console.log(message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment