3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 12:29:26 +01:00

4-indent to 2-indent

This commit is contained in:
Scritches 2018-05-05 13:35:49 -04:00
parent a5f9998872
commit ed69582c7a
3 changed files with 747 additions and 696 deletions

View File

@ -39,7 +39,8 @@ var commands = function(dbot) {
if (this.recentTimeouts[user.id] == 0) { if (this.recentTimeouts[user.id] == 0) {
delete this.recentTimeouts[user.id]; delete this.recentTimeouts[user.id];
} }
}.bind(this), 3600000); }
.bind(this), 3600000);
if (this.recentTimeouts[user.id] == 3) { if (this.recentTimeouts[user.id] == 3) {
duration = null; duration = null;
@ -51,7 +52,8 @@ var commands = function(dbot) {
event.reply(response); event.reply(response);
}); });
} }
}.bind(this)); }
.bind(this));
}, },
'~unquiet': function (event) { '~unquiet': function (event) {
@ -66,7 +68,9 @@ var commands = function(dbot) {
} else { } else {
this.api.unquiet(server, this.hosts[server][quietee], channel); this.api.unquiet(server, this.hosts[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,
@ -98,7 +102,8 @@ var commands = function(dbot) {
// Kick and ban from all channels on the network. // Kick and ban from all channels on the network.
'~nban': function (event) { '~nban': function (event) {
if(!event.input) return; if (!event.input)
return;
var server = event.server, var server = event.server,
banner = event.user, banner = event.user,
@ -138,13 +143,16 @@ var commands = function(dbot) {
// Ban the user from all channels // Ban the user from all channels
var i = 0; var i = 0;
var banChannel = function (channels) { var banChannel = function (channels) {
if(i >= channels.length) return; if (i >= channels.length)
return;
var channel = channels[i]; var channel = channels[i];
this.api.ban(server, host, channel); this.api.ban(server, host, channel);
this.api.kick(server, banee, channel, reason + this.api.kick(server, banee, channel, reason +
' (network-wide ban)'); ' (network-wide ban)');
i++; banChannel(channels); i++;
}.bind(this); banChannel(channels);
}
.bind(this);
banChannel(channels); banChannel(channels);
this.hosts[event.server][banee] = host; this.hosts[event.server][banee] = host;
@ -164,7 +172,8 @@ var commands = function(dbot) {
timeout += ' hours'; timeout += ' hours';
} }
if(!_.has(this.tempBans, event.server)) this.tempBans[event.server] = {}; if (!_.has(this.tempBans, event.server))
this.tempBans[event.server] = {};
this.tempBans[event.server][banee] = msTimeout; this.tempBans[event.server][banee] = msTimeout;
this.internalAPI.addTempBan(event.server, banee, msTimeout); this.internalAPI.addTempBan(event.server, banee, msTimeout);
@ -232,9 +241,12 @@ var commands = function(dbot) {
// err // err
dbot.say(event.server, 'NickServ', 'FREEZE ' + banee + ' ON ' + reason); dbot.say(event.server, 'NickServ', 'FREEZE ' + banee + ' ON ' + reason);
} else { } else {
event.reply(dbot.t('no_user', { 'user': banee })); event.reply(dbot.t('no_user', {
'user': banee
}));
} }
}.bind(this)); }
.bind(this));
}, },
'~nunban': function (event) { '~nunban': function (event) {
@ -244,7 +256,9 @@ var commands = function(dbot) {
this.api.networkUnban(event.server, unbanee, unbanner, host, function (err) { this.api.networkUnban(event.server, unbanee, unbanner, host, function (err) {
if (err) { if (err) {
event.reply(dbot.t('nunban_error', { 'unbanee': unbanee })); event.reply(dbot.t('nunban_error', {
'unbanee': unbanee
}));
} }
}); });
}, },
@ -281,7 +295,9 @@ var commands = function(dbot) {
var orderedKickLeague = function (list, topWhat) { var orderedKickLeague = function (list, topWhat) {
var kickArr = _.chain(list) var kickArr = _.chain(list)
.pairs() .pairs()
.sortBy(function(kick) { return kick[1] }) .sortBy(function (kick) {
return kick[1]
})
.reverse() .reverse()
.first(10) .first(10)
.value(); .value();
@ -310,7 +326,13 @@ var commands = function(dbot) {
} }
if (!_.has(this.voteQuiets, user.id)) { if (!_.has(this.voteQuiets, user.id)) {
this.voteQuiets[user.id] = { 'user': user.id, 'reason': reason, 'channel': event.channel, 'yes': [event.rUser.primaryNick], 'no': [] }; this.voteQuiets[user.id] = {
'user': user.id,
'reason': reason,
'channel': event.channel,
'yes': [event.rUser.primaryNick],
'no': []
};
event.reply(event.user + ' has started a vote to quiet ' + target + ' for "' + reason + '." Type either "~voteyes ' + target + '" or "~voteno ' + target + '" in the next 90 seconds.'); event.reply(event.user + ' has started a vote to quiet ' + target + ' for "' + reason + '." Type either "~voteyes ' + target + '" or "~voteno ' + target + '" in the next 90 seconds.');
this.voteQuiets[user.id].timer = setTimeout(function () { this.voteQuiets[user.id].timer = setTimeout(function () {
@ -337,8 +359,10 @@ var commands = function(dbot) {
setTimeout(function () { setTimeout(function () {
delete this.voteQuiets[user.id]; delete this.voteQuiets[user.id];
}.bind(this), 600000); }
}.bind(this), 90000); .bind(this), 600000);
}
.bind(this), 90000);
} else { } else {
if (this.voteQuiets[user.id].spent) { if (this.voteQuiets[user.id].spent) {
event.reply('A votequiet attempt has already been made on this user in the last 10 minutes.'); event.reply('A votequiet attempt has already been made on this user in the last 10 minutes.');
@ -357,7 +381,8 @@ var commands = function(dbot) {
vq.spent = true; vq.spent = true;
setTimeout(function () { setTimeout(function () {
delete this.voteQuiets[user.id]; delete this.voteQuiets[user.id];
}.bind(this), 600000); }
.bind(this), 600000);
event.reply(response); event.reply(response);
}); });
} }
@ -369,7 +394,8 @@ var commands = function(dbot) {
} else { } else {
event.reply('Target does not seem to be in the channel.'); event.reply('Target does not seem to be in the channel.');
} }
}.bind(this)); }
.bind(this));
} else { } else {
event.reply('Target does not seem to be in the channel.'); event.reply('Target does not seem to be in the channel.');
} }
@ -399,7 +425,8 @@ var commands = function(dbot) {
vq.spent = true; vq.spent = true;
setTimeout(function () { setTimeout(function () {
delete this.voteQuiets[user.id]; delete this.voteQuiets[user.id];
}.bind(this), 600000); }
.bind(this), 600000);
event.reply(response); event.reply(response);
}); });
} }
@ -412,7 +439,8 @@ var commands = function(dbot) {
} else { } else {
event.reply('No idea who that is m8'); event.reply('No idea who that is m8');
} }
}.bind(this)); }
.bind(this));
}, },
'~voteno': function (event) { '~voteno': function (event) {
@ -440,7 +468,8 @@ var commands = function(dbot) {
} else { } else {
event.reply('No idea who that is m8'); event.reply('No idea who that is m8');
} }
}.bind(this)); }
.bind(this));
} }
}; };

View File

@ -78,7 +78,8 @@ var kick = function(dbot) {
}), false, quietee); }), false, quietee);
}); });
} }
}.bind(this)); }
.bind(this));
callback(dbot.t('tquieted', { callback(dbot.t('tquieted', {
'quietee': quietee, 'quietee': quietee,
'minutes': duration 'minutes': duration
@ -89,10 +90,11 @@ var kick = function(dbot) {
'quieter': quieter.primaryNick, 'quieter': quieter.primaryNick,
'quietee': quietee, 'quietee': quietee,
'reason': reason 'reason': reason
}), false, quietee }), false, quietee);
);
} else { } else {
callback(dbot.t('quieted', { 'quietee': quietee })); callback(dbot.t('quieted', {
'quietee': quietee
}));
dbot.api.report.notify('quiet', server, quieter.primaryNick, channel, dbot.api.report.notify('quiet', server, quieter.primaryNick, channel,
dbot.t('quiet_notify', { dbot.t('quiet_notify', {
'quieter': quieter.primaryNick, 'quieter': quieter.primaryNick,
@ -115,9 +117,12 @@ var kick = function(dbot) {
function () {}); function () {});
} }
} else { } else {
event.reply(dbot.t('no_user', { 'user': quietee })); event.reply(dbot.t('no_user', {
'user': quietee
}));
} }
}.bind(this)); }
.bind(this));
}, },
'networkUnban': function (server, unbanee, unbanner, manualHost, callback) { 'networkUnban': function (server, unbanee, unbanner, manualHost, callback) {
@ -156,13 +161,16 @@ var kick = function(dbot) {
// Unban // Unban
var i = 0; var i = 0;
var unbanChannel = function (channels) { var unbanChannel = function (channels) {
if(i >= channels.length) return; if (i >= channels.length)
return;
var channel = channels[i]; var channel = channels[i];
this.api.unban(server, host, channel); this.api.unban(server, host, channel);
setTimeout(function () { setTimeout(function () {
i++; unbanChannel(channels); i++;
unbanChannel(channels);
}, 1000); }, 1000);
}.bind(this); }
.bind(this);
unbanChannel(channels); unbanChannel(channels);
dbot.say(server, 'NickServ', 'FREEZE ' + unbanee + ' OFF'); dbot.say(server, 'NickServ', 'FREEZE ' + unbanee + ' OFF');
@ -171,13 +179,15 @@ var kick = function(dbot) {
// Attempt to look up the host on-the-fly // Attempt to look up the host on-the-fly
dbot.api.nickserv.getUserHost(server, unbanee, unbanner, function (host) { dbot.api.nickserv.getUserHost(server, unbanee, unbanner, function (host) {
if (host) { if (host) {
if(!_.has(this.hosts, server)) this.hosts[server] = {}; if (!_.has(this.hosts, server))
this.hosts[server] = {};
this.hosts[server][unbanee] = host; this.hosts[server][unbanee] = host;
this.api.networkUnban(server, unbanee, unbanner); this.api.networkUnban(server, unbanee, unbanner);
} else { } else {
callback(true); // No host could be found callback(true); // No host could be found
} }
}.bind(this)); }
.bind(this));
} }
} }
}; };
@ -188,15 +198,20 @@ var kick = function(dbot) {
dbot.api.timers.addTimeout(timeout, function () { dbot.api.timers.addTimeout(timeout, function () {
this.api.networkUnban(server, banee, bot, undefined, function (err) {}); this.api.networkUnban(server, banee, bot, undefined, function (err) {});
delete this.tempBans[server][banee]; delete this.tempBans[server][banee];
}.bind(this)); }
}.bind(this)); .bind(this));
}.bind(this) }
.bind(this));
}
.bind(this)
}; };
this.listener = function (event) { this.listener = function (event) {
if (event.kickee == dbot.config.name) { if (event.kickee == dbot.config.name) {
dbot.instance.join(event, event.channel.name); dbot.instance.join(event, event.channel.name);
event.reply(dbot.t('kicked_dbot', { 'botname': dbot.config.name })); event.reply(dbot.t('kicked_dbot', {
'botname': dbot.config.name
}));
dbot.db.kicks[dbot.config.name] += 1; dbot.db.kicks[dbot.config.name] += 1;
} else { } else {
if (!_.has(dbot.db.kicks, event.kickee)) { if (!_.has(dbot.db.kicks, event.kickee)) {
@ -219,7 +234,8 @@ var kick = function(dbot) {
}) + ')'); }) + ')');
} }
} }
}.bind(this); }
.bind(this);
this.on = 'KICK'; this.on = 'KICK';
this.onLoad = function () { this.onLoad = function () {
@ -229,7 +245,8 @@ var kick = function(dbot) {
dbot.db.hosts[k] = {}; dbot.db.hosts[k] = {};
}, this); }, this);
} }
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;
this.voteQuiets = {}; this.voteQuiets = {};
@ -244,7 +261,8 @@ var kick = function(dbot) {
if (_.has(dbot.modules, 'web')) { if (_.has(dbot.modules, 'web')) {
dbot.api.web.addIndexLink('/bans', 'Ban List'); dbot.api.web.addIndexLink('/bans', 'Ban List');
} }
}.bind(this); }
.bind(this);
}; };
exports.fetch = function (dbot) { exports.fetch = function (dbot) {

View File

@ -9,7 +9,9 @@ var pages = function(dbot) {
}, },
'/underbans': function (req, res) { '/underbans': function (req, res) {
this.db.search('nbans', { 'server': server }, function(ban) { this.db.search('nbans', {
'server': server
}, function (ban) {
if (ban.reason.match('#underban')) { if (ban.reason.match('#underban')) {
bans.push(ban); bans.push(ban);
} }
@ -25,7 +27,9 @@ var pages = function(dbot) {
var server = req.params.server, var server = req.params.server,
bans = []; bans = [];
this.db.search('nbans', { 'server': server }, function(ban) { this.db.search('nbans', {
'server': server
}, function (ban) {
bans.push(ban); bans.push(ban);
}, function () { }, function () {
res.render('bans', { res.render('bans', {