From a9b4e1c662e28f64c43da8a1285cada16aa43aa1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 18 Aug 2012 22:04:13 +0300 Subject: [PATCH] Improve success rate of mustachification imgtype=face tries to return results that contain human faces making it easier for mustachify to do its job. --- src/scripts/google-images.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scripts/google-images.coffee b/src/scripts/google-images.coffee index 8574d2c21..39809e255 100644 --- a/src/scripts/google-images.coffee +++ b/src/scripts/google-images.coffee @@ -24,13 +24,15 @@ module.exports = (robot) -> if imagery.match /^https?:\/\//i msg.send "#{mustachify}#{imagery}" else - imageMe msg, imagery, (url) -> + imageMe msg, imagery, false, true, (url) -> msg.send "#{mustachify}#{url}" -imageMe = (msg, query, animated, cb) -> +imageMe = (msg, query, animated, faces, cb) -> cb = animated if typeof animated == 'function' + cb = faces if typeof faces == 'function' q = v: '1.0', rsz: '8', q: query, safe: 'active' q.as_filetype = 'gif' if typeof animated is 'boolean' and animated is true + q.imgtype = 'face' if typeof faces is 'boolean' and faces is true msg.http('http://ajax.googleapis.com/ajax/services/search/images') .query(q) .get() (err, res, body) ->