3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-02 17:09:29 +01:00

Quiet no longer uses chanserv. Some cleanup of host code. Should fix [#601]

This commit is contained in:
reality 2014-02-03 17:37:38 +00:00
parent 68e13e7bcd
commit 39d0bd7058
2 changed files with 62 additions and 55 deletions

View File

@ -8,20 +8,21 @@ var commands = function(dbot) {
var server = event.server, var server = event.server,
quieter = event.user, quieter = event.user,
minutes = event.input[1], minutes = event.input[1],
channel = event.input[2], channel = (event.input[2] || event.channel.name).trim(),
quietee = event.input[3].trim(), quietee = event.input[3].trim(),
reason = event.input[4] || "N/A"; reason = event.input[4] || "N/A";
if(_.isUndefined(channel)) { dbot.api.nickserv.getUserHost(server, quietee, function(host) {
channel = event.channel.name; // Add host record entry
} if(host) {
channel = channel.trim(); this.hosts[server][quietee] = host;
if(!_.isUndefined(minutes)) { if(!_.isUndefined(minutes)) {
minutes = parseFloat(minutes.trim()); minutes = parseFloat(minutes.trim());
var msTimeout = new Date(new Date().getTime() + (minutes * 60000)); var msTimeout = new Date(new Date().getTime() + (minutes * 60000));
dbot.api.timers.addTimeout(msTimeout, function() { dbot.api.timers.addTimeout(msTimeout, function() {
this.api.unquiet(server, quietee, channel); if(_.has(this.hosts[server], quietee)) {
this.api.unquiet(server, this.hosts[server][quietee], channel);
dbot.api.users.resolveUser(server, dbot.config.name, function(user) { dbot.api.users.resolveUser(server, dbot.config.name, function(user) {
dbot.api.report.notify('unquiet', server, user, channel, dbot.api.report.notify('unquiet', server, user, channel,
@ -30,6 +31,7 @@ var commands = function(dbot) {
'quietee': quietee 'quietee': quietee
})); }));
}); });
}
}.bind(this)); }.bind(this));
event.reply(dbot.t('tquieted', { event.reply(dbot.t('tquieted', {
'quietee': quietee, 'quietee': quietee,
@ -53,27 +55,28 @@ var commands = function(dbot) {
})); }));
} }
this.api.quiet(server, quietee, channel); this.api.quiet(server, host, channel);
} else {
event.reply(dbot.t('no_user', { 'user': quietee }));
}
}.bind(this));
}, },
'~unquiet': function(event) { '~unquiet': function(event) {
var server = event.server, var server = event.server,
quieter = event.user, quieter = event.user,
channel = event.input[1], channel = (event.input[1] || event.channel.name).trim(),
quietee = event.input[2].trim(); quietee = event.input[2].trim();
if(_.isUndefined(channel)) { if(_.has(this.hosts[server], quietee)) {
channel = event.channel.name; this.api.unquiet(server, this.hosts[server][quietee], channel);
}
channel = channel.trim();
this.api.unquiet(server, quietee, channel);
event.reply(dbot.t('unquieted', { 'quietee': quietee })); event.reply(dbot.t('unquieted', { 'quietee': quietee }));
dbot.api.report.notify('unquiet', server, event.rUser, channel, dbot.api.report.notify('unquiet', server, event.rUser, channel,
dbot.t('unquiet_notify', { dbot.t('unquiet_notify', {
'unquieter': quieter, 'unquieter': quieter,
'quietee': quietee 'quietee': quietee
})); }));
}
}, },
'~ckick': function(event) { '~ckick': function(event) {

View File

@ -5,18 +5,21 @@ var kick = function(dbot) {
if(!_.has(dbot.db, 'tempBans')) dbot.db.tempBans = {}; if(!_.has(dbot.db, 'tempBans')) dbot.db.tempBans = {};
this.hosts = dbot.db.hosts; this.hosts = dbot.db.hosts;
this.tempBans = dbot.db.tempBans; this.tempBans = dbot.db.tempBans;
_.each(dbot.config.servers, function(v, k) {
this.hosts[k] = {};
}, this);
this.api = { this.api = {
'ban': function(server, host, channel) { 'ban': function(server, host, channel) {
dbot.instance.connections[server].send('MODE ' + channel + ' +b *!*@' + host); dbot.instance.connections[server].send('MODE ' + channel + ' +b *!*@' + host);
}, },
'quiet': function(server, user, channel) { 'quiet': function(server, host, channel) {
dbot.say(server, this.config.chanserv, 'quiet ' + channel + ' ' + user); dbot.instance.connections[server].send('MODE ' + channel + ' +q *!*@' + host);
}, },
'unquiet': function(server, user, channel) { 'unquiet': function(server, host, channel) {
dbot.say(server, this.config.chanserv, 'unquiet ' + channel + ' ' + user); dbot.instance.connections[server].send('MODE ' + channel + ' -q *!*@' + host);
}, },
'kick': function(server, user, channel, msg) { 'kick': function(server, user, channel, msg) {
@ -24,6 +27,7 @@ var kick = function(dbot) {
}, },
'unban': function(server, host, channel) { 'unban': function(server, host, channel) {
// TODO: Wrest control from chanserv
dbot.say(server, this.config.chanserv, 'unban ' + channel + ' *!*@' + host); dbot.say(server, this.config.chanserv, 'unban ' + channel + ' *!*@' + host);
}, },