From 2203f50dea2153ffc8f0138defe753b31ed65b33 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Jul 2013 14:55:15 +0000 Subject: [PATCH] testing version of [#530] --- modules/admin/commands.js | 11 +++++++++-- modules/report/report.js | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/modules/admin/commands.js b/modules/admin/commands.js index 252c234..9ca3d0d 100644 --- a/modules/admin/commands.js +++ b/modules/admin/commands.js @@ -185,8 +185,15 @@ var commands = function(dbot) { event.reply(dbot.t("config_array", { "alternate": "pushconfig" })); } } else { - event.reply(dbot.t('new_config_key', { 'key': configPath })); - config = null; + topConfigPath = configPath.split('.')[0]; + if(_.has(dbot.config.modules, topConfigPath)) { + configPath.splice(0, 0, 'modules'); + event.params[1] = configPath.join('.'); + this.commands['~showconfig'](event); + return; + } else { + event.reply(dbot.t('new_config_key', { 'key': configPath })); + } } this.internalAPI.setConfig(configPath, newOption, function(err) { diff --git a/modules/report/report.js b/modules/report/report.js index 52e50c4..b196147 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -1,7 +1,11 @@ var _ = require('underscore')._, - uuid = require('node-uuid'); + uuid = require('node-uuid'), + async = require('async'); var report = function(dbot) { + if(!dbot.db.pending) dbot.db.pending = {}; + this.pending = dbot.db.pending; + this.api = { 'notify': function(server, channel, message) { var channel = dbot.instance.connections[server].channels[channel]; @@ -13,6 +17,25 @@ var report = function(dbot) { } }, this); + dbot.api.users.getChannel(server, channel, function(channel) { + if(channel) { + var perOps = channel.op; + if(this.config.notifyVoice) pOps = _.union(perOps, channel.voice); + + async.eachSeries(ops, function(nick, next) { + dbot.api.users.resolveUser(server, nick, function(user) { + perOps = _.without(perOps, user.id); next(); + }); + }, function() { + offlineUsers = perOps; + _.each(offlineUsers, function(id) { + if(!this.pending[id]) this.pending[id] = []; + this.pending[id].push(message); + }.bind(this)); + }.bind(this)); + } + }.bind(this)); + var i = 0; var notifyChannel = function(ops) { if(i >= ops.length) return; @@ -25,10 +48,20 @@ var report = function(dbot) { } }; + this.listener = function(event) { + if(_.has(this.pending, event.rUser.id)) { + _.each(this.pending[event.rUser.id], function(message) { + dbot.say(event.server, event.rUser.currentNick, message); + }); + delete this.pending[event.rUser.id]; + } + }.bind(this); + this.on = 'JOIN'; + var commands = { '~report': function(event) { var channelName = event.input[1], - nick = event.input[2]; + nick = event.input[2], reason = event.input[3]; dbot.api.users.resolveUser(event.server, nick, function(reportee) {