forked from GitHub/dbot
fff
This commit is contained in:
parent
da8c297973
commit
c247f48fbe
@ -63,24 +63,38 @@ var warning = function(dbot) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'~rmwarning': function(event) {
|
'~rmwarning': function(event) {
|
||||||
var warning = null;
|
var user = event.params[1],
|
||||||
dbot.api.users.resolveUser(event.server, event.input[1], function(err, warnee) {
|
index = parseInt(event.params[2]);
|
||||||
|
|
||||||
|
dbot.api.users.resolveUser(event.server, user, function(err, warnee) {
|
||||||
if(warnee) {
|
if(warnee) {
|
||||||
this.db.search('warnings', { 'warnee': warnee.id, 'reason': event.input[2] }, function(result) {
|
var warns = {};
|
||||||
warning = result;
|
|
||||||
|
dbot.api.getUserAlises(warnee.id, function(err, aliases) {
|
||||||
|
var alia = aliases.push(warnee.primaryNick);
|
||||||
|
this.db.search('notifies', {
|
||||||
|
'server': warnee.id,
|
||||||
|
'type': 'warn'
|
||||||
|
}, function(result) {
|
||||||
|
if(_.include(alia, result.target)) {
|
||||||
|
warns[result.time] = result;
|
||||||
|
}
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if(!err && warning) {
|
var sTimes = _.keys(warns).sort(function(a, b) {
|
||||||
this.db.del('warnings', warning.id, function(err) {
|
return parseInt(a) - parseInt(b);
|
||||||
|
});
|
||||||
|
|
||||||
|
if(index < sTimes.length && index > 0) {
|
||||||
|
this.db.del('notifies', warns[sTimes[index]], function(err) {
|
||||||
event.reply(dbot.t('warning_removed'));
|
event.reply(dbot.t('warning_removed'));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t('warning_not_found'));
|
event.reply(dbot.t('warning_not_found'));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
} else {
|
});
|
||||||
event.reply(dbot.t('warning_not_found'));
|
|
||||||
}
|
}
|
||||||
}.bind(this));
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'~rmlastwarning': function(event) {
|
'~rmlastwarning': function(event) {
|
||||||
@ -135,7 +149,6 @@ var warning = function(dbot) {
|
|||||||
|
|
||||||
this.commands['~warn'].regex = [/warn ([^ ]+) (.+)/, 3];
|
this.commands['~warn'].regex = [/warn ([^ ]+) (.+)/, 3];
|
||||||
this.commands['~warn'].access = 'power_user';
|
this.commands['~warn'].access = 'power_user';
|
||||||
this.commands['~rmwarning'].regex = [/^rmwarning ([\d\w\s\-]+?)[ ]?=[ ]?(.+)$/, 3];
|
|
||||||
this.commands['~rmwarning'].access = 'power_user';
|
this.commands['~rmwarning'].access = 'power_user';
|
||||||
this.commands['~rmlastwarning'].access = 'power_user';
|
this.commands['~rmlastwarning'].access = 'power_user';
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user