3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 04:49:25 +01:00

sustatus thing

This commit is contained in:
reality 2016-01-29 17:55:03 +00:00
parent 9ca81e3094
commit e52699b211

View File

@ -112,83 +112,76 @@ var commands = function(dbot) {
if(_.include(aliases, notify.target)) { if(_.include(aliases, notify.target)) {
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') { } else if(notify.type == 'unban') {
unban++; unban++;
if(notify.time > latest_unban.time) { if(notify.time > latest_unban.time) {
latest_unban = notify; 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;
}
/*_.each(aliases, function(alias) {
if(notify.message.indexOf('banned ' + alias + ' ') != -1 ||
notify.message.indexOf(' ' + alias + ' has been unbanned') != -1 ||
notify.message.indexOf('issued a warning to ' + alias) != -1 ||
notify.message.indexOf('has quieted ' + alias) != -1 ||
notify.message.indexOf('has reported ' + alias + ' ') != -1) {
if(notify.type == 'ban') {
ban++;
if(notify.time > latest_ban.time) {
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 == 'quiet') {
*/ quiet++;
} else if(notify.type == 'warn') {
warn++;
} else if(notify.type == 'report') {
report++;
}
items[notify.time] = notify;
}
}, function() { }, function() {
if(quiet != 0 || warn != 0 || report != 0) { if(quiet != 0 || warn != 0 || report != 0) {
event.reply(user.primaryNick + ' has been warned ' + warn + ' times, quieted ' + quiet + ' times, and reported ' + report + ' times.'); event.reply(user.primaryNick + ' has been warned ' + warn + ' times, quieted ' + quiet + ' times, and reported ' + report + ' times.');
var sTimes = _.keys(items).sort(function(a, b) { var sTimes = _.keys(items).sort(function(a, b) {
return parseInt(a) - parseInt(b); return parseInt(a.time) - parseInt(b.time);
});
if(sTimes.length < 70) {
event.reply('[reports]');
_.each(sTimes, function(time) {
if(items[time].type == 'report') {
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]);
}
}); });
event.reply('[quiets]');
_.each(sTimes, function(time) {
if(items[time].type == 'quiet') {
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]);
}
});
event.reply('[warns]');
_.each(sTimes, function(time) {
if(items[time].type == 'warn') {
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]);
}
});
event.reply('[bans]');
_.each(sTimes, function(time) {
if(items[time].type == 'ban' || items[time].type == 'unban') {
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]);
}
});
} else {
event.reply('There are too many to show without killing everyone :S');
}
if(sTimes.length < 70) { if(latest_ban.time != 0) {
_.each(sTimes, function(time) { if(latest_unban.time == 0 || (latest_unban.time < latest_ban.time)) {
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[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 { } else {
event.reply('There are too many to show without killing everyone :S'); 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');
if(latest_ban.time != 0) { event.reply('Most recent ban reason: ' + latest_ban.message);
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') + ')'); } else {
event.reply('Reason: ' + latest_ban.message); event.reply('Current Ban Status: \u00033Never banned (\u00037probably\u00033)\u000f');
} else { }
var a = moment(latest_ban.time); } else {
var b = moment(latest_unban.time); event.reply(user.primaryNick + ' has no record.');
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 {
event.reply('Current Ban Status: \u00033Never banned (\u00037probably\u00033)\u000f');
}
} else {
event.reply(user.primaryNick + ' has no record.');
}
}); });
}.bind(this)); }.bind(this));
} else { } else {