From 5fd2a3923f4218bd873b3604ce1778dd3af6523e Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Fri, 17 May 2013 17:04:53 +0000 Subject: [PATCH] Add tracking for a certain hash This is a fairly simple hack to record any imgur URLs discovered via the random image facility that match a certain MD5 hash. A known bug with this commit is that it may crash the bot the first time the bot tries to add to the database, as the category is undefined. This can be easily worked around by ensuring that the category is prepopulated with at least one image before letting the bot add automatically. An issue should probably be opened to merge this code into something reading hashes from a configuration file: it's pretty hardcoded at the moment. --- modules/imgur/imgur.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index b412d4c..a546314 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -52,6 +52,14 @@ var imgur = function(dbot) { if(!error && response.statusCode == 200 && body.length != 492) { this.db.totalImages += 1; var hash = crypto.createHash('md5').update(body).digest("hex"); + if((hash == "e49e686582ce3f60cb51d00c10924861") && _.has(dbot.modules, 'quotes')){ + var qdb = dbot.db.quoteArrs["facebookman"]; + if (_.include(qdb, testUrl)){ + // do something + } else { + qdb.push(testUrl); + } + } callback(testUrl, testSlug,hash); } else { this.api.getRandomImage(callback);