Skip to content

Instantly share code, notes, and snippets.

@avimar
Created July 19, 2012 20:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avimar/3146678 to your computer and use it in GitHub Desktop.
Save avimar/3146678 to your computer and use it in GitHub Desktop.
auto-opper written in node
console.log("Bot Started...");
process.on('uncaughtException', function (err) { console.log('OMG something went really wrong: ' + err); });
var irc = require('irc');
//https://github.com/martynsmith/node-irc
//npm install irc
var MYBOT = {};
MYBOT.channelname = "#node.js";
MYBOT.nick = "ryan_opper";
var client = new irc.Client('irc.freenode.net', MYBOT.nick, {///6697
channels: [MYBOT.channelname]
//,debug: true
});
var regex = /^ops?\s*pl(ease|z|x)/i;
//var result = message.match(regex);
//Handle on message in target channel event
client.addListener("message" + MYBOT.channelname, function (nick,text) {
//if(text=="op plz"){
if(text.match(regex)){
client.send('MODE', MYBOT.channelname, '+o', nick);
}
});
//Will auto-op on enterance.
/*
client.addListener('join'+ MYBOT.channelname, function (nick,text) {
client.send('MODE', MYBOT.channelname, '+o', nick);
});*/
//untested: op upon de-op. Unless they did it themselves.
/*client.addListener('-mode', function (channel, by, mode, argument, message) {
if(mode=='o' && by!=argument){
client.send('MODE', MYBOT.channelname, '+o', argument);
}
});*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment