kara
Version:
A third generation EX-400 android
40 lines (32 loc) • 986 B
JavaScript
var Kick = module.exports = function Kick(bot) {
function hook(msg) {
if (/^kick\b/.test(msg.body)) {
msg.tokens = msg.body.trim().split(/\s+/);
bot.enqueue(function(next) { onKick(msg, next) });
}
}
function onKick(msg, next) {
msg.target = msg.tokens[1];
msg.reason = msg.tokens.slice(2).join(" ");
bot.send("WHOIS", [msg.from]);
// :server 330 kara <queryNick> <identifiedNick> :is logged in as
bot.once("irc:330", function(res){
bot.reply(msg, JSON.stringify(res));
next();
});
}
// function kick(nick) {
// // msg.to = msg.parameters[0];
// // msg.query = msg.parameters[1];
// msg.identifiedAs = msg.parameters[2];
// if (bot.isAdmin(msg.identifiedAs)) {
// bot.send("KICK", kickNick);
// }
// }
this.enable = function enable() {
bot.on("msg:direct", hook);
};
this.disable = function disable() {
bot.removeListener("msg:direct", hook);
};
};