mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 22:39:26 +01:00
initial 302 USERHOST support in nickserv api [#498]
This commit is contained in:
parent
9dc9ebfd2e
commit
3e2f96fb11
@ -1,5 +1,6 @@
|
|||||||
var nickserv = function(dbot) {
|
var nickserv = function(dbot) {
|
||||||
this.authStack = {};
|
this.authStack = {};
|
||||||
|
this.userStack = {};
|
||||||
|
|
||||||
this.api = {
|
this.api = {
|
||||||
'auth': function(server, nick, callback) {
|
'auth': function(server, nick, callback) {
|
||||||
@ -8,26 +9,34 @@ var nickserv = function(dbot) {
|
|||||||
|
|
||||||
if(!_.has(this.authStack, server)) this.authStack[server] = {};
|
if(!_.has(this.authStack, server)) this.authStack[server] = {};
|
||||||
this.authStack[server][nick] = callback;
|
this.authStack[server][nick] = callback;
|
||||||
|
|
||||||
dbot.say(server, nickserv, infoCommand + ' ' + nick);
|
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) {
|
this.listener = function(event) {
|
||||||
var nickserv = dbot.config.servers[event.server].nickserv,
|
if(event.action == 'NOTICE') {
|
||||||
statusRegex = this.config.servers[event.server].matcher,
|
var nickserv = dbot.config.servers[event.server].nickserv,
|
||||||
acceptableState = this.config.servers[event.server].acceptableState;
|
statusRegex = this.config.servers[event.server].matcher,
|
||||||
|
acceptableState = this.config.servers[event.server].acceptableState;
|
||||||
|
|
||||||
|
if(event.user == nickserv) {
|
||||||
if(event.user == nickserv) {
|
var info = event.params.match(statusRegex);
|
||||||
var info = event.params.match(statusRegex);
|
if(info && _.has(this.authStack, event.server)) {
|
||||||
if(info && _.has(this.authStack, event.server)) {
|
if(info[2] == acceptableState ) {
|
||||||
if(info[2] == acceptableState ) {
|
this.authStack[event.server][info[1]](true);
|
||||||
this.authStack[event.server][info[1]](true);
|
} else {
|
||||||
} else {
|
this.authStack[event.server][info[1]](false);
|
||||||
this.authStack[event.server][info[1]](false);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(event.action == '302') {
|
||||||
|
console.log(event.params);
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
this.on = 'NOTICE';
|
this.on = 'NOTICE';
|
||||||
|
Loading…
Reference in New Issue
Block a user