mirror of
https://github.com/reality/dbot.git
synced 2024-12-28 05:32:50 +01:00
akill
This commit is contained in:
parent
d0aab89435
commit
a7ccb5ff14
@ -76,60 +76,72 @@ var atheme = function(dbot) {
|
||||
this.commands['~chanmode'].regex = [/^chanmode (\+.)/, 2];
|
||||
|
||||
this.listener = function(event) {
|
||||
if(event.user === 'ChanServ') {
|
||||
var flags = event.params.match(/(\d+)\s+([^ ]+)\s+(\+\w+)\s+\((\#[\w\.]+)\)/),
|
||||
end = event.params.match(/end of \u0002(\#[\w\.]+)\u0002 flags listing/i);
|
||||
if(event.action === 'NOTICE') {
|
||||
if(event.user === 'ChanServ') {
|
||||
var flags = event.params.match(/(\d+)\s+([^ ]+)\s+(\+\w+)\s+\((\#[\w\.]+)\)/),
|
||||
end = event.params.match(/end of \u0002(\#[\w\.]+)\u0002 flags listing/i);
|
||||
|
||||
if(flags && _.has(this.flagStack[event.server], flags[4])) {
|
||||
this.flagStack[event.server][flags[4]].flags[flags[2]] = flags[3];
|
||||
} else if(end) {
|
||||
if(_.has(this.flagStack[event.server], end[1])) {
|
||||
// Parse wildcard hostmasks to nicks
|
||||
var allFlags = this.flagStack[event.server][end[1]].flags,
|
||||
hostMasks = {};
|
||||
if(flags && _.has(this.flagStack[event.server], flags[4])) {
|
||||
this.flagStack[event.server][flags[4]].flags[flags[2]] = flags[3];
|
||||
} else if(end) {
|
||||
if(_.has(this.flagStack[event.server], end[1])) {
|
||||
// Parse wildcard hostmasks to nicks
|
||||
var allFlags = this.flagStack[event.server][end[1]].flags,
|
||||
hostMasks = {};
|
||||
|
||||
_.each(allFlags, function(f, u) { // TODO: combine to one loop
|
||||
if(u.indexOf('*!*@') !== -1) {
|
||||
hostMasks[u] = f;
|
||||
delete allFlags[u];
|
||||
}
|
||||
});
|
||||
|
||||
async.each(_.keys(hostMasks), function(hostMask, done) {
|
||||
this.api.getVHosts(event.server, hostMask.split('@')[1], function(err, users) {
|
||||
_.each(users, function(user) {
|
||||
allFlags[user] = hostMasks[hostMask];
|
||||
});
|
||||
done();
|
||||
_.each(allFlags, function(f, u) { // TODO: combine to one loop
|
||||
if(u.indexOf('*!*@') !== -1) {
|
||||
hostMasks[u] = f;
|
||||
delete allFlags[u];
|
||||
}
|
||||
});
|
||||
}.bind(this), function() {
|
||||
console.log('DONE');
|
||||
_.each(this.flagStack[event.server][end[1]].callbacks, function(callback) {
|
||||
callback(null, this.flagStack[event.server][end[1]].flags);
|
||||
}.bind(this));
|
||||
delete this.flagStack[event.server][end[1]];
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
} else if(event.user === 'HostServ') {
|
||||
_.each(this.hostStack[event.server], function(el, mask) {
|
||||
if(event.params.match(mask)) {
|
||||
var user = event.params.match(/- ([^ ]+)/),
|
||||
end = event.params.match(/matches for pattern/);
|
||||
|
||||
if(user) {
|
||||
this.hostStack[event.server][mask].users.push(user[1]);
|
||||
} else if(end) {
|
||||
_.each(this.hostStack[event.server][mask].callbacks, function(callback) {
|
||||
callback(null, this.hostStack[event.server][mask].users);
|
||||
}, this);
|
||||
delete this.hostStack[event.server][mask];
|
||||
async.each(_.keys(hostMasks), function(hostMask, done) {
|
||||
this.api.getVHosts(event.server, hostMask.split('@')[1], function(err, users) {
|
||||
_.each(users, function(user) {
|
||||
allFlags[user] = hostMasks[hostMask];
|
||||
});
|
||||
done();
|
||||
});
|
||||
}.bind(this), function() {
|
||||
console.log('DONE');
|
||||
_.each(this.flagStack[event.server][end[1]].callbacks, function(callback) {
|
||||
callback(null, this.flagStack[event.server][end[1]].flags);
|
||||
}.bind(this));
|
||||
delete this.flagStack[event.server][end[1]];
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
} else if(event.user === 'HostServ') {
|
||||
_.each(this.hostStack[event.server], function(el, mask) {
|
||||
if(event.params.match(mask)) {
|
||||
var user = event.params.match(/- ([^ ]+)/),
|
||||
end = event.params.match(/matches for pattern/);
|
||||
|
||||
if(user) {
|
||||
this.hostStack[event.server][mask].users.push(user[1]);
|
||||
} else if(end) {
|
||||
_.each(this.hostStack[event.server][mask].callbacks, function(callback) {
|
||||
callback(null, this.hostStack[event.server][mask].users);
|
||||
}, this);
|
||||
delete this.hostStack[event.server][mask];
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
} else { // PRIVMSG
|
||||
var akill = event.message.match(/([^ ]+) AKILL:ADD: ([^ ]+) \(reason: (.+)(\) )\(duration: ([^,)]+)/);
|
||||
if(event.channel === '#services' && akill) {
|
||||
var channel = dbot.config.servers[server].admin_channel;
|
||||
dbot.api.report.notify('ban', 'tripsit', akill[1], channel, dbot.t('akill', {
|
||||
'host': akill[2],
|
||||
'reason': akill[3],
|
||||
'duration': akill[4]
|
||||
}));
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
this.on = 'NOTICE';
|
||||
this.on = ['NOTICE', 'PRIVMSG'];
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
|
Loading…
Reference in New Issue
Block a user