From f8768a7740249d82047e31e6900fc7ac7338aeaf Mon Sep 17 00:00:00 2001 From: reality Date: Wed, 5 Jun 2013 22:26:10 +0000 Subject: [PATCH 01/34] ~commands command [Close #491] --- modules/command/commands.js | 18 ++++++++++++++++++ modules/command/strings.json | 3 +++ 2 files changed, 21 insertions(+) diff --git a/modules/command/commands.js b/modules/command/commands.js index 5f5e079..5bf355b 100644 --- a/modules/command/commands.js +++ b/modules/command/commands.js @@ -17,6 +17,24 @@ var commands = function(dbot) { } }, + '~commands': function(event) { + var name = event.params[1]; + if(_.has(dbot.modules, name)) { + var commands = _.keys(dbot.commands); + commands = _.filter(commands, function(cName) { + return dbot.commands[cName].module == name; + }); + event.reply(dbot.t('module_commands', { + 'module': name, + 'commands': commands.join(', ') + })); + } else { + event.reply(dbot.t('loaded_modules', { + 'modules': _.keys(dbot.modules).join(', ') + })); + } + }, + '~help': function(event) { var moduleName = event.params[1]; if(!moduleName || !_.has(dbot.modules, moduleName)) { diff --git a/modules/command/strings.json b/modules/command/strings.json index 3f531b1..3e6d5a0 100644 --- a/modules/command/strings.json +++ b/modules/command/strings.json @@ -48,5 +48,8 @@ "cy": "Modiwlau sy'n lwythodd: {modules}.", "nl": "Geladen modules: {modules}.", "de": "Module geladen: {modules}." + }, + "module_commands": { + "en": "Commands in {module}: {commands}." } } From f3a5c00be866ebecfc9b74956b2ba796f57bb0c0 Mon Sep 17 00:00:00 2001 From: reality Date: Wed, 5 Jun 2013 22:48:15 +0000 Subject: [PATCH 02/34] update version of github w/ milestone fixed and that --- modules/github | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/github b/modules/github index ee6e9ba..5f4e3dc 160000 --- a/modules/github +++ b/modules/github @@ -1 +1 @@ -Subproject commit ee6e9ba9279e993567ebecb961184245a2a07ecf +Subproject commit 5f4e3dc8335000e97af528fee289b880a3c99e81 From cd4b9460b14d1816dc4b260f90078e46d0a1b8ac Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 6 Jun 2013 17:27:56 +0000 Subject: [PATCH 03/34] String translation exceptions in project --- modules/project/config.json | 12 +++++++++++- modules/project/project.js | 5 ++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/project/config.json b/modules/project/config.json index 0725dea..78aa0e3 100644 --- a/modules/project/config.json +++ b/modules/project/config.json @@ -1,3 +1,13 @@ { - "dependencies": ["web", "quotes", "github"] + "dependencies": ["web", "quotes", "github"], + "string_exceptions": [ + "rdns", + "imgurinfo", + "xkcd", + "link", + "log_message", + "poll_describe", + "branch", + "oaosidl" + ] } diff --git a/modules/project/project.js b/modules/project/project.js index 5bb291e..417e98d 100644 --- a/modules/project/project.js +++ b/modules/project/project.js @@ -44,7 +44,10 @@ var project = function(dbot) { }, 'translationProgress' : function(callback){ var translation = [] ; - var str = _.values(dbot.strings); + var str = _.filter(dbot.strings, function(strings, key) { + return _.include(this.config.string_exceptions, key) != true; + }, this); + str = _.values(str); for (var i = 0; i < str.length; i++){ var cur = _.keys(str[i]); for (var j = 0; j < cur.length; j++) { From 0421316002ffa145ce2532886e04a424611abffc Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 8 Jun 2013 18:34:29 +0000 Subject: [PATCH 04/34] ~nban no longer bans from network admin channel, posts notification in network admin chan --- modules/kick/commands.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 29df25f..63adc6d 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -45,21 +45,9 @@ var commands = function(dbot) { banner = event.user, banee = event.input[1], reason = event.input[2], + adminChannel = this.config.admin_channels[event.server]; channels = dbot.config.servers[server].channels; - var i = 0; - var banChannel = function(channels) { - if(i >= channels.length) return; - var channel = channels[i]; - this.api.ban(server, banee, channel); - this.api.kick(server, banee, channel, reason + - ' (network-wide ban requested by ' + banner + ')'); - setTimeout(function() { - i++; banChannel(channels); - }, 1000); - }.bind(this); - banChannel(channels); - var notifyString = dbot.t('nbanned', { 'banner': banner, 'banee': banee, @@ -79,11 +67,27 @@ var commands = function(dbot) { notifyString += ' ' + dbot.t('quote_recorded', { 'user': banee }); } - var notifyChannel = event.channel.name; + // Notify moderators, banee if(this.config.admin_channels[event.server]) { notifyChannel = this.config.admin_channels[event.server]; + channels = _.without(channels, notifyChannel); + dbot.api.report.notify(server, adminChannel, notifyString); + dbot.say(event.server, adminChannel, notifyString); } - dbot.api.report.notify(server, notifyChannel, notifyString); + + // Ban the user from all channels + var i = 0; + var banChannel = function(channels) { + if(i >= channels.length) return; + var channel = channels[i]; + this.api.ban(server, banee, channel); + this.api.kick(server, banee, channel, reason + + ' (network-wide ban requested by ' + banner + ')'); + setTimeout(function() { + i++; banChannel(channels); + }, 1000); + }.bind(this); + banChannel(channels); }, /*** Kick Stats ***/ From cab231b6478a7095097388ba09b1d841f9c8bfc3 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 8 Jun 2013 18:59:37 +0000 Subject: [PATCH 05/34] inform banee that they got banned in pm [Close #493] --- modules/kick/commands.js | 18 ++++++++++++++---- modules/kick/config.json | 5 ++++- modules/kick/strings.json | 3 +++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 63adc6d..9879319 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -45,7 +45,7 @@ var commands = function(dbot) { banner = event.user, banee = event.input[1], reason = event.input[2], - adminChannel = this.config.admin_channels[event.server]; + adminChannel = this.config.admin_channel[event.server]; channels = dbot.config.servers[server].channels; var notifyString = dbot.t('nbanned', { @@ -68,11 +68,21 @@ var commands = function(dbot) { } // Notify moderators, banee - if(this.config.admin_channels[event.server]) { - notifyChannel = this.config.admin_channels[event.server]; - channels = _.without(channels, notifyChannel); + if(adminChannel) { + channels = _.without(channels, adminChannel); + dbot.api.report.notify(server, adminChannel, notifyString); dbot.say(event.server, adminChannel, notifyString); + + var network = this.config.network_name[event.server]; + if(!network) network = event.server; + + dbot.say(event.server, banee, dbot.t('nbanned_notify', { + 'network': network, + 'banner': banner, + 'reason': reason, + 'admin_channel': adminChannel + })); } // Ban the user from all channels diff --git a/modules/kick/config.json b/modules/kick/config.json index bf4cd1d..be5bdda 100644 --- a/modules/kick/config.json +++ b/modules/kick/config.json @@ -4,9 +4,12 @@ "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md", "ignorable": true, "countSilently": true, - "admin_channels": { + "admin_channel": { "aberwiki": "#fishbox" }, + "network_name": { + "aberwiki": "OAOSIDL" + }, "chanserv": "ChanServ", "document_bans": false } diff --git a/modules/kick/strings.json b/modules/kick/strings.json index 4d0081f..e73514b 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -30,6 +30,9 @@ "cy": "Sylw: {banner} wedi gwahardd {banee} ledled y rhwydwaith. Y rheswm a roddwyd oedd: \"{reason}.\"", "de": "Achtung: {banner} hat {banee} auf dem gesamten Netzwerk gebannt. Grund: \"{reason}.\"" }, + "nbanned_notify": { + "en": "You have been banned from the {network} network by {banner}. The reason given was \"{reason}.\" You can join {admin_channel} for more information or to discuss the ban." + }, "nban_quote": { "en": "{banee} was banned from the network by {banner} on {time}. The reason given was \"{reason}.\"", "cy": "Cafodd {banee} ei wahardd o'r rhwydwaith gan {banner} ar {time}. Y rheswm a roddwyd oedd: \"{reason}.\"", From aefc605ecb2fe3ed5b9c954de9f4914d2d39ae8d Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 8 Jun 2013 19:06:57 +0000 Subject: [PATCH 06/34] correct config truth tests --- modules/kick/commands.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 9879319..0adf976 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -68,14 +68,16 @@ var commands = function(dbot) { } // Notify moderators, banee - if(adminChannel) { + if(this.config.admin_channel[event.server]) { channels = _.without(channels, adminChannel); dbot.api.report.notify(server, adminChannel, notifyString); dbot.say(event.server, adminChannel, notifyString); - var network = this.config.network_name[event.server]; - if(!network) network = event.server; + var network = event.server; + if(this.config.network_name[event.server]) { + network = this.config.network_name[event.server]; + } dbot.say(event.server, banee, dbot.t('nbanned_notify', { 'network': network, From ecfa6552a9168fd1baf0a724d554cb4c1287503e Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 12:40:13 +0000 Subject: [PATCH 07/34] lowercase banee name in quote cat --- modules/kick/commands.js | 2 +- modules/web/config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 0adf976..c60133c 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -57,7 +57,7 @@ var commands = function(dbot) { // TODO: When this is merged into database branch, have it use the // api.quotes.addQuote function if(this.config.document_bans && _.has(dbot.modules, 'quotes')) { - dbot.db.quoteArrs['ban_' + banee] = [ dbot.t('nban_quote', { + dbot.db.quoteArrs['ban_' + banee.toLowerCase()] = [ dbot.t('nban_quote', { 'banee': banee, 'banner': banner, 'time': new Date().toUTCString(), diff --git a/modules/web/config.json b/modules/web/config.json index e6b635e..72798aa 100644 --- a/modules/web/config.json +++ b/modules/web/config.json @@ -1,6 +1,6 @@ { "webHost": "nourishedcloud.com", - "webPort": 8080, + "webPort": 9002, "externalPath": false, "help": "https://github.com/reality/depressionbot/blob/master/modules/web/README.md" } From 32b89794cbd55a3f6a0fcc65801d57189e7abbb4 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 12:42:00 +0000 Subject: [PATCH 08/34] reset web AGAIN --- modules/web/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/web/config.json b/modules/web/config.json index 72798aa..e6b635e 100644 --- a/modules/web/config.json +++ b/modules/web/config.json @@ -1,6 +1,6 @@ { "webHost": "nourishedcloud.com", - "webPort": 9002, + "webPort": 8080, "externalPath": false, "help": "https://github.com/reality/depressionbot/blob/master/modules/web/README.md" } From 8a7333cef3088272b07616d2367531e75c1c592a Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 15:25:06 +0000 Subject: [PATCH 09/34] addTimeout for timers module [#494] --- modules/timers/timers.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/timers/timers.js b/modules/timers/timers.js index b1e968d..2acb505 100644 --- a/modules/timers/timers.js +++ b/modules/timers/timers.js @@ -34,6 +34,18 @@ var timers = function(dbot) { } }.bind(this), timeout)); } + }, + + 'addTimeout': function(date, callback, params) { + var now = new Date().getTime() + timeout = date.getTime() - now; + this.runningTimeouts.push(setTimeout(function() { + try { + callback.apply(callback, params); + } catch(err) { + console.log('Callback failed: ' + err); + } + }, timeout)); } }; From 9dc9ebfd2e23e66489327b5c9811a2c1175afd51 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 15:25:31 +0000 Subject: [PATCH 10/34] syntax fix in timers --- modules/timers/timers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/timers/timers.js b/modules/timers/timers.js index 2acb505..a3fc80f 100644 --- a/modules/timers/timers.js +++ b/modules/timers/timers.js @@ -37,7 +37,7 @@ var timers = function(dbot) { }, 'addTimeout': function(date, callback, params) { - var now = new Date().getTime() + var now = new Date().getTime(), timeout = date.getTime() - now; this.runningTimeouts.push(setTimeout(function() { try { From 3e2f96fb1107500a882fb51046be92a207b1c77a Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 16:05:19 +0000 Subject: [PATCH 11/34] initial 302 USERHOST support in nickserv api [#498] --- modules/nickserv/nickserv.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index e489878..5b6ca5a 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -1,5 +1,6 @@ var nickserv = function(dbot) { this.authStack = {}; + this.userStack = {}; this.api = { 'auth': function(server, nick, callback) { @@ -8,26 +9,34 @@ var nickserv = function(dbot) { if(!_.has(this.authStack, server)) this.authStack[server] = {}; this.authStack[server][nick] = callback; - dbot.say(server, nickserv, infoCommand + ' ' + nick); + }, + + 'getUserHost': function(server, nick, callback) { + if(!_.has(this.userStack, server)) this.userStack[server] = {}; + this.userStack[server][nick] = callback; + dbot.instance.connections.send('USERHOST ' + nick); } }; this.listener = function(event) { - var nickserv = dbot.config.servers[event.server].nickserv, - statusRegex = this.config.servers[event.server].matcher, - acceptableState = this.config.servers[event.server].acceptableState; + if(event.action == 'NOTICE') { + var nickserv = dbot.config.servers[event.server].nickserv, + statusRegex = this.config.servers[event.server].matcher, + acceptableState = this.config.servers[event.server].acceptableState; - - if(event.user == nickserv) { - var info = event.params.match(statusRegex); - if(info && _.has(this.authStack, event.server)) { - if(info[2] == acceptableState ) { - this.authStack[event.server][info[1]](true); - } else { - this.authStack[event.server][info[1]](false); + if(event.user == nickserv) { + var info = event.params.match(statusRegex); + if(info && _.has(this.authStack, event.server)) { + if(info[2] == acceptableState ) { + this.authStack[event.server][info[1]](true); + } else { + this.authStack[event.server][info[1]](false); + } } } + } else if(event.action == '302') { + console.log(event.params); } }.bind(this); this.on = 'NOTICE'; From 58786672fdf27ac2b382194c00f5b4b0cf087544 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 16:06:58 +0000 Subject: [PATCH 12/34] missing server clause in send --- modules/nickserv/nickserv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 5b6ca5a..4c508bd 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -15,7 +15,7 @@ var nickserv = function(dbot) { 'getUserHost': function(server, nick, callback) { if(!_.has(this.userStack, server)) this.userStack[server] = {}; this.userStack[server][nick] = callback; - dbot.instance.connections.send('USERHOST ' + nick); + dbot.instance.connections[server].send('USERHOST ' + nick); } }; From 32c5fe8bf1233d1a70f175f0cbe226842de89d0b Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 16:08:52 +0000 Subject: [PATCH 13/34] catchmsg --- modules/nickserv/nickserv.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 4c508bd..82af3f9 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -36,6 +36,7 @@ var nickserv = function(dbot) { } } } else if(event.action == '302') { + console.log('caught'); console.log(event.params); } }.bind(this); From 995a5125bc76f4e1b8ac19cd92838b86e9eaa33f Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 16:10:57 +0000 Subject: [PATCH 14/34] adding it to listener.on would have been a good idea you retard --- modules/nickserv/nickserv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 82af3f9..e501b32 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -40,7 +40,7 @@ var nickserv = function(dbot) { console.log(event.params); } }.bind(this); - this.on = 'NOTICE'; + this.on = ['NOTICE', '302']; }; exports.fetch = function(dbot) { From 47e9672b3275a3735693cfc99867e058a341c989 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 16:55:46 +0000 Subject: [PATCH 15/34] working userhost api function [Close #498] --- modules/nickserv/nickserv.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index e501b32..8e9559a 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -1,3 +1,5 @@ +var _ = require('underscore')._; + var nickserv = function(dbot) { this.authStack = {}; this.userStack = {}; @@ -36,8 +38,10 @@ var nickserv = function(dbot) { } } } else if(event.action == '302') { - console.log('caught'); - console.log(event.params); + var match = event.params.match(/:(.*)=([^@]+)@(.+)$/); + if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { + this.userStack[event.server][match[1]](match[3].trim()); + } } }.bind(this); this.on = ['NOTICE', '302']; From e22c42f560b9d201425207fc996207b2dab40f4c Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 17:27:39 +0000 Subject: [PATCH 16/34] some debug output in getUserHost --- modules/nickserv/nickserv.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 8e9559a..6306152 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -39,6 +39,8 @@ var nickserv = function(dbot) { } } else if(event.action == '302') { var match = event.params.match(/:(.*)=([^@]+)@(.+)$/); + console.log(match); + console.log(event.params); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { this.userStack[event.server][match[1]](match[3].trim()); } From ec73da976e7fac005a043bf270319d91a6c21b9c Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 17:31:21 +0000 Subject: [PATCH 17/34] remove trailing * --- modules/nickserv/nickserv.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 6306152..7c4c207 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -38,9 +38,8 @@ var nickserv = function(dbot) { } } } else if(event.action == '302') { - var match = event.params.match(/:(.*)=([^@]+)@(.+)$/); + var match = event.params.match(/:(.*)\*?=([^@]+)@(.+)$/); console.log(match); - console.log(event.params); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { this.userStack[event.server][match[1]](match[3].trim()); } From 33bde312e8980e4966c8329b84087aaeb7fd00e6 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 17:34:12 +0000 Subject: [PATCH 18/34] make the nick matcher in 302 non greedy --- modules/nickserv/nickserv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 7c4c207..81acea0 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -38,7 +38,7 @@ var nickserv = function(dbot) { } } } else if(event.action == '302') { - var match = event.params.match(/:(.*)\*?=([^@]+)@(.+)$/); + var match = event.params.match(/:(.+)\*?=([^@]+)@(.+)$/); console.log(match); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { this.userStack[event.server][match[1]](match[3].trim()); From 024b5a514c5ad7da8e875daa099afd6e03467b60 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 17:37:03 +0000 Subject: [PATCH 19/34] use brackety thing for the whatsit --- modules/nickserv/nickserv.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 81acea0..0fdc6e7 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -38,10 +38,9 @@ var nickserv = function(dbot) { } } } else if(event.action == '302') { - var match = event.params.match(/:(.+)\*?=([^@]+)@(.+)$/); - console.log(match); + var match = event.params.match(/:(.+)(\*)?=([^@]+)@(.+)$/); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { - this.userStack[event.server][match[1]](match[3].trim()); + this.userStack[event.server][match[1]](match[4].trim()); } } }.bind(this); From a395b17218a11a536d91ae340475b14aeb47a919 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 17:39:51 +0000 Subject: [PATCH 20/34] print match --- modules/nickserv/nickserv.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 0fdc6e7..f96c6c5 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -39,6 +39,7 @@ var nickserv = function(dbot) { } } else if(event.action == '302') { var match = event.params.match(/:(.+)(\*)?=([^@]+)@(.+)$/); + console.log(match); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { this.userStack[event.server][match[1]](match[4].trim()); } From 9c6b78863ef34bf9cff2b7ec0ed3e1e7d64bc796 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 17:42:41 +0000 Subject: [PATCH 21/34] fuck regex --- modules/nickserv/nickserv.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index f96c6c5..3299f36 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -38,10 +38,10 @@ var nickserv = function(dbot) { } } } else if(event.action == '302') { - var match = event.params.match(/:(.+)(\*)?=([^@]+)@(.+)$/); - console.log(match); + var match = event.params.match(/:(.+)=([^@]+)@(.+)$/); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { - this.userStack[event.server][match[1]](match[4].trim()); + match[1] = match[1].replace('\*', ''); + this.userStack[event.server][match[1]](match[3].trim()); } } }.bind(this); From 6b9cf29e955db8f0978d6bbec57ff39653b128b2 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 17:46:45 +0000 Subject: [PATCH 22/34] fuck regex --- modules/nickserv/nickserv.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 3299f36..b0e52db 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -39,6 +39,7 @@ var nickserv = function(dbot) { } } else if(event.action == '302') { var match = event.params.match(/:(.+)=([^@]+)@(.+)$/); + console.log(match); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { match[1] = match[1].replace('\*', ''); this.userStack[event.server][match[1]](match[3].trim()); From 9226da5b76cfd7fc2e0dd26559fe79a51f12535b Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 17:51:49 +0000 Subject: [PATCH 23/34] that should do it did i mention fuck regex --- modules/nickserv/nickserv.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index b0e52db..72abd24 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -39,9 +39,9 @@ var nickserv = function(dbot) { } } else if(event.action == '302') { var match = event.params.match(/:(.+)=([^@]+)@(.+)$/); - console.log(match); + + if(match[1]) match[1] = match[1].replace('\*', ''); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { - match[1] = match[1].replace('\*', ''); this.userStack[event.server][match[1]](match[3].trim()); } } From 2b7b67b89409b8318552ab8e8a0c87f45a8097fd Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 21:07:17 +0000 Subject: [PATCH 24/34] nban records a host record [#497][#495] --- modules/kick/commands.js | 97 +++++++++++++++++++++------------------- modules/kick/config.json | 2 +- modules/kick/kick.js | 1 + 3 files changed, 54 insertions(+), 46 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index c60133c..f4cc9cc 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -48,58 +48,65 @@ var commands = function(dbot) { adminChannel = this.config.admin_channel[event.server]; channels = dbot.config.servers[server].channels; - var notifyString = dbot.t('nbanned', { - 'banner': banner, - 'banee': banee, - 'reason': reason - }); + dbot.api.nickserv.getUserHost(event.server, banee, function(host) { + // Add host record entry + if(!_.has(this.hosts, event.server)) this.hosts[event.server] = {}; + this.hosts[event.server][banee] = host; - // TODO: When this is merged into database branch, have it use the - // api.quotes.addQuote function - if(this.config.document_bans && _.has(dbot.modules, 'quotes')) { - dbot.db.quoteArrs['ban_' + banee.toLowerCase()] = [ dbot.t('nban_quote', { - 'banee': banee, + // Create notify string + var notifyString = dbot.t('nbanned', { 'banner': banner, - 'time': new Date().toUTCString(), + 'banee': banee, 'reason': reason - }) ]; - - notifyString += ' ' + dbot.t('quote_recorded', { 'user': banee }); - } + }); - // Notify moderators, banee - if(this.config.admin_channel[event.server]) { - channels = _.without(channels, adminChannel); - - dbot.api.report.notify(server, adminChannel, notifyString); - dbot.say(event.server, adminChannel, notifyString); - - var network = event.server; - if(this.config.network_name[event.server]) { - network = this.config.network_name[event.server]; + // TODO: When this is merged into database branch, have it use the + // api.quotes.addQuote function + if(this.config.document_bans && _.has(dbot.modules, 'quotes')) { + dbot.db.quoteArrs['ban_' + banee.toLowerCase()] = [ dbot.t('nban_quote', { + 'banee': banee, + 'banner': banner, + 'time': new Date().toUTCString(), + 'reason': reason + }) ]; + + notifyString += ' ' + dbot.t('quote_recorded', { 'user': banee }); } - dbot.say(event.server, banee, dbot.t('nbanned_notify', { - 'network': network, - 'banner': banner, - 'reason': reason, - 'admin_channel': adminChannel - })); - } + // Notify moderators, banee + if(this.config.admin_channel[event.server]) { + channels = _.without(channels, adminChannel); - // Ban the user from all channels - var i = 0; - var banChannel = function(channels) { - if(i >= channels.length) return; - var channel = channels[i]; - this.api.ban(server, banee, channel); - this.api.kick(server, banee, channel, reason + - ' (network-wide ban requested by ' + banner + ')'); - setTimeout(function() { - i++; banChannel(channels); - }, 1000); - }.bind(this); - banChannel(channels); + dbot.api.report.notify(server, adminChannel, notifyString); + dbot.say(event.server, adminChannel, notifyString); + + var network = event.server; + if(this.config.network_name[event.server]) { + network = this.config.network_name[event.server]; + } + + dbot.say(event.server, banee, dbot.t('nbanned_notify', { + 'network': network, + 'banner': banner, + 'reason': reason, + 'admin_channel': adminChannel + })); + } + + // Ban the user from all channels + var i = 0; + var banChannel = function(channels) { + if(i >= channels.length) return; + var channel = channels[i]; + this.api.ban(server, banee, channel); + this.api.kick(server, banee, channel, reason + + ' (network-wide ban requested by ' + banner + ')'); + setTimeout(function() { + i++; banChannel(channels); + }, 1000); + }.bind(this); + banChannel(channels); + }.bind(this)); }, /*** Kick Stats ***/ diff --git a/modules/kick/config.json b/modules/kick/config.json index be5bdda..0a52e4c 100644 --- a/modules/kick/config.json +++ b/modules/kick/config.json @@ -1,5 +1,5 @@ { - "dbKeys": [ "kicks", "kickers" ], + "dbKeys": [ "kicks", "kickers", "hosts" ], "dependencies": [ "command", "report", "users" ], "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md", "ignorable": true, diff --git a/modules/kick/kick.js b/modules/kick/kick.js index 6314c07..93758d0 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -1,6 +1,7 @@ var _ = require('underscore')._; var kick = function(dbot) { + this.hosts = dbot.db.hosts; this.api = { 'ban': function(server, user, channel) { From ab520e625afbebae34c26cac717ea396a56ff7ce Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 9 Jun 2013 22:50:11 +0000 Subject: [PATCH 25/34] ~nunban command --- modules/kick/commands.js | 59 +++++++++++++++++++++++++++++++++++---- modules/kick/kick.js | 8 ++++-- modules/kick/strings.json | 11 +++++++- 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index f4cc9cc..070dbf0 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -46,7 +46,12 @@ var commands = function(dbot) { banee = event.input[1], reason = event.input[2], adminChannel = this.config.admin_channel[event.server]; - channels = dbot.config.servers[server].channels; + channels = dbot.config.servers[server].channels, + network = event.server; + + if(this.config.network_name[event.server]) { + network = this.config.network_name[event.server]; + } dbot.api.nickserv.getUserHost(event.server, banee, function(host) { // Add host record entry @@ -55,6 +60,7 @@ var commands = function(dbot) { // Create notify string var notifyString = dbot.t('nbanned', { + 'network': network, 'banner': banner, 'banee': banee, 'reason': reason @@ -80,11 +86,6 @@ var commands = function(dbot) { dbot.api.report.notify(server, adminChannel, notifyString); dbot.say(event.server, adminChannel, notifyString); - var network = event.server; - if(this.config.network_name[event.server]) { - network = this.config.network_name[event.server]; - } - dbot.say(event.server, banee, dbot.t('nbanned_notify', { 'network': network, 'banner': banner, @@ -109,6 +110,52 @@ var commands = function(dbot) { }.bind(this)); }, + '~nunban': function(event) { + var unbanee = event.params[1], + unbanner = event.user, + adminChannel = this.config.admin_channel[event.server], + channels = dbot.config.servers[event.server].channels, + network = event.server; + + if(this.config.network_name[event.server]) { + network = this.config.network_name[event.server]; + } + + if(_.has(this.hosts, event.server) && _.has(this.hosts[event.server], unbanee)) { + var host = this.hosts[event.server][unbanee]; + + var notifyString = dbot.t('nunbanned', { + 'network': network, + 'unbanee': unbanee, + 'unbanner': unbanner + }); + + if(this.config.admin_channel[event.server]) { + dbot.api.report.notify(event.server, adminChannel, notifyString); + dbot.say(event.server, adminChannel, notifyString); + } + + dbot.say(event.server, unbanee, dbot.t('nunban_notify', { + 'network': network, + 'unbanee': unbanee, + 'unbanner': unbanner + })); + + var i = 0; + var unbanChannel = function(channels) { + if(i >= channels.length) return; + var channel = channels[i]; + this.api.unban(event.server, host, channel); + setTimeout(function() { + i++; unbanChannel(channels); + }, 1000); + }.bind(this); + unbanChannel(channels); + } else { + event.reply(dbot.t('nunban_error', { 'unbanee': unbanee })); + } + }, + /*** Kick Stats ***/ // Give the number of times a given user has been kicked and has kicked diff --git a/modules/kick/kick.js b/modules/kick/kick.js index 93758d0..63f6fcb 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -5,15 +5,19 @@ var kick = function(dbot) { this.api = { 'ban': function(server, user, channel) { - dbot.say(server, this.config.chanserv, 'ban ' + channel + ' ' + user) + dbot.say(server, this.config.chanserv, 'ban ' + channel + ' ' + user); }, 'quiet': function(server, user, channel) { - dbot.say(server, this.config.chanserv, 'quiet ' + channel + ' ' + user) + dbot.say(server, this.config.chanserv, 'quiet ' + channel + ' ' + user); }, 'kick': function(server, user, channel, msg) { dbot.instance.connections[server].send('KICK ' + channel + ' ' + user + ' :' + msg); + }, + + 'unban': function(server, host, channel) { + dbot.say(server, this.config.chanserv, 'unban ' + channel + ' *!*@' + host); } }; diff --git a/modules/kick/strings.json b/modules/kick/strings.json index e73514b..42ec46a 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -26,7 +26,7 @@ "de": "Achtung: {banner} hat {banee} von {channel} gebannt. Grund: \"{reason}.\"" }, "nbanned": { - "en": "Attention: {banner} has banned {banee} network-wide. The reason given was \"{reason}.\"", + "en": "Attention: {banner} has banned {banee} from the {network} network. The reason given was \"{reason}.\"", "cy": "Sylw: {banner} wedi gwahardd {banee} ledled y rhwydwaith. Y rheswm a roddwyd oedd: \"{reason}.\"", "de": "Achtung: {banner} hat {banee} auf dem gesamten Netzwerk gebannt. Grund: \"{reason}.\"" }, @@ -38,6 +38,15 @@ "cy": "Cafodd {banee} ei wahardd o'r rhwydwaith gan {banner} ar {time}. Y rheswm a roddwyd oedd: \"{reason}.\"", "de": "{banee} wurde von {banner} auf dem gesamten Netzwerk um {time} gebannt. Grund: \"{reason}.\"" }, + "nunbanned": { + "en": "Attention: {unbanee} has been unbanned from the {network} network by {unbanner}." + }, + "nunban_notify": { + "en": "You have been unbanned from the {network} network by {unbanner}." + }, + "nunban_error": { + "en": "It appears {unbanee} was not banned using the ~nban command." + }, "quote_recorded": { "en": "This has been recorded in ~ban_{user}.", "cy": "Mae hyn wedi cael ei gofnodi yn ~ban_{user}.", From 0544bb9d1240404166fe436bd36448ae6084ed2f Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 10 Jun 2013 16:13:30 +0000 Subject: [PATCH 26/34] getUserHost callbacks false if response not received in timely manner [Close #501] --- modules/nickserv/nickserv.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 72abd24..2981d3e 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -18,6 +18,9 @@ var nickserv = function(dbot) { if(!_.has(this.userStack, server)) this.userStack[server] = {}; this.userStack[server][nick] = callback; dbot.instance.connections[server].send('USERHOST ' + nick); + setTimeout(function() { + if(_.has(this.userStack[server], nick)) callback(false); + }.bind(this), 3000); } }; @@ -43,6 +46,7 @@ var nickserv = function(dbot) { if(match[1]) match[1] = match[1].replace('\*', ''); if(match && _.has(this.userStack, event.server) && _.has(this.userStack[event.server], match[1])) { this.userStack[event.server][match[1]](match[3].trim()); + delete this.userStack[event.server][match[1]]; } } }.bind(this); From 3be45d4692cc7b85f0654caf783406c0bd8d3714 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 10 Jun 2013 16:15:28 +0000 Subject: [PATCH 27/34] nunban moved to api + efficiency [#500], attempts to look up host otf [Close #499], tempban backedn [#495] --- modules/kick/commands.js | 166 +++++++++++++++++--------------------- modules/kick/config.json | 2 +- modules/kick/kick.js | 62 ++++++++++++++ modules/kick/strings.json | 3 + 4 files changed, 140 insertions(+), 93 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 070dbf0..8646ff8 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -41,10 +41,13 @@ var commands = function(dbot) { // Kick and ban from all channels on the network. '~nban': function(event) { + if(!event.input) return; + var server = event.server, banner = event.user, - banee = event.input[1], - reason = event.input[2], + timeout = event.input[1], + banee = event.input[2], + reason = event.input[3], adminChannel = this.config.admin_channel[event.server]; channels = dbot.config.servers[server].channels, network = event.server; @@ -52,108 +55,87 @@ var commands = function(dbot) { if(this.config.network_name[event.server]) { network = this.config.network_name[event.server]; } + console.log(timeout); + console.log(banee); + console.log(reason); dbot.api.nickserv.getUserHost(event.server, banee, function(host) { // Add host record entry - if(!_.has(this.hosts, event.server)) this.hosts[event.server] = {}; - this.hosts[event.server][banee] = host; + if(host) { + if(!_.has(this.hosts, event.server)) this.hosts[event.server] = {}; + this.hosts[event.server][banee] = host; - // Create notify string - var notifyString = dbot.t('nbanned', { - 'network': network, - 'banner': banner, - 'banee': banee, - 'reason': reason - }); + // Create notify string + /*if(!_.isUndefined(timeout)) { + timeout = new Date(new Date().getTime() + (timeout * 3600000)); + if(!_.has(this.tempBans, event.server)) this.tempBans[event.server] = {}; + this.tempBans[event.server][banee] = timeout; + this.internalAPI.addTempBan(event.server, banee, timeout); + } else {*/ + var notifyString = dbot.t('nbanned', { + 'network': network, + 'banner': banner, + 'banee': banee, + 'reason': reason + }); + var quoteString = dbot.t('nban_quote', { + 'banee': banee, + 'banner': banner, + 'time': new Date().toUTCString(), + 'reason': reason + }); + //} + console.log(notifyString); - // TODO: When this is merged into database branch, have it use the - // api.quotes.addQuote function - if(this.config.document_bans && _.has(dbot.modules, 'quotes')) { - dbot.db.quoteArrs['ban_' + banee.toLowerCase()] = [ dbot.t('nban_quote', { - 'banee': banee, - 'banner': banner, - 'time': new Date().toUTCString(), - 'reason': reason - }) ]; - - notifyString += ' ' + dbot.t('quote_recorded', { 'user': banee }); + // Add qutoe category documenting ban + if(this.config.document_bans && _.has(dbot.modules, 'quotes')) { + dbot.db.quoteArrs['ban_' + banee.toLowerCase()] = [ quoteString ]; + notifyString += ' ' + dbot.t('quote_recorded', { 'user': banee }); + } + + // Notify moderators, banee + if(this.config.admin_channel[event.server]) { + channels = _.without(channels, adminChannel); + + dbot.api.report.notify(server, adminChannel, notifyString); + dbot.say(event.server, adminChannel, notifyString); + + dbot.say(event.server, banee, dbot.t('nbanned_notify', { + 'network': network, + 'banner': banner, + 'reason': reason, + 'admin_channel': adminChannel + })); + } + + // Ban the user from all channels + var i = 0; + var banChannel = function(channels) { + if(i >= channels.length) return; + var channel = channels[i]; + this.api.ban(server, banee, channel); + this.api.kick(server, banee, channel, reason + + ' (network-wide ban requested by ' + banner + ')'); + setTimeout(function() { + i++; banChannel(channels); + }, 1000); + }.bind(this); + banChannel(channels); + } else { + event.reply(dbot.t('no_user', { 'user': banee })); } - - // Notify moderators, banee - if(this.config.admin_channel[event.server]) { - channels = _.without(channels, adminChannel); - - dbot.api.report.notify(server, adminChannel, notifyString); - dbot.say(event.server, adminChannel, notifyString); - - dbot.say(event.server, banee, dbot.t('nbanned_notify', { - 'network': network, - 'banner': banner, - 'reason': reason, - 'admin_channel': adminChannel - })); - } - - // Ban the user from all channels - var i = 0; - var banChannel = function(channels) { - if(i >= channels.length) return; - var channel = channels[i]; - this.api.ban(server, banee, channel); - this.api.kick(server, banee, channel, reason + - ' (network-wide ban requested by ' + banner + ')'); - setTimeout(function() { - i++; banChannel(channels); - }, 1000); - }.bind(this); - banChannel(channels); }.bind(this)); }, '~nunban': function(event) { var unbanee = event.params[1], - unbanner = event.user, - adminChannel = this.config.admin_channel[event.server], - channels = dbot.config.servers[event.server].channels, - network = event.server; + unbanner = event.user; - if(this.config.network_name[event.server]) { - network = this.config.network_name[event.server]; - } - - if(_.has(this.hosts, event.server) && _.has(this.hosts[event.server], unbanee)) { - var host = this.hosts[event.server][unbanee]; - - var notifyString = dbot.t('nunbanned', { - 'network': network, - 'unbanee': unbanee, - 'unbanner': unbanner - }); - - if(this.config.admin_channel[event.server]) { - dbot.api.report.notify(event.server, adminChannel, notifyString); - dbot.say(event.server, adminChannel, notifyString); + this.api.networkUnban(event.server, unbanee, unbanner, function(err) { + if(err) { + event.reply(dbot.t('nunban_error', { 'unbanee': unbanee })); } - - dbot.say(event.server, unbanee, dbot.t('nunban_notify', { - 'network': network, - 'unbanee': unbanee, - 'unbanner': unbanner - })); - - var i = 0; - var unbanChannel = function(channels) { - if(i >= channels.length) return; - var channel = channels[i]; - this.api.unban(event.server, host, channel); - setTimeout(function() { - i++; unbanChannel(channels); - }, 1000); - }.bind(this); - unbanChannel(channels); - } else { - event.reply(dbot.t('nunban_error', { 'unbanee': unbanee })); - } + }); }, /*** Kick Stats ***/ @@ -214,7 +196,7 @@ var commands = function(dbot) { commands['~kickstats'].access = 'regular'; commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4]; - commands['~nban'].regex = [/^~nban ([^ ]+) (.+)$/, 3]; + commands['~nban'].regex = /^~nban ([\d^ ]+)?([^ ]+) (.+)$/; return commands; }; diff --git a/modules/kick/config.json b/modules/kick/config.json index 0a52e4c..74adb04 100644 --- a/modules/kick/config.json +++ b/modules/kick/config.json @@ -1,5 +1,5 @@ { - "dbKeys": [ "kicks", "kickers", "hosts" ], + "dbKeys": [ "kicks", "kickers", "hosts", "tempBans" ], "dependencies": [ "command", "report", "users" ], "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md", "ignorable": true, diff --git a/modules/kick/kick.js b/modules/kick/kick.js index 63f6fcb..a3cee79 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -2,6 +2,7 @@ var _ = require('underscore')._; var kick = function(dbot) { this.hosts = dbot.db.hosts; + this.tempBans = dbot.db.tempBans; this.api = { 'ban': function(server, user, channel) { @@ -18,6 +19,67 @@ var kick = function(dbot) { 'unban': function(server, host, channel) { dbot.say(server, this.config.chanserv, 'unban ' + channel + ' *!*@' + host); + }, + + 'networkUnban': function(server, unbanee, unbanner, callback) { + var channels = dbot.config.servers[server].channels, + network = this.config.network_name[server] || server, + adminChannel = this.config.admin_channel[server]; + + if(_.has(this.hosts, server) && _.has(this.hosts[server], unbanee)) { + var host = this.hosts[server][unbanee]; + + // Notify Staff + if(!_.isUndefined(adminChannel)) { + var notifyString = dbot.t('nunbanned', { + 'network': network, + 'unbanee': unbanee, + 'unbanner': unbanner + }); + dbot.api.report.notify(server, adminChannel, notifyString); + dbot.say(server, adminChannel, notifyString); + } + + // Notify Unbanee + dbot.say(server, unbanee, dbot.t('nunban_notify', { + 'network': network, + 'unbanee': unbanee, + 'unbanner': unbanner + })); + + // Unban + var i = 0; + var unbanChannel = function(channels) { + if(i >= channels.length) return; + var channel = channels[i]; + this.api.unban(server, host, channel); + setTimeout(function() { + i++; unbanChannel(channels); + }, 1000); + }.bind(this); + unbanChannel(channels); + + callback(null); // Success + } else { + // Attempt to look up the host on-the-fly + dbot.api.nickserv.getUserHost(server, unbanee, function(host) { + if(host) { + if(!_.has(this.hosts, server)) this.hosts[server] = {}; + this.hosts[server][unbanee] = host; + this.api.networkUnban(server, unbanee, unbanner); + } else { + callback(true); // No host could be found + } + }); + } + } + }; + + this.internalAPI = { + 'addTempBan': function(server, banee, timeout) { + dbot.api.timers.addTimeout(timeout, function() { + + }); } }; diff --git a/modules/kick/strings.json b/modules/kick/strings.json index 42ec46a..55ad7df 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -38,6 +38,9 @@ "cy": "Cafodd {banee} ei wahardd o'r rhwydwaith gan {banner} ar {time}. Y rheswm a roddwyd oedd: \"{reason}.\"", "de": "{banee} wurde von {banner} auf dem gesamten Netzwerk um {time} gebannt. Grund: \"{reason}.\"" }, + "no_user": { + "en": "{user} doesn't seem to be online on this server." + }, "nunbanned": { "en": "Attention: {unbanee} has been unbanned from the {network} network by {unbanner}." }, From 5f86eb225fafff7e92501ed1f9a658c5319faa02 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 10 Jun 2013 16:20:47 +0000 Subject: [PATCH 28/34] raise acceptable response time for getUserInfo to 8 seconds --- modules/nickserv/nickserv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 2981d3e..6feafd9 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -20,7 +20,7 @@ var nickserv = function(dbot) { dbot.instance.connections[server].send('USERHOST ' + nick); setTimeout(function() { if(_.has(this.userStack[server], nick)) callback(false); - }.bind(this), 3000); + }.bind(this), 8000); } }; From 1c848376118b15875a95d4ea9de35fe6a8d294fa Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 10 Jun 2013 16:59:56 +0000 Subject: [PATCH 29/34] Initial non-persistent support for temp banning [#495] --- modules/kick/commands.js | 55 +++++++++++++++++++++++++++++---------- modules/kick/kick.js | 6 ++--- modules/kick/strings.json | 6 +++++ 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 8646ff8..c64aa46 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -66,12 +66,29 @@ var commands = function(dbot) { this.hosts[event.server][banee] = host; // Create notify string - /*if(!_.isUndefined(timeout)) { - timeout = new Date(new Date().getTime() + (timeout * 3600000)); + if(!_.isUndefined(timeout)) { + timeout = parseFloat(timeout.trim()); + + var msTimeout = new Date(new Date().getTime() + (timeout * 3600000)); if(!_.has(this.tempBans, event.server)) this.tempBans[event.server] = {}; - this.tempBans[event.server][banee] = timeout; - this.internalAPI.addTempBan(event.server, banee, timeout); - } else {*/ + this.tempBans[event.server][banee] = msTimeout; + this.internalAPI.addTempBan(event.server, banee, msTimeout); + + var notifyString = dbot.t('tbanned', { + 'network': network, + 'banner': banner, + 'banee': banee, + 'hours': timeout, + 'reason': reason + }); + var quoteString = dbot.t('tban_quote', { + 'banee': banee, + 'banner': banner, + 'hours': timeout, + 'time': new Date().toUTCString(), + 'reason': reason + }); + } else { var notifyString = dbot.t('nbanned', { 'network': network, 'banner': banner, @@ -84,8 +101,7 @@ var commands = function(dbot) { 'time': new Date().toUTCString(), 'reason': reason }); - //} - console.log(notifyString); + } // Add qutoe category documenting ban if(this.config.document_bans && _.has(dbot.modules, 'quotes')) { @@ -100,12 +116,23 @@ var commands = function(dbot) { dbot.api.report.notify(server, adminChannel, notifyString); dbot.say(event.server, adminChannel, notifyString); - dbot.say(event.server, banee, dbot.t('nbanned_notify', { - 'network': network, - 'banner': banner, - 'reason': reason, - 'admin_channel': adminChannel - })); + if(!_.isUndefined(timeout)) { + dbot.say(event.server, banee, dbot.t('tbanned_notify', { + 'network': network, + 'banner': banner, + 'reason': reason, + 'hours': timeout, + 'admin_channel': adminChannel + })); + } else { + dbot.say(event.server, banee, dbot.t('nbanned_notify', { + 'network': network, + 'banner': banner, + 'reason': reason, + 'hours': timeout, + 'admin_channel': adminChannel + })); + } } // Ban the user from all channels @@ -196,7 +223,7 @@ var commands = function(dbot) { commands['~kickstats'].access = 'regular'; commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4]; - commands['~nban'].regex = /^~nban ([\d^ ]+)?([^ ]+) (.+)$/; + commands['~nban'].regex = /^~nban ([\d\.^ ]+)?([^ ]+) (.+)$/; return commands; }; diff --git a/modules/kick/kick.js b/modules/kick/kick.js index a3cee79..4699728 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -78,9 +78,9 @@ var kick = function(dbot) { this.internalAPI = { 'addTempBan': function(server, banee, timeout) { dbot.api.timers.addTimeout(timeout, function() { - - }); - } + this.api.networkUnban(server, banee, dbot.config.name, function(err) {}); + }.bind(this)); + }.bind(this) }; this.listener = function(event) { diff --git a/modules/kick/strings.json b/modules/kick/strings.json index 55ad7df..07d8064 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -25,6 +25,12 @@ "cy": "Sylw: {banner} wedi gwahardd {banee} o {channel}. Y rheswm a roddwyd oedd: \"{reason}.\"", "de": "Achtung: {banner} hat {banee} von {channel} gebannt. Grund: \"{reason}.\"" }, + "tbanned": { + "en": "Attention: {banner} has banned {banee} from the {network} network for {hours} hours. The reason given was \"{reason}.\"" + }, + "tbanned_notify": { + "en": "You have been banned from the {network} network for {hours} hours by {banner}. The reason given was \"{reason}.\" You can join {admin_channel} for more information or to discuss the ban." + }, "nbanned": { "en": "Attention: {banner} has banned {banee} from the {network} network. The reason given was \"{reason}.\"", "cy": "Sylw: {banner} wedi gwahardd {banee} ledled y rhwydwaith. Y rheswm a roddwyd oedd: \"{reason}.\"", From 654a04810ac2a0f0e93ba24942730e9cee313c3d Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 10 Jun 2013 17:10:57 +0000 Subject: [PATCH 30/34] reload persistence for tempban [#495] --- modules/kick/kick.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/kick/kick.js b/modules/kick/kick.js index 4699728..ff15f3d 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -111,6 +111,14 @@ var kick = function(dbot) { } }.bind(this); this.on = 'KICK'; + + this.onLoad = function() { + _.each(this.tempBans, function(bans, server) { + _.each(bans, function(timeout, nick) { + this.internalAPI.addTempBan(server, nick, timeout); + }, this); + }, this); + }.bind(this); }; exports.fetch = function(dbot) { From dc6489767f33326cd3f0eaa099da9076ca472553 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 10 Jun 2013 17:20:58 +0000 Subject: [PATCH 31/34] create new date from serialised timeout --- modules/kick/kick.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/kick/kick.js b/modules/kick/kick.js index ff15f3d..5b11c6e 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -115,6 +115,7 @@ var kick = function(dbot) { this.onLoad = function() { _.each(this.tempBans, function(bans, server) { _.each(bans, function(timeout, nick) { + timeout = new Date(timeout); this.internalAPI.addTempBan(server, nick, timeout); }, this); }, this); From f6aebb61b4c261f1e987ee3a7b687b61bf281a22 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 11 Jun 2013 17:24:42 +0000 Subject: [PATCH 32/34] initial draft of word definition thing [#503] --- install.sh | 2 +- modules/words/config.json | 3 +++ modules/words/words.js | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 modules/words/config.json create mode 100644 modules/words/words.js diff --git a/install.sh b/install.sh index 70cf91c..9c1ae68 100755 --- a/install.sh +++ b/install.sh @@ -14,7 +14,7 @@ then exit 1 fi -npm install ent underscore request sandbox express moment jade@0.25 +npm install wordnik ent underscore request sandbox express moment jade@0.25 cd public/ wget http://twitter.github.com/bootstrap/assets/bootstrap.zip diff --git a/modules/words/config.json b/modules/words/config.json new file mode 100644 index 0000000..649e069 --- /dev/null +++ b/modules/words/config.json @@ -0,0 +1,3 @@ +{ + "api_key": "http://developer.wordnik.com/" +} diff --git a/modules/words/words.js b/modules/words/words.js new file mode 100644 index 0000000..eac90b0 --- /dev/null +++ b/modules/words/words.js @@ -0,0 +1,26 @@ +var Wordnik = require('wordnik'); + +var words = function(dbot) { + this.commands = { + '~define': function(event) { + var query = event.params[1]; + this.wn.definitions(query, function(err, defs) { + if(!err && defs[0]) { + event.reply(query + ': ' + defs[0].text); + } else { + event.reply('No definitions found for ' + query); + } + }); + } + }; + + this.onLoad = function() { + this.wn = new Wordnik({ + 'api_key': this.config.api_key + }); + }.bind(this); +}; + +exports.fetch = function(dbot) { + return new words(dbot); +}; From 051ea2ca28286af06a8903cbc20f9d300595d70c Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 11 Jun 2013 17:57:04 +0000 Subject: [PATCH 33/34] remove ban from ban list when tempban expires [#500] --- modules/kick/kick.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/kick/kick.js b/modules/kick/kick.js index 5b11c6e..6197b0d 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -79,6 +79,7 @@ var kick = function(dbot) { 'addTempBan': function(server, banee, timeout) { dbot.api.timers.addTimeout(timeout, function() { this.api.networkUnban(server, banee, dbot.config.name, function(err) {}); + delete this.tempBans[server][banee]; }.bind(this)); }.bind(this) }; From dce6ec6c548acf097a01fd3efc29b7bc8146f8f3 Mon Sep 17 00:00:00 2001 From: ProButcher Date: Wed, 12 Jun 2013 12:49:16 -0300 Subject: [PATCH 34/34] Updated README for kick module. Added ~ckick, ~cban, ~nban and ~nunban. --- modules/kick/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/kick/README.md b/modules/kick/README.md index b3aa217..3da8b6c 100644 --- a/modules/kick/README.md +++ b/modules/kick/README.md @@ -15,3 +15,15 @@ people. #### ~kickstats Show a list of top kickers and kickees. + +#### ~ckick [#channel] [username] [reason] +Kick a user from a channel. + +#### ~cban [#channel] [username] [reason] +Ban a user from a channel. + +#### ~nban {optional: Duration in Hours} [username] [reason] +Ban a user from the network. + +#### ~nunban [username] [reason] +Unban a user from the network.