mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
find alias notifies
This commit is contained in:
parent
3d92550c76
commit
849067127f
@ -85,72 +85,76 @@ var commands = function(dbot) {
|
|||||||
|
|
||||||
dbot.api.users.resolveUser(event.server, user, function(err, user) {
|
dbot.api.users.resolveUser(event.server, user, function(err, user) {
|
||||||
if(user) {
|
if(user) {
|
||||||
var ban = 0,
|
dbot.api.users.getUserAliases(user.id, function(err, aliases) {
|
||||||
latest_ban = {'time':0},
|
var ban = 0,
|
||||||
latest_unban = {'time':0},
|
latest_ban = {'time':0},
|
||||||
unban = 0,
|
latest_unban = {'time':0},
|
||||||
quiet = 0,
|
unban = 0,
|
||||||
warn = 0,
|
quiet = 0,
|
||||||
report = 0,
|
warn = 0,
|
||||||
items = {};
|
report = 0,
|
||||||
|
items = {};
|
||||||
|
aliases.push(user.primaryNick);
|
||||||
|
|
||||||
// i'll fix it later
|
dbot.modules.report.db.search('notifies', {
|
||||||
dbot.modules.report.db.search('notifies', {
|
'server': event.server
|
||||||
'server': event.server
|
}, function(notify) {
|
||||||
}, function(notify) {
|
_.each(aliases, function(alias) {
|
||||||
if(notify.message.match('banned ' + user.primaryNick) ||
|
if(notify.message.match('banned ' + alias) ||
|
||||||
notify.message.match(user.primaryNick + ' has been unbanned') ||
|
notify.message.match(alias + ' has been unbanned') ||
|
||||||
notify.message.match('issued a warning to ' + user.primaryNick) ||
|
notify.message.match('issued a warning to ' + alias) ||
|
||||||
notify.message.match('has quieted ' + user.primaryNick) ||
|
notify.message.match('has quieted ' + alias) ||
|
||||||
notify.message.match('has reported ' + user.primaryNick)) {
|
notify.message.match('has reported ' + alias)) {
|
||||||
if(notify.type == 'ban') {
|
if(notify.type == 'ban') {
|
||||||
ban++;
|
ban++;
|
||||||
if(notify.time > latest_ban.time) {
|
if(notify.time > latest_ban.time) {
|
||||||
latest_ban = notify;
|
latest_ban = notify;
|
||||||
|
}
|
||||||
|
} else if(notify.type == 'unban') {
|
||||||
|
unban++;
|
||||||
|
if(notify.time > latest_unban.time) {
|
||||||
|
latest_unban = notify;
|
||||||
|
}
|
||||||
|
} else if(notify.type == 'quiet') {
|
||||||
|
quiet++;
|
||||||
|
} else if(notify.type == 'warn') {
|
||||||
|
warn++;
|
||||||
|
} else if(notify.type == 'report') {
|
||||||
|
report++;
|
||||||
|
}
|
||||||
|
items[notify.time] = notify.message;
|
||||||
}
|
}
|
||||||
} else if(notify.type == 'unban') {
|
|
||||||
unban++;
|
|
||||||
if(notify.time > latest_unban.time) {
|
|
||||||
latest_unban = notify;
|
|
||||||
}
|
|
||||||
} else if(notify.type == 'quiet') {
|
|
||||||
quiet++;
|
|
||||||
} else if(notify.type == 'warn') {
|
|
||||||
warn++;
|
|
||||||
} else if(notify.type == 'report') {
|
|
||||||
report++;
|
|
||||||
}
|
|
||||||
items[notify.time] = notify.message;
|
|
||||||
}
|
|
||||||
}, function() {
|
|
||||||
if(quiet != 0 || warn != 0 || report != 0) {
|
|
||||||
event.reply(user.primaryNick + ' has been warned ' + warn + ' times, quieted ' + quiet + ' times, and reported ' + report + ' times.');
|
|
||||||
|
|
||||||
var sTimes = _.keys(items).sort(function(a, b) {
|
|
||||||
return parseInt(a) - parseInt(b);
|
|
||||||
});
|
|
||||||
|
|
||||||
_.each(sTimes, function(time) {
|
|
||||||
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]);
|
|
||||||
});
|
});
|
||||||
|
}, function() {
|
||||||
|
if(quiet != 0 || warn != 0 || report != 0) {
|
||||||
|
event.reply(user.primaryNick + ' has been warned ' + warn + ' times, quieted ' + quiet + ' times, and reported ' + report + ' times.');
|
||||||
|
|
||||||
if(latest_ban.time != 0) {
|
var sTimes = _.keys(items).sort(function(a, b) {
|
||||||
if(latest_unban.time == 0 || (latest_unban.time < latest_ban.time)) {
|
return parseInt(a) - parseInt(b);
|
||||||
event.reply('Current Ban Status: \u00034Banned\u000f since ' + moment(latest_ban.time).fromNow() + ' (' + moment(parseInt(latest_ban.time)).format('DD/MM/YYYY') + ')');
|
});
|
||||||
event.reply('Reason: ' + latest_ban.message);
|
|
||||||
|
_.each(sTimes, function(time) {
|
||||||
|
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]);
|
||||||
|
});
|
||||||
|
|
||||||
|
if(latest_ban.time != 0) {
|
||||||
|
if(latest_unban.time == 0 || (latest_unban.time < latest_ban.time)) {
|
||||||
|
event.reply('Current Ban Status: \u00034Banned\u000f since ' + moment(latest_ban.time).fromNow() + ' (' + moment(parseInt(latest_ban.time)).format('DD/MM/YYYY') + ')');
|
||||||
|
event.reply('Reason: ' + latest_ban.message);
|
||||||
|
} else {
|
||||||
|
var a = moment(latest_ban.time);
|
||||||
|
var b = moment(latest_unban.time);
|
||||||
|
event.reply('Current Ban Status: \u00037Unbanned\u000f since ' + moment(parseInt(latest_unban.time)).format('DD/MM/YYYY') + ' after being banned for ' + b.diff(a, 'days') + ' days');
|
||||||
|
event.reply('Most recent ban reason: ' + latest_ban.message);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var a = moment(latest_ban.time);
|
event.reply('Current Ban Status: \u00033Never banned (\u00037probably\u00033)\u000f');
|
||||||
var b = moment(latest_unban.time);
|
|
||||||
event.reply('Current Ban Status: \u00037Unbanned\u000f since ' + moment(parseInt(latest_unban.time)).format('DD/MM/YYYY') + ' after being banned for ' + b.diff(a, 'days') + ' days');
|
|
||||||
event.reply('Most recent ban reason: ' + latest_ban.message);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
event.reply('Current Ban Status: \u00033Never banned (\u00037probably\u00033)\u000f');
|
event.reply(user.primaryNick + ' has no record.');
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
event.reply(user.primaryNick + ' has no record.');
|
}.bind(this));
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
event.reply('never heard of em');
|
event.reply('never heard of em');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user