Created
July 19, 2012 20:42
-
-
Save avimar/3146678 to your computer and use it in GitHub Desktop.
auto-opper written in node
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
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