From 80b586ba605b93eb1f361fc823730991e32721eb Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 6 May 2013 21:49:45 +0000 Subject: [PATCH 1/7] Fix access control [Close #436] --- modules/command/api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/command/api.js b/modules/command/api.js index 4abaa9b..5fb8aa4 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -21,7 +21,10 @@ var api = function(dbot) { var accessNeeded = dbot.commands[command].access; if(accessNeeded == 'admin' || accessNeeded == 'moderator') { - if(!_.include(dbot.config[accessNeeded + 's'], user)) { // lol + var allowedNicks = dbot.config.admins; + if(accessNeeded == 'moderator') allowedNicks = _.union(allowedNicks, dbot.config.moderators); + + if(!_.include(allowedNicks, user)) { callback(false); } else { if(_.has(dbot.modules, 'nickserv') && this.config.useNickserv == true) { From cdfe353b94ad15f9714ec8ed9c9ed4aa73299c16 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 6 May 2013 21:56:45 +0000 Subject: [PATCH 2/7] more shit i cant be bothered to finish yet on [#261] --- modules/kick/commands.js | 86 ++++++++++++++++++++++++++++++++++++++- modules/kick/config.json | 3 ++ modules/kick/strings.json | 3 ++ modules/report/report.js | 4 +- 4 files changed, 92 insertions(+), 4 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index a3dd294..4310d79 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -1,6 +1,9 @@ +var _ = require('underscore')._; + var commands = function(dbot) { var commands = { /*** Kick Management ***/ + '~ckick': function(event) { var server = event.server, kicker = event.user, @@ -9,7 +12,8 @@ var commands = function(dbot) { reason = event.input[3]; this.api.kick(server, kickee, channel, reason + ' (requested by ' + kicker + ')'); - dbot.api.report.notify(server, channel, kicker, kickee, dbot.t('ckicked', { + + dbot.api.report.notify(server, channel, dbot.t('ckicked', { 'kicker': kicker, 'kickee': kickee, 'channel': channel, @@ -17,6 +21,80 @@ var commands = function(dbot) { })); }, + '~cban': function(event) { + var server = event.server, + banner = event.user, + banee = event.input[2], + channel = event.input[1], + reason = event.input[3]; + + this.api.ban(server, banee, channel); + this.api.kick(server, kickee, channel, reason + ' (requested by ' + banner + ')'); + + dbot.api.report.notify(server, channel, dbot.t('cbanned', { + 'banner': banner, + 'banee': banee, + 'channel': channel, + 'reason': reason + })); + }, + + '~cquiet': function(event) { + var server = event.server, + quieter = event.user, + quietee = event.input[2], + channel = event.input[1], + reason = event.input[3]; + + this.api.quiet(server, quietee, channel); + + dbot.api.report(server, channel, dbot.t('cquieted', { + 'quieter': quieter, + 'quietee': quietee, + 'channel': channel, + 'reason': reason + })); + }, + + '~nquiet': function(event) { + var server = event.server, + quieter = event.user, + quietee = event.input[1], + channels = dbot.config.servers[server].channels, + reason = event.input[2]; + + _.each(channels, function(channel) { + this.api.quiet(server, quietee, channel); + }, this); + + dbot.api.report(server, channel, dbot.t('nquieted', { + 'quieter': quieter, + 'quietee': quietee, + 'reason': reason + })); + }, + + // Kick and ban from all channels on the network. + '~nban': function(event) { + var server = event.server, + banner = event.user, + banee = event.input[1], + reason = event.input[2], + channels = dbot.config.servers[server].channels; + + _.each(channels, function(channel) { + this.api.ban(server, banee, channel); + this.api.kick(server, banee, channel, reason + + ' (network-wide ban requested by ' + banner + ')'); + }, this); + + dbot.api.report.notify(server, this.config.admin_channels[event.server], dbot.t('nbanned', { + 'banner': banner, + 'banee': banee, + 'reason': reason + })); + }, + /*** Kick Stats ***/ // Give the number of times a given user has been kicked and has kicked @@ -67,8 +145,12 @@ var commands = function(dbot) { } }; - commands['~ckick'].access = 'moderator'; + _.each(commands, function(command) { + command.access = 'moderator'; + }); + commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4]; + commands['~nban'].regex = [/^~nban ([^ ]+) (.+)$/, 3]; return commands; }; diff --git a/modules/kick/config.json b/modules/kick/config.json index c32561f..bd6e05f 100644 --- a/modules/kick/config.json +++ b/modules/kick/config.json @@ -4,5 +4,8 @@ "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md", "ignorable": true, "countSilently": true, + "admin_channels": { + "aberwiki": "#fishbox" + }, "chanserv": "ChanServ" } diff --git a/modules/kick/strings.json b/modules/kick/strings.json index 6764552..e9e13f5 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -17,4 +17,7 @@ "cy": "Ni ddylech cicio {botname}", "nl": "Gij zult {botname} niet kicken" } + "nbanned": { + "en": "Attention: {banner} has banned {banee} network-wide. The reason given was \"{reason}.\"" + } } diff --git a/modules/report/report.js b/modules/report/report.js index 9c7953b..1f545df 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -2,7 +2,7 @@ var _ = require('underscore')._; var report = function(dbot) { this.api = { - 'notify': function(server, channel, reporter, reported, message) { + 'notify': function(server, channel, message) { var channel = dbot.instance.connections[server].channels[channel]; var ops = _.filter(channel.nicks, function(user) { if(this.config.notifyVoice) { @@ -27,7 +27,7 @@ var report = function(dbot) { if(_.has(event.allChannels, channelName)) { if(dbot.api.users.isChannelUser(event.server, nick, channelName, true)) { nick = dbot.api.users.resolveUser(event.server, nick, true); - this.api.notify(event.server, channelName, event.user, nick, dbot.t('report', { + this.api.notify(event.server, channelName, dbot.t('report', { 'reporter': event.user, 'reported': nick, 'channel': channelName, From b46f72a409eaf405f3a6069fb20b8500360544fd Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 7 May 2013 14:23:37 +0000 Subject: [PATCH 3/7] nban should work goodly now --- modules/kick/commands.js | 23 +++++++++++++++++++---- modules/kick/config.json | 3 ++- modules/kick/strings.json | 10 ++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 4310d79..d5cd3b3 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -39,7 +39,7 @@ var commands = function(dbot) { })); }, - '~cquiet': function(event) { + /*'~cquiet': function(event) { var server = event.server, quieter = event.user, quietee = event.input[2], @@ -72,7 +72,7 @@ var commands = function(dbot) { 'quietee': quietee, 'reason': reason })); - }, + },*/ // Kick and ban from all channels on the network. '~nban': function(event) { @@ -88,11 +88,26 @@ var commands = function(dbot) { ' (network-wide ban requested by ' + banner + ')'); }, this); - dbot.api.report.notify(server, this.config.admin_channels[event.server], dbot.t('nbanned', { + var notifyString = dbot.t('nbanned', { 'banner': banner, 'banee': banee, 'reason': reason - })); + }); + + // 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', { + 'banee': banee, + 'banner': banner, + 'time': new Date().toUTCString(), + 'reason': reason + }) ]; + + notifyString += ' ' + dbot.t('quote_recorded', { 'user': banee }); + } + + dbot.api.report.notify(server, this.config.admin_channels[event.server], notifyString); }, /*** Kick Stats ***/ diff --git a/modules/kick/config.json b/modules/kick/config.json index bd6e05f..bf4cd1d 100644 --- a/modules/kick/config.json +++ b/modules/kick/config.json @@ -7,5 +7,6 @@ "admin_channels": { "aberwiki": "#fishbox" }, - "chanserv": "ChanServ" + "chanserv": "ChanServ", + "document_bans": false } diff --git a/modules/kick/strings.json b/modules/kick/strings.json index e9e13f5..f71fd0e 100644 --- a/modules/kick/strings.json +++ b/modules/kick/strings.json @@ -13,11 +13,17 @@ "cy": "Ni ddylech cicio {botname}" }, "ckicked": { - "en": "Attention: {kicker} has kicked {kickee} from {channel}. The reason given was: \"{reason}.\"" + "en": "Attention: {kicker} has kicked {kickee} from {channel}. The reason given was: \"{reason}.\"", "cy": "Ni ddylech cicio {botname}", "nl": "Gij zult {botname} niet kicken" - } + }, "nbanned": { "en": "Attention: {banner} has banned {banee} network-wide. The reason given was \"{reason}.\"" + }, + "nban_quote": { + "en": "{banee} was banned from the network by {banner} on {time}. The reason given was \"{reason}.\"" + }, + "quote_recorded": { + "en": "This has been recorded in ~ban_{user}." } } From cef60ccb64f17b443357cec6e1f7e6bcd47f3e6a Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 10 May 2013 11:45:38 +0000 Subject: [PATCH 4/7] docs for nickserv module [#351][#352] --- modules/nickserv/README.md | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 modules/nickserv/README.md diff --git a/modules/nickserv/README.md b/modules/nickserv/README.md new file mode 100644 index 0000000..93c0ebe --- /dev/null +++ b/modules/nickserv/README.md @@ -0,0 +1,41 @@ +## Nickserv + +Check nick authentication with nickserv. + +### Description + +This module provides an API function which allows you to check the +authentication status of a given nick. This is useful for checking that someone +is actually who they say they are, and not an imposter; for example, this API +function will be used in the command module to check if a user is authed before +running commands which require elevated access (if the useNickserv configuration +option is set). + +### Configuration + +#### Servers + +This is a data structure which allows you to define the data behaviour for +nickservs on various different servers. + + _nc_: { + _matcher_: This is a regular expression which will be used to match login + status responses from nickserv. + _acceptableState_: The numeric response from nickserv which will be + accepted as meaning the user is authenticated. + _infoCommand_: The command to be sent to nickserv inquiring about user + authentication status. + } + +The server name should match that of the one configured in the main DBot +config.json file. Also note that the name of the services bot these commands +will be sent to will also be taken from the 'nickserv' configuration option in +the server definition in the main config file. + +### API + +#### auth(server, nick, callback) +This will send a message to the configured nickserv bot inquiring as to the +login status of the given user. The callback will be called with one argument, +true or false depending on the nickserv's response as to whether the nick is +authed or not. From 15e6b039b96376fd2e8966855a2b182ac7cc75e2 Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 10 May 2013 11:48:52 +0000 Subject: [PATCH 5/7] add link to nickserv dox[#352] --- modules/nickserv/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/nickserv/config.json b/modules/nickserv/config.json index 3bcaece..06ef457 100644 --- a/modules/nickserv/config.json +++ b/modules/nickserv/config.json @@ -5,5 +5,6 @@ "acceptableState": 3, "infoCommand": "status" } - } + }, + "help": "https://github.com/reality/depressionbot/blob/master/modules/nickserv/README.md" } From 9fc95cdd047e3bf0423f6f1f8130d1b506bc35f7 Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 10 May 2013 12:11:32 +0000 Subject: [PATCH 6/7] flashy dox[#351][#352] --- modules/flashy/README.md | 9 +++++++++ modules/flashy/config.json | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 modules/flashy/README.md create mode 100644 modules/flashy/config.json diff --git a/modules/flashy/README.md b/modules/flashy/README.md new file mode 100644 index 0000000..2ed5530 --- /dev/null +++ b/modules/flashy/README.md @@ -0,0 +1,9 @@ +## Flashy + +Make big flashy text at people. + +### Commands + +#### ~flashy [color] [message] +Give a link to a page hosted by the flashy module which produces big flashing +text in the given colour. diff --git a/modules/flashy/config.json b/modules/flashy/config.json new file mode 100644 index 0000000..39287b4 --- /dev/null +++ b/modules/flashy/config.json @@ -0,0 +1,3 @@ +{ + "help": "https://github.com/reality/depressionbot/blob/master/modules/flashy/README.md" +} From 91f2730785e6e97101cad2796c00693ce13572fb Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 10 May 2013 12:38:14 +0000 Subject: [PATCH 7/7] favicon [#416] --- public/favicon.ico | Bin 0 -> 318 bytes views/layout.jade | 1 + 2 files changed, 1 insertion(+) create mode 100644 public/favicon.ico diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..b402290ee73a22ba6788aec7579a6c6f742f5650 GIT binary patch literal 318 zcma)zF%H5o5Cq2(qIP77+E8%?g?~V#l$5}C;0Jkx|H88nw@xCZL9na6J>Bg>aK;!B zjsbRZmoC{A*!YBJo70%mP;G1nt0QKWda_mO_gcD!R1Vp>PbCZgxC)+I`a|dJQ|TMz egKulsBb6mL_a1LJZ@)|b%L{IIxX#k9n|>dAfFyAM literal 0 HcmV?d00001 diff --git a/views/layout.jade b/views/layout.jade index ad2d14e..c7b9b65 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -6,6 +6,7 @@ html(lang='en') link(rel="stylesheet", type="text/css", href="http://fonts.googleapis.com/css?family=Source+Sans+Pro") link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css") link(rel='stylesheet', type='text/css', href='/styles.css') + link(rel='shortcut icon', type='image/png', href='/favicon.ico') title #{name} web interface body div.container