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

testing version of [#530]

This commit is contained in:
reality 2013-07-14 14:55:15 +00:00
parent 08843950dd
commit 2203f50dea
2 changed files with 44 additions and 4 deletions

View File

@ -185,8 +185,15 @@ var commands = function(dbot) {
event.reply(dbot.t("config_array", { "alternate": "pushconfig" })); event.reply(dbot.t("config_array", { "alternate": "pushconfig" }));
} }
} else { } else {
event.reply(dbot.t('new_config_key', { 'key': configPath })); topConfigPath = configPath.split('.')[0];
config = null; 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) { this.internalAPI.setConfig(configPath, newOption, function(err) {

View File

@ -1,7 +1,11 @@
var _ = require('underscore')._, var _ = require('underscore')._,
uuid = require('node-uuid'); uuid = require('node-uuid'),
async = require('async');
var report = function(dbot) { var report = function(dbot) {
if(!dbot.db.pending) dbot.db.pending = {};
this.pending = dbot.db.pending;
this.api = { this.api = {
'notify': function(server, channel, message) { 'notify': function(server, channel, message) {
var channel = dbot.instance.connections[server].channels[channel]; var channel = dbot.instance.connections[server].channels[channel];
@ -13,6 +17,25 @@ var report = function(dbot) {
} }
}, this); }, 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 i = 0;
var notifyChannel = function(ops) { var notifyChannel = function(ops) {
if(i >= ops.length) return; 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 = { var commands = {
'~report': function(event) { '~report': function(event) {
var channelName = event.input[1], var channelName = event.input[1],
nick = event.input[2]; nick = event.input[2],
reason = event.input[3]; reason = event.input[3];
dbot.api.users.resolveUser(event.server, nick, function(reportee) { dbot.api.users.resolveUser(event.server, nick, function(reportee) {