forked from GitHub/dbot
nickserv module in master
This commit is contained in:
parent
218509b786
commit
c37e9cded7
9
modules/nickserv/config.json
Normal file
9
modules/nickserv/config.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"servers": {
|
||||||
|
"nc": {
|
||||||
|
"matcher": "STATUS ([^ ]+) (\\d)$",
|
||||||
|
"acceptableState": 3,
|
||||||
|
"infoCommand": "status"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
modules/nickserv/nickserv.js
Normal file
37
modules/nickserv/nickserv.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
var nickserv = function(dbot) {
|
||||||
|
this.authStack = {};
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'auth': function(server, nick, callback) {
|
||||||
|
var nickserv = dbot.config.servers[server].nickserv,
|
||||||
|
infoCommand = this.config.servers[server].infoCommand;
|
||||||
|
|
||||||
|
if(!_.has(this.authStack, server)) this.authStack[server] = {};
|
||||||
|
this.authStack[server][nick] = callback;
|
||||||
|
|
||||||
|
dbot.say(server, nickserv, infoCommand + ' ' + 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.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
this.on = 'NOTICE';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new nickserv(dbot);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user