From 0e2e6a60dbb4cadcbdab0ab1ca7b03528b5db59c Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 15:21:07 +0000 Subject: [PATCH 01/27] Add links to existing docs in config.json files [#352] --- modules/ctcp/config.json | 3 ++- modules/dent/config.json | 1 + modules/dns/config.json | 3 +++ modules/event/config.json | 3 +++ modules/timers/config.json | 3 +++ modules/web/config.json | 3 ++- 6 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 modules/dns/config.json create mode 100644 modules/event/config.json create mode 100644 modules/timers/config.json diff --git a/modules/ctcp/config.json b/modules/ctcp/config.json index c945e96..b300d9f 100644 --- a/modules/ctcp/config.json +++ b/modules/ctcp/config.json @@ -1,3 +1,4 @@ { - "ignorable": true + "ignorable": true, + "help": "https://github.com/reality/depressionbot/blob/master/modules/ctcp/README.md" } diff --git a/modules/dent/config.json b/modules/dent/config.json index 4a48ea8..8b0fd90 100644 --- a/modules/dent/config.json +++ b/modules/dent/config.json @@ -3,5 +3,6 @@ "password": "yourpasswordhere", "dependencies": [ "command" ], "ignorable": true, + "help": "https://github.com/reality/depressionbot/blob/master/modules/dent/README.md", "dentQuotes": false } diff --git a/modules/dns/config.json b/modules/dns/config.json new file mode 100644 index 0000000..644956e --- /dev/null +++ b/modules/dns/config.json @@ -0,0 +1,3 @@ +{ + "help": "https://github.com/reality/depressionbot/blob/master/modules/dns/README.md" +} diff --git a/modules/event/config.json b/modules/event/config.json new file mode 100644 index 0000000..55c9c57 --- /dev/null +++ b/modules/event/config.json @@ -0,0 +1,3 @@ +{ + "help": "https://github.com/reality/depressionbot/blob/master/modules/event/README.md" +} diff --git a/modules/timers/config.json b/modules/timers/config.json new file mode 100644 index 0000000..9cc23c8 --- /dev/null +++ b/modules/timers/config.json @@ -0,0 +1,3 @@ +{ + "help": "https://github.com/reality/depressionbot/blob/master/modules/timers/README.md" +} diff --git a/modules/web/config.json b/modules/web/config.json index 7ed62f6..f714ecc 100644 --- a/modules/web/config.json +++ b/modules/web/config.json @@ -1,5 +1,6 @@ { "webHost": "localhost", "webPort": 8080, - "externalPath": false + "externalPath": false, + "help": "https://github.com/reality/depressionbot/blob/master/modules/web/README.md" } From 8a2dd076a4eff8dad0c7045b896ab71e243c4075 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 15:33:43 +0000 Subject: [PATCH 02/27] show width/height of imgur image too [#350] --- modules/imgur/imgur.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index e47928c..217f159 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -21,7 +21,8 @@ var imgur = function(dbot) { } else { info += 'a non-animated ' + imgData.type.split('/')[1] + ' with '; } - info += imgData.views + ' views].'; + info += imgData.views + ' views ('; + info += imgData.width + 'x' + imgData.height + ')].'; } return info; From 8151122b8015e247c23cd6ab93ca07b0567840c5 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 15:41:13 +0000 Subject: [PATCH 03/27] oh, handler was checking existence of matches[2] for some stupid reason [Close #353] --- modules/imgur/imgur.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index 217f159..e5efccf 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -77,15 +77,15 @@ var imgur = function(dbot) { this.onLoad = function() { var imgurHandler = function(event, matches, name) { - if(matches[2]) { // TODO: handle this in the regex + if(matches[1]) { this.api.getImageInfo(matches[1], function(imgData) { var info = this.internalAPI.infoString(imgData); if(info) event.reply(info); }.bind(this)); } }.bind(this); - dbot.api.link.addHandler(this.name, /http:\/\/i\.imgur\.com\/([a-zA-Z0-9]+)\.([jpg|png|gif])/, imgurHandler); - dbot.api.link.addHandler(this.name, /\bhttps?:\/\/imgur\.com\/([a-zA-Z0-9]+)\b/i, imgurHandler); + dbot.api.link.addHandler(this.name, /https?:\/\/i\.imgur\.com\/([a-zA-Z0-9]+)\.([jpg|png|gif])/, imgurHandler); + dbot.api.link.addHandler(this.name, /https?:\/\/imgur\.com\/([a-zA-Z0-9]+)/, imgurHandler); }.bind(this); }; From a881e60c818822940bcd8ff987762a3429179ef6 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 16:54:48 +0000 Subject: [PATCH 04/27] Basic Reddit module which posts info about Reddit links posted in the channel [#293] --- modules/reddit/reddit.js | 46 +++++++++++++++++++++++++++++++++++++ modules/reddit/strings.json | 5 ++++ 2 files changed, 51 insertions(+) create mode 100644 modules/reddit/reddit.js create mode 100644 modules/reddit/strings.json diff --git a/modules/reddit/reddit.js b/modules/reddit/reddit.js new file mode 100644 index 0000000..b3c7a2c --- /dev/null +++ b/modules/reddit/reddit.js @@ -0,0 +1,46 @@ +/** + * Module Name: reddit + * Description: Various reddit functionality + */ +var _ = require('underscore')._, + request = require('request'); + +var reddit = function(dbot) { + this.ApiRoot = 'http://reddit.com/'; + + this.api = { + 'getSubredditInfo': function(name, callback) { + request.get({ + 'url': this.ApiRoot + 'r/' + name + '/about.json', + 'json': true, + 'headers': { + 'User-Agent': 'dbot by u/realitone' + } + }, function(err, response, body) { + callback(body); + }); + } + }; + + this.onLoad = function() { + var srHandler = function(event, matches, name) { + this.api.getSubredditInfo(matches[1], function(info) { + if(info.data) { + info = info.data; + var infoString = dbot.t('about_subreddit', { + 'display_name': info.display_name, + 'subscribers': info.subscribers, + 'active': info.accounts_active + }); + if(info.over18) infoString += ' [NSFW]'; + event.reply(infoString); + } + }); + }.bind(this); + dbot.api.link.addHandler(this.name, /https?:\/\/reddit\.com\/r\/([a-zA-Z0-9]+)/, srHandler); + }.bind(this); +}; + +exports.fetch = function(dbot) { + return new reddit(dbot); +} diff --git a/modules/reddit/strings.json b/modules/reddit/strings.json new file mode 100644 index 0000000..065e876 --- /dev/null +++ b/modules/reddit/strings.json @@ -0,0 +1,5 @@ +{ + "about_subreddit": { + "en": "[{display_name} has {subscribers} subscribers ({active} active)]" + } +} From 234e84010c8790932f0051df570e0e442cf60ebe Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 17:57:42 +0000 Subject: [PATCH 05/27] fix for reddit data with www --- modules/reddit/reddit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/reddit/reddit.js b/modules/reddit/reddit.js index b3c7a2c..97134a8 100644 --- a/modules/reddit/reddit.js +++ b/modules/reddit/reddit.js @@ -24,7 +24,7 @@ var reddit = function(dbot) { this.onLoad = function() { var srHandler = function(event, matches, name) { - this.api.getSubredditInfo(matches[1], function(info) { + this.api.getSubredditInfo(matches[2], function(info) { if(info.data) { info = info.data; var infoString = dbot.t('about_subreddit', { @@ -37,7 +37,7 @@ var reddit = function(dbot) { } }); }.bind(this); - dbot.api.link.addHandler(this.name, /https?:\/\/reddit\.com\/r\/([a-zA-Z0-9]+)/, srHandler); + dbot.api.link.addHandler(this.name, /https?:\/\/(www\.)?reddit\.com\/r\/([a-zA-Z0-9]+)/, srHandler); }.bind(this); }; From a6ca9bb9c8c24b8fdd2e77711b392527b71945bb Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 18:37:47 +0000 Subject: [PATCH 06/27] fix thing --- modules/imgur/imgur.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index e5efccf..b68f8ef 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -16,10 +16,14 @@ var imgur = function(dbot) { if(imgData.title) { info += imgData.title + ' is '; } - if(imgData.animated) { - info += 'an animated ' + imgData.type.split('/')[1] + ' with '; + if(imgData.type) { + if(imgData.animated) { + info += 'an animated ' + imgData.type.split('/')[1] + ' with '; + } else { + info += 'a non-animated ' + imgData.type.split('/')[1] + ' with '; + } } else { - info += 'a non-animated ' + imgData.type.split('/')[1] + ' with '; + info += 'an image with '; } info += imgData.views + ' views ('; info += imgData.width + 'x' + imgData.height + ')].'; From 49beccf849dd1ca19ba33e0cb9ff6bf02f3cad9f Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 18:38:53 +0000 Subject: [PATCH 07/27] fix syntax error in web --- modules/web/web.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/web/web.js b/modules/web/web.js index 452beb4..05c7bae 100644 --- a/modules/web/web.js +++ b/modules/web/web.js @@ -46,7 +46,7 @@ var webInterface = function(dbot) { } else { return 'http://' + this.config.webHost + ':' + port + '/' + path; } - }; + } }; }; From 1dada50559d56c33ba67776b3df2b400e1f5e9e9 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 19:20:02 +0000 Subject: [PATCH 08/27] Add ability to get post information and write regex (unimplemented handler for comments currently) which handles all three Things [#293] --- modules/reddit/reddit.js | 70 ++++++++++++++++++++++++++++--------- modules/reddit/strings.json | 3 ++ 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/modules/reddit/reddit.js b/modules/reddit/reddit.js index 97134a8..1cc9919 100644 --- a/modules/reddit/reddit.js +++ b/modules/reddit/reddit.js @@ -7,6 +7,7 @@ var _ = require('underscore')._, var reddit = function(dbot) { this.ApiRoot = 'http://reddit.com/'; + this.UserAgent = 'dbot by u/realitone'; this.api = { 'getSubredditInfo': function(name, callback) { @@ -14,30 +15,67 @@ var reddit = function(dbot) { 'url': this.ApiRoot + 'r/' + name + '/about.json', 'json': true, 'headers': { - 'User-Agent': 'dbot by u/realitone' + 'User-Agent': this.UserAgent } }, function(err, response, body) { - callback(body); + var data = null; + if(_.has(body, 'data')) data = body.data; + callback(data); + }); + }, + + 'getPostInfo': function(name, callback) { + request.get({ + 'url': this.ApiRoot + 'comments/' + name + '.json', + 'json': true, + 'headers': { + 'User-Agent': this.UserAgent + } + }, function(err, response, body) { + if(body[0] && _.has(body[0], 'data')) { + callback(body[0].data.children[0].data); + } }); } }; this.onLoad = function() { - var srHandler = function(event, matches, name) { - this.api.getSubredditInfo(matches[2], function(info) { - if(info.data) { - info = info.data; - var infoString = dbot.t('about_subreddit', { - 'display_name': info.display_name, - 'subscribers': info.subscribers, - 'active': info.accounts_active - }); - if(info.over18) infoString += ' [NSFW]'; - event.reply(infoString); - } - }); + var rHandler = function(event, matches, name) { + if(matches[6]) { // It's a comment + + } else if(matches[4]) { // It's a post + this.api.getPostInfo(matches[4], function(info) { + if(info) { + var infoString = dbot.t('about_post', { + 'poster': info.author, + 'subreddit': info.subreddit, + 'comments': info.num_comments, + 'score': info.score, + 'up': info.ups, + 'down': info.downs + }); + if(info.over18) infoString += ' [NSFW]'; + event.reply(infoString); + } + }); + } else if(matches[2]) { // It's a subreddit + this.api.getSubredditInfo(matches[2], function(info) { + if(info) { + var infoString = dbot.t('about_subreddit', { + 'display_name': info.display_name, + 'subscribers': info.subscribers, + 'active': info.accounts_active + }); + if(info.over18) infoString += ' [NSFW]'; + event.reply(infoString); + } + }); + } }.bind(this); - dbot.api.link.addHandler(this.name, /https?:\/\/(www\.)?reddit\.com\/r\/([a-zA-Z0-9]+)/, srHandler); + + dbot.api.link.addHandler(this.name, // I'm so sorry, Jesus. + /https?:\/\/(www\.)?reddit\.com\/r\/([a-zA-Z0-9]+)(\/comments\/([a-zA-Z0-9]+)?\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9_]+)?)?/, + rHandler); }.bind(this); }; diff --git a/modules/reddit/strings.json b/modules/reddit/strings.json index 065e876..87a23e5 100644 --- a/modules/reddit/strings.json +++ b/modules/reddit/strings.json @@ -1,5 +1,8 @@ { "about_subreddit": { "en": "[{display_name} has {subscribers} subscribers ({active} active)]" + }, + "about_post": { + "en": "[Post by {poster} in {subreddit}. Comments: {comments}. Score: {score} ({up}|{down})]" } } From 588ea41fb7d1d5d1347e394e7258d4351157cdad Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 19:58:05 +0000 Subject: [PATCH 09/27] Show comment info for reddit module [#293] --- modules/reddit/reddit.js | 34 ++++++++++++++++++++++++++++++++-- modules/reddit/strings.json | 5 ++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/modules/reddit/reddit.js b/modules/reddit/reddit.js index 1cc9919..47f2482 100644 --- a/modules/reddit/reddit.js +++ b/modules/reddit/reddit.js @@ -36,13 +36,43 @@ var reddit = function(dbot) { callback(body[0].data.children[0].data); } }); + }, + + 'getCommentInfo': function(post, name, callback) { + request.get({ + 'url': this.ApiRoot + 'comments/' + post + '.json', + 'qs': { + 'comment': name + }, + 'json': true, + 'headers': { + 'User-Agent': this.UserAgent + } + }, function(err, response, body) { + if(body[1] && _.has(body[1], 'data')) { + callback(body[1].data.children[0].data); + } + }); } }; this.onLoad = function() { var rHandler = function(event, matches, name) { if(matches[6]) { // It's a comment - + this.api.getCommentInfo(matches[4], matches[6], function(info) { + if(info) { + var infoString = dbot.t('about_comment', { + 'poster': info.author, + 'subreddit': info.subreddit, + 'comments': info.num_comments, + 'score': info.ups - info.downs, + 'up': info.ups, + 'down': info.downs + }); + if(info.over_18) infoString += ' [NSFW]'; + event.reply(infoString); + } + }); } else if(matches[4]) { // It's a post this.api.getPostInfo(matches[4], function(info) { if(info) { @@ -54,7 +84,7 @@ var reddit = function(dbot) { 'up': info.ups, 'down': info.downs }); - if(info.over18) infoString += ' [NSFW]'; + if(info.over_18) infoString += ' [NSFW]'; event.reply(infoString); } }); diff --git a/modules/reddit/strings.json b/modules/reddit/strings.json index 87a23e5..2a93967 100644 --- a/modules/reddit/strings.json +++ b/modules/reddit/strings.json @@ -3,6 +3,9 @@ "en": "[{display_name} has {subscribers} subscribers ({active} active)]" }, "about_post": { - "en": "[Post by {poster} in {subreddit}. Comments: {comments}. Score: {score} ({up}|{down})]" + "en": "[Post by {poster} in {subreddit} - Comments: {comments}, Score: {score} ({up}|{down})]" + }, + "about_comment": { + "en": "[Comment by {poster} in {subreddit} - Score: {score} ({up}|{down})]" } } From cd3b468adaf36b57173c51784d1b504c37bfae07 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 20:04:06 +0000 Subject: [PATCH 10/27] Show short form of link for Reddit posts [#293] --- modules/reddit/reddit.js | 5 +++-- modules/reddit/strings.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/reddit/reddit.js b/modules/reddit/reddit.js index 47f2482..009a913 100644 --- a/modules/reddit/reddit.js +++ b/modules/reddit/reddit.js @@ -82,12 +82,13 @@ var reddit = function(dbot) { 'comments': info.num_comments, 'score': info.score, 'up': info.ups, - 'down': info.downs + 'down': info.downs, + 'url': this.ApiRoot + matches[4] }); if(info.over_18) infoString += ' [NSFW]'; event.reply(infoString); } - }); + }.bind(this)); } else if(matches[2]) { // It's a subreddit this.api.getSubredditInfo(matches[2], function(info) { if(info) { diff --git a/modules/reddit/strings.json b/modules/reddit/strings.json index 2a93967..bef4de0 100644 --- a/modules/reddit/strings.json +++ b/modules/reddit/strings.json @@ -3,7 +3,7 @@ "en": "[{display_name} has {subscribers} subscribers ({active} active)]" }, "about_post": { - "en": "[Post by {poster} in {subreddit} - Comments: {comments}, Score: {score} ({up}|{down})]" + "en": "[Post by {poster} in {subreddit} - Comments: {comments}, Score: {score} ({up}|{down})] - {url}" }, "about_comment": { "en": "[Comment by {poster} in {subreddit} - Score: {score} ({up}|{down})]" From c1f642084d34e9940ef7200662f27671983cf54d Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 13 Apr 2013 21:08:23 +0000 Subject: [PATCH 11/27] flashy module uses new url constructor api --- modules/flashy/flashy.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js index 7c553c4..4a8126b 100644 --- a/modules/flashy/flashy.js +++ b/modules/flashy/flashy.js @@ -28,11 +28,8 @@ var flashy = function(dbot) { var text = event.input[2].trim().toUpperCase(); if(_.has(this.colourMap, colour)) { - event.reply(dbot.t('url', { - 'host': dbot.config.web.webHost, - 'port': dbot.config.web.webPort, - 'path': 'flashy/' + colour + '/' + encodeURIComponent(text) - })); + event.reply(dbot.api.web.getUrl('flashy/' + colour + '/' + + encodeURIComponent(text))); } else { var possibleColours = _.keys(this.colourMap).join(', ') + '.'; event.reply('No such colour, brah. Available colours are: ' + possibleColours); From 7d0162afff61abf1e5b9bc8949222eaa4b9edcd5 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sat, 13 Apr 2013 22:40:35 +0000 Subject: [PATCH 12/27] slim down the normal announcement Specifying that images are non-animated each time isn't really required, and causes the string to be rather long. Stripping this implicit property makes it look a bit nicer. --- modules/imgur/imgur.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index b68f8ef..27209c1 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -20,7 +20,7 @@ var imgur = function(dbot) { if(imgData.animated) { info += 'an animated ' + imgData.type.split('/')[1] + ' with '; } else { - info += 'a non-animated ' + imgData.type.split('/')[1] + ' with '; + info += 'a ' + imgData.type.split('/')[1] + ' with '; } } else { info += 'an image with '; From 541e6a1798078f73b2f4e832c849780dd35a7792 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 14 Apr 2013 01:35:04 +0000 Subject: [PATCH 13/27] add color to up/downvotes; move NSFW to strings Orange isn't a color widely available on IRC clients, so green has been substituted. "NSFW" is fairly transcendal when it comes to languages; Catalan, French, and German generally do not seem to localise the abbreviation. However, it has been moved to strings.json on the off chance that a better translation arises. This commit has not been tested. Merge at your own risk. --- modules/reddit/reddit.js | 6 +++--- modules/reddit/strings.json | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/reddit/reddit.js b/modules/reddit/reddit.js index 009a913..9250d31 100644 --- a/modules/reddit/reddit.js +++ b/modules/reddit/reddit.js @@ -69,7 +69,7 @@ var reddit = function(dbot) { 'up': info.ups, 'down': info.downs }); - if(info.over_18) infoString += ' [NSFW]'; + if(info.over_18) infoString += " " + dbot.t("nsfw"); event.reply(infoString); } }); @@ -85,7 +85,7 @@ var reddit = function(dbot) { 'down': info.downs, 'url': this.ApiRoot + matches[4] }); - if(info.over_18) infoString += ' [NSFW]'; + if(info.over_18) infoString += " " + dbot.t("nsfw"); event.reply(infoString); } }.bind(this)); @@ -97,7 +97,7 @@ var reddit = function(dbot) { 'subscribers': info.subscribers, 'active': info.accounts_active }); - if(info.over18) infoString += ' [NSFW]'; + if(info.over18) infoString += dbot.t("nsfw"); event.reply(infoString); } }); diff --git a/modules/reddit/strings.json b/modules/reddit/strings.json index bef4de0..a6984e1 100644 --- a/modules/reddit/strings.json +++ b/modules/reddit/strings.json @@ -3,9 +3,12 @@ "en": "[{display_name} has {subscribers} subscribers ({active} active)]" }, "about_post": { - "en": "[Post by {poster} in {subreddit} - Comments: {comments}, Score: {score} ({up}|{down})] - {url}" + "en": "[Post by {poster} in {subreddit} — Comments: {comments}, Score: {score} (\u00039▲{up}\u0015|\u000312{down}▼\u0015)] — {url}" }, "about_comment": { - "en": "[Comment by {poster} in {subreddit} - Score: {score} ({up}|{down})]" + "en": "[Comment by {poster} in {subreddit} — Score: {score} (\u00039▲{up}\u0015|\u000312{down}▼\u0015)]" + } + "nsfw": { + "en": "[NSFW]" } } From b24a9b56b12650efa3294ba6e02b6af15e11b284 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 14 Apr 2013 01:39:13 +0000 Subject: [PATCH 14/27] Update strings.json --- modules/reddit/strings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/reddit/strings.json b/modules/reddit/strings.json index a6984e1..6148652 100644 --- a/modules/reddit/strings.json +++ b/modules/reddit/strings.json @@ -7,7 +7,7 @@ }, "about_comment": { "en": "[Comment by {poster} in {subreddit} — Score: {score} (\u00039▲{up}\u0015|\u000312{down}▼\u0015)]" - } + }, "nsfw": { "en": "[NSFW]" } From 1a9f2d47eeda6365441348c87c2c93695540b407 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 14 Apr 2013 01:46:39 +0000 Subject: [PATCH 15/27] Update strings.json --- modules/reddit/strings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/reddit/strings.json b/modules/reddit/strings.json index 6148652..7a4d692 100644 --- a/modules/reddit/strings.json +++ b/modules/reddit/strings.json @@ -3,10 +3,10 @@ "en": "[{display_name} has {subscribers} subscribers ({active} active)]" }, "about_post": { - "en": "[Post by {poster} in {subreddit} — Comments: {comments}, Score: {score} (\u00039▲{up}\u0015|\u000312{down}▼\u0015)] — {url}" + "en": "[Post by {poster} in {subreddit} — Comments: {comments}, Score: {score} (\u00039▲{up}\u000f|\u000312{down}▼\u000f)] — {url}" }, "about_comment": { - "en": "[Comment by {poster} in {subreddit} — Score: {score} (\u00039▲{up}\u0015|\u000312{down}▼\u0015)]" + "en": "[Comment by {poster} in {subreddit} — Score: {score} (\u00039▲{up}\u000f|\u000312{down}▼\u000f)]" }, "nsfw": { "en": "[NSFW]" From 5e063ac24ae4ea91ac3b567ffc5c07fcea66d8c7 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 03:53:53 +0000 Subject: [PATCH 16/27] fix web getUrl api function --- modules/web/web.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/web/web.js b/modules/web/web.js index 05c7bae..d860f32 100644 --- a/modules/web/web.js +++ b/modules/web/web.js @@ -41,10 +41,13 @@ var webInterface = function(dbot) { this.api = { 'getUrl': function(path) { + console.log(path); if(this.config.externalPath) { + console.log('external'); return this.config.externalPath + '/' + path; } else { - return 'http://' + this.config.webHost + ':' + port + '/' + path; + console.log('internal'); + return 'http://' + this.config.webHost + ':' + this.config.webPort + '/' + path; } } }; From 69c7ddde553e08a2563c9bfc132dbd1faf54abc8 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 04:00:59 +0000 Subject: [PATCH 17/27] missing close brakcet in profiles --- modules/profile/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/profile/commands.js b/modules/profile/commands.js index ece4638..6e6e6b5 100644 --- a/modules/profile/commands.js +++ b/modules/profile/commands.js @@ -33,7 +33,7 @@ var commands = function(dbot){ if(event.params[1]){ var primary = dbot.api.users.resolveUser(event.server, event.params[1]); if(_.has(dbot.db.profiles[event.server], primary.toLowerCase())){ - event.reply(dbot.api.web.getUrl("/profile/"+event.server+"/"+primary.toLowerCase()); + event.reply(dbot.api.web.getUrl("/profile/"+event.server+"/"+primary.toLowerCase())); } else{ event.reply("No profile found for "+event.params[1]); From de2a22834d94ee42dac1d399ee5a61849297c642 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 04:02:00 +0000 Subject: [PATCH 18/27] extra whatever thing good comit msg --- modules/profile/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/profile/commands.js b/modules/profile/commands.js index 6e6e6b5..609bcb6 100644 --- a/modules/profile/commands.js +++ b/modules/profile/commands.js @@ -33,7 +33,7 @@ var commands = function(dbot){ if(event.params[1]){ var primary = dbot.api.users.resolveUser(event.server, event.params[1]); if(_.has(dbot.db.profiles[event.server], primary.toLowerCase())){ - event.reply(dbot.api.web.getUrl("/profile/"+event.server+"/"+primary.toLowerCase())); + event.reply(dbot.api.web.getUrl("profile/"+event.server+"/"+primary.toLowerCase())); } else{ event.reply("No profile found for "+event.params[1]); From 5e0f1266933aa938fe55db5281a9d9fa35ff88f2 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 13:58:45 +0000 Subject: [PATCH 19/27] Do [#359] --- modules/command/api.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/command/api.js b/modules/command/api.js index dd19b9e..3f3ae3d 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -53,10 +53,18 @@ var api = function(dbot) { var applies = false; if(_.has(dbot.commands[commandName], 'regex')) { var cRegex = dbot.commands[commandName].regex; - var q = event.message.valMatch(cRegex[0], cRegex[1]); - if(q) { - applies = true; - event.input = q; + if(_.isArray(cRegex) && cRegex.length == 2) { + var q = event.message.valMatch(cRegex[0], cRegex[1]); + if(q) { + applies = true; + event.input = q; + } + } else if { + var q = event.message.match(cRegex); + if(q) { + applies = true; + event.input = q; + ] } } else { applies = true; From b51f24006145368a26c2fa9ba8d4b630217dfa9f Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 14:29:14 +0000 Subject: [PATCH 20/27] Fix broken syntax in command changes [#359] --- modules/command/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/command/api.js b/modules/command/api.js index 3f3ae3d..da718d3 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -59,12 +59,12 @@ var api = function(dbot) { applies = true; event.input = q; } - } else if { + } else { var q = event.message.match(cRegex); if(q) { applies = true; event.input = q; - ] + } } } else { applies = true; From d8267316efd05a4ec01d92de233777d565eac926 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 14:33:47 +0000 Subject: [PATCH 21/27] Add API function for notification in report module [#360] --- modules/report/report.js | 51 +++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/modules/report/report.js b/modules/report/report.js index 89910ba..9c7953b 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -1,6 +1,23 @@ var _ = require('underscore')._; var report = function(dbot) { + this.api = { + 'notify': function(server, channel, reporter, reported, message) { + var channel = dbot.instance.connections[server].channels[channel]; + var ops = _.filter(channel.nicks, function(user) { + if(this.config.notifyVoice) { + return user.op || user.voice; + } else { + return user.op; + } + }, this); + + _.each(ops, function(user) { + dbot.say(server, user.name, message); + }, this); + } + }; + var commands = { '~report': function(event) { var channelName = event.input[1]; @@ -8,31 +25,21 @@ var report = function(dbot) { var reason = event.input[3]; if(_.has(event.allChannels, channelName)) { - var channel = event.allChannels[channelName]; if(dbot.api.users.isChannelUser(event.server, nick, channelName, true)) { - var nick = dbot.api.users.resolveUser(event.server, nick, true); - var ops = _.filter(channel.nicks, function(user) { - if(this.config.notifyVoice) { - return user.op || user.voice; - } else { - return user.op; - } - }, this); - - _.each(ops, function(user) { - dbot.say(event.server, user.name, dbot.t('report', { - 'reporter': event.user, - 'reported': nick, - 'channel': channelName, - 'reason': reason - })); - }, this); - + nick = dbot.api.users.resolveUser(event.server, nick, true); + this.api.notify(event.server, channelName, event.user, nick, dbot.t('report', { + 'reporter': event.user, + 'reported': nick, + 'channel': channelName, + 'reason': reason + })); event.reply(dbot.t('reported', { 'reported': nick })); } else { - event.reply(dbot.t('user_not_found', { 'reported': nick, - 'channel': channelName })); - } + event.reply(dbot.t('user_not_found', { + 'reported': nick, + 'channel': channelName + })); + } } else { event.reply(dbot.t('not_in_channel', { 'channel': channelName })); } From 732a1e3d3bc73826307b1ec26472aeb1a4de17d5 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 14:34:30 +0000 Subject: [PATCH 22/27] ~ckick command to channelKick on behalf of dbot. Add countSilently kick option. [#261] --- modules/kick/config.json | 5 ++-- modules/kick/kick.js | 63 +++++---------------------------------- modules/kick/strings.json | 3 ++ modules/web/config.json | 4 +-- 4 files changed, 16 insertions(+), 59 deletions(-) diff --git a/modules/kick/config.json b/modules/kick/config.json index 558129d..d765613 100644 --- a/modules/kick/config.json +++ b/modules/kick/config.json @@ -1,6 +1,7 @@ { "dbKeys": [ "kicks", "kickers" ], - "dependencies": [ "command" ], + "dependencies": [ "command", "report", "users" ], "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md", - "ignorable": true + "ignorable": true, + "countSilently": true } diff --git a/modules/kick/kick.js b/modules/kick/kick.js index 37e4b95..f00720d 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -1,56 +1,7 @@ var _ = require('underscore')._; var kick = function(dbot) { - var commands = { - // Give the number of times a given user has been kicked and has kicked - // other people. - '~kickcount': function(event) { - var username = event.params[1]; - - if(!_.has(dbot.db.kicks, username)) { - var kicks = '0'; - } else { - var kicks = dbot.db.kicks[username]; - } - - if(!_.has(dbot.db.kickers, username)) { - var kicked = '0'; - } else { - var kicked = dbot.db.kickers[username]; - } - - event.reply(dbot.t('user_kicks', { - 'user': username, - 'kicks': kicks, - 'kicked': kicked - })); - }, - - // Output a list of the people who have been kicked the most and those - // who have kicked other people the most. - '~kickstats': function(event) { - var orderedKickLeague = function(list, topWhat) { - var kickArr = _.chain(list) - .pairs() - .sortBy(function(kick) { return kick[1] }) - .reverse() - .first(10) - .value(); - - var kickString = "Top " + topWhat + ": "; - for(var i=0;i Date: Sun, 14 Apr 2013 14:35:49 +0000 Subject: [PATCH 23/27] include new kick commands file... [#261] --- modules/kick/commands.js | 78 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 modules/kick/commands.js diff --git a/modules/kick/commands.js b/modules/kick/commands.js new file mode 100644 index 0000000..a3dd294 --- /dev/null +++ b/modules/kick/commands.js @@ -0,0 +1,78 @@ +var commands = function(dbot) { + var commands = { + /*** Kick Management ***/ + '~ckick': function(event) { + var server = event.server, + kicker = event.user, + kickee = event.input[2], + channel = event.input[1], + 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', { + 'kicker': kicker, + 'kickee': kickee, + 'channel': channel, + 'reason': reason + })); + }, + + /*** Kick Stats ***/ + + // Give the number of times a given user has been kicked and has kicked + // other people. + '~kickcount': function(event) { + var username = event.params[1]; + + if(!_.has(dbot.db.kicks, username)) { + var kicks = '0'; + } else { + var kicks = dbot.db.kicks[username]; + } + + if(!_.has(dbot.db.kickers, username)) { + var kicked = '0'; + } else { + var kicked = dbot.db.kickers[username]; + } + + event.reply(dbot.t('user_kicks', { + 'user': username, + 'kicks': kicks, + 'kicked': kicked + })); + }, + + // Output a list of the people who have been kicked the most and those + // who have kicked other people the most. + '~kickstats': function(event) { + var orderedKickLeague = function(list, topWhat) { + var kickArr = _.chain(list) + .pairs() + .sortBy(function(kick) { return kick[1] }) + .reverse() + .first(10) + .value(); + + var kickString = "Top " + topWhat + ": "; + for(var i=0;i Date: Sun, 14 Apr 2013 14:38:04 +0000 Subject: [PATCH 24/27] revert the fucking web config file again --- modules/web/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/web/config.json b/modules/web/config.json index 1b7646b..f714ecc 100644 --- a/modules/web/config.json +++ b/modules/web/config.json @@ -1,6 +1,6 @@ { - "webHost": "nourishedcloud.com", - "webPort": 9001, + "webHost": "localhost", + "webPort": 8080, "externalPath": false, "help": "https://github.com/reality/depressionbot/blob/master/modules/web/README.md" } From e40a8437a32e98a314a57637da02f60fe5c700c8 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 15:00:15 +0000 Subject: [PATCH 25/27] bind the kick listener correctly to this --- modules/kick/kick.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kick/kick.js b/modules/kick/kick.js index f00720d..5308615 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -38,7 +38,7 @@ var kick = function(dbot) { }) + ')'); } } - }; + }.bind(this); this.on = 'KICK'; }; From ce647263f18c2b44d12cae44acf934784fd3c531 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 15:06:51 +0000 Subject: [PATCH 26/27] bump jsbot --- jsbot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsbot b/jsbot index 2be1731..e6a0c48 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit 2be1731911bf2a207b963ac79656f626e09eac6f +Subproject commit e6a0c4880bfd4985a29c03ab87944463b03fe333 From c1670dcbe254cf7be8829db29e973fd2f193a5b2 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 14 Apr 2013 15:09:45 +0000 Subject: [PATCH 27/27] bump jsbot --- jsbot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsbot b/jsbot index e6a0c48..11cbb75 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit e6a0c4880bfd4985a29c03ab87944463b03fe333 +Subproject commit 11cbb75b504fbb703450a2f8c938d5a81680109c