3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-30 16:09:27 +01:00

Initial non-persistent support for temp banning [#495]

This commit is contained in:
reality 2013-06-10 16:59:56 +00:00
parent 5f86eb225f
commit 1c84837611
3 changed files with 50 additions and 17 deletions

View File

@ -66,12 +66,29 @@ var commands = function(dbot) {
this.hosts[event.server][banee] = host; this.hosts[event.server][banee] = host;
// Create notify string // Create notify string
/*if(!_.isUndefined(timeout)) { if(!_.isUndefined(timeout)) {
timeout = new Date(new Date().getTime() + (timeout * 3600000)); timeout = parseFloat(timeout.trim());
var msTimeout = new Date(new Date().getTime() + (timeout * 3600000));
if(!_.has(this.tempBans, event.server)) this.tempBans[event.server] = {}; if(!_.has(this.tempBans, event.server)) this.tempBans[event.server] = {};
this.tempBans[event.server][banee] = timeout; this.tempBans[event.server][banee] = msTimeout;
this.internalAPI.addTempBan(event.server, banee, timeout); this.internalAPI.addTempBan(event.server, banee, msTimeout);
} else {*/
var notifyString = dbot.t('tbanned', {
'network': network,
'banner': banner,
'banee': banee,
'hours': timeout,
'reason': reason
});
var quoteString = dbot.t('tban_quote', {
'banee': banee,
'banner': banner,
'hours': timeout,
'time': new Date().toUTCString(),
'reason': reason
});
} else {
var notifyString = dbot.t('nbanned', { var notifyString = dbot.t('nbanned', {
'network': network, 'network': network,
'banner': banner, 'banner': banner,
@ -84,8 +101,7 @@ var commands = function(dbot) {
'time': new Date().toUTCString(), 'time': new Date().toUTCString(),
'reason': reason 'reason': reason
}); });
//} }
console.log(notifyString);
// Add qutoe category documenting ban // Add qutoe category documenting ban
if(this.config.document_bans && _.has(dbot.modules, 'quotes')) { if(this.config.document_bans && _.has(dbot.modules, 'quotes')) {
@ -100,12 +116,23 @@ var commands = function(dbot) {
dbot.api.report.notify(server, adminChannel, notifyString); dbot.api.report.notify(server, adminChannel, notifyString);
dbot.say(event.server, adminChannel, notifyString); dbot.say(event.server, adminChannel, notifyString);
dbot.say(event.server, banee, dbot.t('nbanned_notify', { if(!_.isUndefined(timeout)) {
'network': network, dbot.say(event.server, banee, dbot.t('tbanned_notify', {
'banner': banner, 'network': network,
'reason': reason, 'banner': banner,
'admin_channel': adminChannel 'reason': reason,
})); 'hours': timeout,
'admin_channel': adminChannel
}));
} else {
dbot.say(event.server, banee, dbot.t('nbanned_notify', {
'network': network,
'banner': banner,
'reason': reason,
'hours': timeout,
'admin_channel': adminChannel
}));
}
} }
// Ban the user from all channels // Ban the user from all channels
@ -196,7 +223,7 @@ var commands = function(dbot) {
commands['~kickstats'].access = 'regular'; commands['~kickstats'].access = 'regular';
commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4]; commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4];
commands['~nban'].regex = /^~nban ([\d^ ]+)?([^ ]+) (.+)$/; commands['~nban'].regex = /^~nban ([\d\.^ ]+)?([^ ]+) (.+)$/;
return commands; return commands;
}; };

View File

@ -78,9 +78,9 @@ var kick = function(dbot) {
this.internalAPI = { this.internalAPI = {
'addTempBan': function(server, banee, timeout) { 'addTempBan': function(server, banee, timeout) {
dbot.api.timers.addTimeout(timeout, function() { dbot.api.timers.addTimeout(timeout, function() {
this.api.networkUnban(server, banee, dbot.config.name, function(err) {});
}); }.bind(this));
} }.bind(this)
}; };
this.listener = function(event) { this.listener = function(event) {

View File

@ -25,6 +25,12 @@
"cy": "Sylw: {banner} wedi gwahardd {banee} o {channel}. Y rheswm a roddwyd oedd: \"{reason}.\"", "cy": "Sylw: {banner} wedi gwahardd {banee} o {channel}. Y rheswm a roddwyd oedd: \"{reason}.\"",
"de": "Achtung: {banner} hat {banee} von {channel} gebannt. Grund: \"{reason}.\"" "de": "Achtung: {banner} hat {banee} von {channel} gebannt. Grund: \"{reason}.\""
}, },
"tbanned": {
"en": "Attention: {banner} has banned {banee} from the {network} network for {hours} hours. The reason given was \"{reason}.\""
},
"tbanned_notify": {
"en": "You have been banned from the {network} network for {hours} hours by {banner}. The reason given was \"{reason}.\" You can join {admin_channel} for more information or to discuss the ban."
},
"nbanned": { "nbanned": {
"en": "Attention: {banner} has banned {banee} from the {network} network. The reason given was \"{reason}.\"", "en": "Attention: {banner} has banned {banee} from the {network} network. The reason given was \"{reason}.\"",
"cy": "Sylw: {banner} wedi gwahardd {banee} ledled y rhwydwaith. Y rheswm a roddwyd oedd: \"{reason}.\"", "cy": "Sylw: {banner} wedi gwahardd {banee} ledled y rhwydwaith. Y rheswm a roddwyd oedd: \"{reason}.\"",