mirror of
https://github.com/reality/dbot.git
synced 2024-12-12 13:59:26 +01:00
timeout
This commit is contained in:
parent
71632f401b
commit
72e6fca9e5
@ -17,6 +17,43 @@ var commands = function(dbot) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'~timeout': function(event) {
|
||||||
|
var server = event.server,
|
||||||
|
quieter = event.rUser,
|
||||||
|
duration = this.config.timeoutTime,
|
||||||
|
channel = event.channel.name,
|
||||||
|
quietee = event.input[1],
|
||||||
|
reason = event.input[2] || "N/A";
|
||||||
|
|
||||||
|
reason += ' #timeout';
|
||||||
|
|
||||||
|
dbot.api.users.resolveUser(server, quietee, function(err, user) {
|
||||||
|
if(!err && user) {
|
||||||
|
if(!_.has(this.recentTimeouts, user.id)) {
|
||||||
|
this.recentTimeouts[user.id] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.recentTimeouts[user.id] += 1;
|
||||||
|
setTimeout(function() {
|
||||||
|
this.recentTimeouts[user.id] -= 1;
|
||||||
|
if(this.recentTimeouts[user.id] == 0) {
|
||||||
|
delete this.recentTimeouts[user.id];
|
||||||
|
}
|
||||||
|
}.bind(this), 300000);
|
||||||
|
|
||||||
|
if(this.recentTimeouts[user.id] == 3) {
|
||||||
|
duration = null;
|
||||||
|
reason += ' #permatimeout';
|
||||||
|
dbot.say(event.server, dbot.config.servers[event.server].admin_channel, quietee + ' has been given three timeouts in the last hour, and so has been quieted indefinitely. Please review.');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.api.quietUser(server, quieter, duration, channel, quietee, reason, function(response) {
|
||||||
|
event.reply(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
'~unquiet': function(event) {
|
'~unquiet': function(event) {
|
||||||
var server = event.server,
|
var server = event.server,
|
||||||
quieter = event.user,
|
quieter = event.user,
|
||||||
@ -381,6 +418,7 @@ var commands = function(dbot) {
|
|||||||
commands['~voteyes'].access = 'regular';
|
commands['~voteyes'].access = 'regular';
|
||||||
commands['~voteno'].access = 'regular';
|
commands['~voteno'].access = 'regular';
|
||||||
commands['~quiet'].access = 'voice';
|
commands['~quiet'].access = 'voice';
|
||||||
|
commands['~timeout'].access = 'voice';
|
||||||
commands['~unquiet'].access = 'voice';
|
commands['~unquiet'].access = 'voice';
|
||||||
commands['~nban'].access = 'power_user';
|
commands['~nban'].access = 'power_user';
|
||||||
commands['~nunban'].access = 'power_user';
|
commands['~nunban'].access = 'power_user';
|
||||||
@ -388,6 +426,7 @@ var commands = function(dbot) {
|
|||||||
commands['~ckick'].regex = /^ckick (#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
commands['~ckick'].regex = /^ckick (#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
||||||
commands['~nban'].regex = /^nban (\d[\d\.dhms]+)? ?([^ ]+) (.+)$/;
|
commands['~nban'].regex = /^nban (\d[\d\.dhms]+)? ?([^ ]+) (.+)$/;
|
||||||
commands['~quiet'].regex = /^quiet (\d[\d\.hms]+)? ?(#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
commands['~quiet'].regex = /^quiet (\d[\d\.hms]+)? ?(#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
||||||
|
commands['~timeout'].regex = /^timeout ([^ ]+) ?(.*)?$/;
|
||||||
commands['~unquiet'].regex = /^unquiet (#[^ ]+ )?([^ ]+) ?$/;
|
commands['~unquiet'].regex = /^unquiet (#[^ ]+ )?([^ ]+) ?$/;
|
||||||
commands['~votequiet'].regex = [/^votequiet ([^ ]+) (.+)$/, 3];
|
commands['~votequiet'].regex = [/^votequiet ([^ ]+) (.+)$/, 3];
|
||||||
|
|
||||||
|
@ -13,5 +13,6 @@
|
|||||||
"document_bans": false,
|
"document_bans": false,
|
||||||
"dbType": "redis",
|
"dbType": "redis",
|
||||||
"requireWebLogin": true,
|
"requireWebLogin": true,
|
||||||
"webAccess": "power_user"
|
"webAccess": "power_user",
|
||||||
|
"timeoutTime": "10m"
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
var _ = require('underscore')._;
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
var kick = function(dbot) {
|
var kick = function(dbot) {
|
||||||
|
if(!_.has(dbot.db, 'recentTimeouts')) {
|
||||||
|
dbot.db.recentTimeouts = {};
|
||||||
|
}
|
||||||
|
this.recentTimeouts = dbot.db.recentTimeouts;
|
||||||
|
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user