diff --git a/config.json.sample b/config.json.sample index 043afd6..87190a7 100644 --- a/config.json.sample +++ b/config.json.sample @@ -14,6 +14,7 @@ }, "admins": [ "batman" ], "moderators": [ "whatever" ], + "power_users": [], "moduleNames": [ "ignore", "admin", "command", "dice", "js", "kick", "quotes", "spelling", "youare", "timers", "stats", "users", "link" ], "language": "en", "debugMode": false, diff --git a/modules/command/api.js b/modules/command/api.js index f5be301..c68d716 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -8,9 +8,10 @@ var api = function(dbot) { 'hasAccess': function(user, command, callback) { var accessNeeded = dbot.commands[command].access; - if(accessNeeded == 'admin' || accessNeeded == 'moderator') { + if(accessNeeded == 'admin' || accessNeeded == 'moderator' || accessNeeded == 'power_user') { var allowedNicks = dbot.config.admins; if(accessNeeded == 'moderator') allowedNicks = _.union(allowedNicks, dbot.config.moderators); + if(accessNeeded == 'power_user') allowedNicks = _.union(allowedNicks, dbot.config.power_users); if(!_.include(allowedNicks, user.primaryNick)) { callback(false); diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 426970e..fd02f16 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -3,6 +3,49 @@ var _ = require('underscore')._; var commands = function(dbot) { var commands = { /*** Kick Management ***/ + '~quiet': function(event) { + var server = event.server, + quieter = event.user, + minutes = event.input[1], + channel = event.input[2], + quietee = event.input[3].trim(); + + if(_.isUndefined(channel)) { + channel = event.channel.name; + } + channel = channel.trim(); + + if(!_.isUndefined(minutes)) { + minutes = parseFloat(minutes.trim()); + var msTimeout = new Date(new Date().getTime() + (minutes * 60000)); + dbot.api.timers.addTimeout(msTimeout, function() { + this.api.unquiet(server, quietee, channel); + }.bind(this)); + event.reply(dbot.t('tquieted', { + 'quietee': quietee, + 'minutes': minutes + })); + } else { + event.reply(dbot.t('quieted', { 'quietee': quietee })); + } + + this.api.quiet(server, quietee, channel); + }, + + '~unquiet': function(event) { + var server = event.server, + quieter = event.user, + channel = event.input[1], + quietee = event.input[2].trim(); + + if(_.isUndefined(channel)) { + channel = event.channel.name; + } + channel = channel.trim(); + + this.api.unquiet(server, quietee, channel); + event.reply(dbot.t('unquieted', { 'quietee': quietee })); + }, '~ckick': function(event) { var server = event.server, @@ -223,6 +266,8 @@ var commands = function(dbot) { commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4]; commands['~nban'].regex = /^~nban ([\d\.^ ]+)?([^ ]+) (.+)$/; + commands['~quiet'].regex = /^~quiet ([\d\.^ ]+)?(#[^ ]+ )?([^ ]+) ?$/; + commands['~unquiet'].regex = /^~unquiet (#[^ ]+ )?([^ ]+) ?$/; return commands; }; diff --git a/modules/kick/kick.js b/modules/kick/kick.js index f90315e..9652be5 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -13,6 +13,10 @@ var kick = function(dbot) { dbot.say(server, this.config.chanserv, 'quiet ' + channel + ' ' + user); }, + 'unquiet': function(server, user, channel) { + dbot.say(server, this.config.chanserv, 'unquiet ' + channel + ' ' + user); + }, + 'kick': function(server, user, channel, msg) { dbot.instance.connections[server].send('KICK ' + channel + ' ' + user + ' :' + msg); }, diff --git a/modules/kick/strings.json b/modules/kick/strings.json index 07d8064..e81cceb 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -7,6 +7,15 @@ "nl": "{user} is {kicks} keer gekickt en heeft anderen {kicked} keer gekickt.", "de": "{user} wurde {kicks} mal gekickt und hat {kicked} mal andere Benutzer gekickt." }, + "quieted": { + "en": "Quieted {quietee}. Remember: don't be a coconut." + }, + "tquieted": { + "en": "Quieted {quietee} for {minutes} minutes. Remember: don't be a coconut." + }, + "unquieted": { + "en": "Unquieted {quietee}. Remember: don't be a coconut." + }, "kicked_dbot": { "en": "Thou shalt not kick {botname}", "es": "No expulsás {botname}",