3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 22:39:26 +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,
quieter = event.user,
minutes = event.input[1],
channel = event.input[2],
channel = (event.input[2] || event.channel.name).trim(),
quietee = event.input[3].trim(),
reason = event.input[4] || "N/A";
if(_.isUndefined(channel)) {
channel = event.channel.name;
}
channel = channel.trim();
dbot.api.nickserv.getUserHost(server, quietee, function(host) {
// Add host record entry
if(host) {
this.hosts[server][quietee] = host;
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);
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.report.notify('unquiet', server, user, channel,
@ -30,6 +31,7 @@ var commands = function(dbot) {
'quietee': quietee
}));
});
}
}.bind(this));
event.reply(dbot.t('tquieted', {
'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) {
var server = event.server,
quieter = event.user,
channel = event.input[1],
channel = (event.input[1] || event.channel.name).trim(),
quietee = event.input[2].trim();
if(_.isUndefined(channel)) {
channel = event.channel.name;
}
channel = channel.trim();
this.api.unquiet(server, quietee, channel);
if(_.has(this.hosts[server], quietee)) {
this.api.unquiet(server, this.hosts[server][quietee], channel);
event.reply(dbot.t('unquieted', { 'quietee': quietee }));
dbot.api.report.notify('unquiet', server, event.rUser, channel,
dbot.t('unquiet_notify', {
'unquieter': quieter,
'quietee': quietee
}));
}
},
'~ckick': function(event) {

View File

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