From 3e2f96fb1107500a882fb51046be92a207b1c77a Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 16:05:19 +0000 Subject: [PATCH] initial 302 USERHOST support in nickserv api [#498] --- modules/nickserv/nickserv.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index e489878..5b6ca5a 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -1,5 +1,6 @@ var nickserv = function(dbot) { this.authStack = {}; + this.userStack = {}; this.api = { 'auth': function(server, nick, callback) { @@ -8,26 +9,34 @@ var nickserv = function(dbot) { if(!_.has(this.authStack, server)) this.authStack[server] = {}; this.authStack[server][nick] = callback; - dbot.say(server, nickserv, infoCommand + ' ' + nick); + }, + + 'getUserHost': function(server, nick, callback) { + if(!_.has(this.userStack, server)) this.userStack[server] = {}; + this.userStack[server][nick] = callback; + dbot.instance.connections.send('USERHOST ' + nick); } }; this.listener = function(event) { - var nickserv = dbot.config.servers[event.server].nickserv, - statusRegex = this.config.servers[event.server].matcher, - acceptableState = this.config.servers[event.server].acceptableState; + if(event.action == 'NOTICE') { + var nickserv = dbot.config.servers[event.server].nickserv, + statusRegex = this.config.servers[event.server].matcher, + acceptableState = this.config.servers[event.server].acceptableState; - - if(event.user == nickserv) { - var info = event.params.match(statusRegex); - if(info && _.has(this.authStack, event.server)) { - if(info[2] == acceptableState ) { - this.authStack[event.server][info[1]](true); - } else { - this.authStack[event.server][info[1]](false); + if(event.user == nickserv) { + var info = event.params.match(statusRegex); + if(info && _.has(this.authStack, event.server)) { + if(info[2] == acceptableState ) { + this.authStack[event.server][info[1]](true); + } else { + this.authStack[event.server][info[1]](false); + } } } + } else if(event.action == '302') { + console.log(event.params); } }.bind(this); this.on = 'NOTICE';