diff --git a/modules/kick/commands.js b/modules/kick/commands.js index a3dd294..4310d79 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -1,6 +1,9 @@ +var _ = require('underscore')._; + var commands = function(dbot) { var commands = { /*** Kick Management ***/ + '~ckick': function(event) { var server = event.server, kicker = event.user, @@ -9,7 +12,8 @@ var commands = function(dbot) { reason = event.input[3]; this.api.kick(server, kickee, channel, reason + ' (requested by ' + kicker + ')'); - dbot.api.report.notify(server, channel, kicker, kickee, dbot.t('ckicked', { + + dbot.api.report.notify(server, channel, dbot.t('ckicked', { 'kicker': kicker, 'kickee': kickee, 'channel': channel, @@ -17,6 +21,80 @@ var commands = function(dbot) { })); }, + '~cban': function(event) { + var server = event.server, + banner = event.user, + banee = event.input[2], + channel = event.input[1], + reason = event.input[3]; + + this.api.ban(server, banee, channel); + this.api.kick(server, kickee, channel, reason + ' (requested by ' + banner + ')'); + + dbot.api.report.notify(server, channel, dbot.t('cbanned', { + 'banner': banner, + 'banee': banee, + 'channel': channel, + 'reason': reason + })); + }, + + '~cquiet': function(event) { + var server = event.server, + quieter = event.user, + quietee = event.input[2], + channel = event.input[1], + reason = event.input[3]; + + this.api.quiet(server, quietee, channel); + + dbot.api.report(server, channel, dbot.t('cquieted', { + 'quieter': quieter, + 'quietee': quietee, + 'channel': channel, + 'reason': reason + })); + }, + + '~nquiet': function(event) { + var server = event.server, + quieter = event.user, + quietee = event.input[1], + channels = dbot.config.servers[server].channels, + reason = event.input[2]; + + _.each(channels, function(channel) { + this.api.quiet(server, quietee, channel); + }, this); + + dbot.api.report(server, channel, dbot.t('nquieted', { + 'quieter': quieter, + 'quietee': quietee, + 'reason': reason + })); + }, + + // Kick and ban from all channels on the network. + '~nban': function(event) { + var server = event.server, + banner = event.user, + banee = event.input[1], + reason = event.input[2], + channels = dbot.config.servers[server].channels; + + _.each(channels, function(channel) { + this.api.ban(server, banee, channel); + this.api.kick(server, banee, channel, reason + + ' (network-wide ban requested by ' + banner + ')'); + }, this); + + dbot.api.report.notify(server, this.config.admin_channels[event.server], dbot.t('nbanned', { + 'banner': banner, + 'banee': banee, + 'reason': reason + })); + }, + /*** Kick Stats ***/ // Give the number of times a given user has been kicked and has kicked @@ -67,8 +145,12 @@ var commands = function(dbot) { } }; - commands['~ckick'].access = 'moderator'; + _.each(commands, function(command) { + command.access = 'moderator'; + }); + commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4]; + commands['~nban'].regex = [/^~nban ([^ ]+) (.+)$/, 3]; return commands; }; diff --git a/modules/kick/config.json b/modules/kick/config.json index c32561f..bd6e05f 100644 --- a/modules/kick/config.json +++ b/modules/kick/config.json @@ -4,5 +4,8 @@ "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md", "ignorable": true, "countSilently": true, + "admin_channels": { + "aberwiki": "#fishbox" + }, "chanserv": "ChanServ" } diff --git a/modules/kick/strings.json b/modules/kick/strings.json index 6764552..e9e13f5 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -17,4 +17,7 @@ "cy": "Ni ddylech cicio {botname}", "nl": "Gij zult {botname} niet kicken" } + "nbanned": { + "en": "Attention: {banner} has banned {banee} network-wide. The reason given was \"{reason}.\"" + } } diff --git a/modules/report/report.js b/modules/report/report.js index 9c7953b..1f545df 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -2,7 +2,7 @@ var _ = require('underscore')._; var report = function(dbot) { this.api = { - 'notify': function(server, channel, reporter, reported, message) { + 'notify': function(server, channel, message) { var channel = dbot.instance.connections[server].channels[channel]; var ops = _.filter(channel.nicks, function(user) { if(this.config.notifyVoice) { @@ -27,7 +27,7 @@ var report = function(dbot) { if(_.has(event.allChannels, channelName)) { if(dbot.api.users.isChannelUser(event.server, nick, channelName, true)) { nick = dbot.api.users.resolveUser(event.server, nick, true); - this.api.notify(event.server, channelName, event.user, nick, dbot.t('report', { + this.api.notify(event.server, channelName, dbot.t('report', { 'reporter': event.user, 'reported': nick, 'channel': channelName,