From 539d0106e2f1f06271032da5a903391cbfb5d521 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 1 Jul 2013 18:34:02 +0000 Subject: [PATCH] timed quiet maybe --- modules/kick/commands.js | 23 ++++++++++++++++++----- modules/kick/strings.json | 3 +++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 21001a9..c778743 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -3,20 +3,33 @@ var _ = require('underscore')._; var commands = function(dbot) { var commands = { /*** Kick Management ***/ - '~quiet': function(event) { var server = event.server, quieter = event.user, - channel = event.input[1], - quietee = event.input[2].trim(); + 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() + (timeout * 3600000)); + 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); - event.reply(dbot.t('quieted', { 'quietee': quietee })); }, '~unquiet': function(event) { @@ -254,7 +267,7 @@ var commands = function(dbot) { commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4]; commands['~nban'].regex = /^~nban ([\d\.^ ]+)?([^ ]+) (.+)$/; - commands['~quiet'].regex = /^~quiet (#[^ ]+ )?([^ ]+) ?$/; + commands['~quiet'].regex = /^~quiet ([\d\.^ ]+)?(#[^ ]+ )?([^ ]+) ?$/; commands['~unquiet'].regex = /^~unquiet (#[^ ]+ )?([^ ]+) ?$/; return commands; diff --git a/modules/kick/strings.json b/modules/kick/strings.json index cd2b0bc..e81cceb 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -10,6 +10,9 @@ "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." },