forked from GitHub/dbot
move warn to api and rmwarning
This commit is contained in:
parent
1af4788de0
commit
5ecd3054b3
@ -16,5 +16,14 @@
|
|||||||
"fr": "Attention : {warner} a donné un avertissement à {warnee} pour \"{reason}.\". Plus d'informations peuvent être trouvées ici : {url}",
|
"fr": "Attention : {warner} a donné un avertissement à {warnee} pour \"{reason}.\". Plus d'informations peuvent être trouvées ici : {url}",
|
||||||
"it": "Attenzione : {warner} ha dato un' avvertenza a {warnee} per \"{reason}.\". Ulterior informazioni si trovano a {url}",
|
"it": "Attenzione : {warner} ha dato un' avvertenza a {warnee} per \"{reason}.\". Ulterior informazioni si trovano a {url}",
|
||||||
"de": "{warner} hat {warnee} für \"{reason}.\" verwarnt. Mehr Informationen sind auf {url} erhältlich"
|
"de": "{warner} hat {warnee} für \"{reason}.\" verwarnt. Mehr Informationen sind auf {url} erhältlich"
|
||||||
|
},
|
||||||
|
"warning_not_found": {
|
||||||
|
"en": "Specified warning not found."
|
||||||
|
},
|
||||||
|
"warning_removed": {
|
||||||
|
"en": "Warning removed."
|
||||||
|
},
|
||||||
|
"warnee_not_found": {
|
||||||
|
"en": "{user} not found."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,16 @@ var _ = require('underscore')._;
|
|||||||
uuid = require('node-uuid');
|
uuid = require('node-uuid');
|
||||||
|
|
||||||
var warning = function(dbot) {
|
var warning = function(dbot) {
|
||||||
this.commands = {
|
this.api = {
|
||||||
'~warn': function(event) {
|
'warn': function(server, warner, user, reason, channel, callback) {
|
||||||
var warner = event.rUser,
|
var adminChannel = dbot.config.servers[server].admin_channel || channel.name;
|
||||||
server = event.server,
|
|
||||||
reason = event.input[2],
|
dbot.api.users.resolveUser(server, user, function(warnee) {
|
||||||
adminChannel = dbot.config.servers[server].admin_channel || event.channel.name;
|
|
||||||
|
|
||||||
dbot.api.users.resolveUser(server, event.input[1], function(warnee) {
|
|
||||||
if(warnee) {
|
if(warnee) {
|
||||||
var id = uuid.v4();
|
var id = uuid.v4();
|
||||||
this.db.save('warnings', id, {
|
this.db.save('warnings', id, {
|
||||||
'id': id,
|
'id': id,
|
||||||
'server': event.server,
|
'server': server,
|
||||||
'warnee': warnee.id,
|
'warnee': warnee.id,
|
||||||
'warner': warner.id,
|
'warner': warner.id,
|
||||||
'reason': reason,
|
'reason': reason,
|
||||||
@ -28,12 +25,49 @@ var warning = function(dbot) {
|
|||||||
+ warnee.primaryNick)
|
+ warnee.primaryNick)
|
||||||
});
|
});
|
||||||
|
|
||||||
dbot.api.report.notify('warn', event.server, event.rUser, adminChannel, notifyString);
|
dbot.api.report.notify('warn', server, warner, adminChannel, notifyString);
|
||||||
dbot.say(server, adminChannel, notifyString);
|
dbot.say(server, adminChannel, notifyString);
|
||||||
|
|
||||||
|
callback(null);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'~warn': function(event) {
|
||||||
|
var warner = event.rUser,
|
||||||
|
server = event.server,
|
||||||
|
reason = event.input[2];
|
||||||
|
|
||||||
|
this.api.warn(server, warner, event.input[1], reason, event.channel, function(err) {
|
||||||
|
if(err) {
|
||||||
event.reply(dbot.t('warnee_not_found', { 'user': event.input[1] }));
|
event.reply(dbot.t('warnee_not_found', { 'user': event.input[1] }));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'~rmwarning': function(event) {
|
||||||
|
var warning = null;
|
||||||
|
dbot.api.users.resolveUser(event.server, event.input[1], function(warnee) {
|
||||||
|
if(warnee) {
|
||||||
|
this.db.search('warnings', { 'warnee': warnee.id, 'reason': event.input[2] }, function(result) {
|
||||||
|
warning = result;
|
||||||
|
}, function(err) {
|
||||||
|
if(!err && warning) {
|
||||||
|
this.db.del('warnings', warning.id, function(err) {
|
||||||
|
event.reply(dbot.t('warning_removed'));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('warning_not_found'));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('warning_not_found'));
|
||||||
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -67,6 +101,8 @@ 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';
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.fetch = function(dbot) {
|
exports.fetch = function(dbot) {
|
||||||
|
Loading…
Reference in New Issue
Block a user