From 797459889eba28ad16fe6b6ddefa98828c472c11 Mon Sep 17 00:00:00 2001 From: Tom Bell Date: Fri, 22 Jun 2012 11:41:13 +0100 Subject: [PATCH] Remove underscore dependency --- package.json | 3 +-- src/scripts/google-images.coffee | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 9d421528e..e7cafbc37 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,7 @@ "scoped-http-client": "0.9.7", "log": "1.3.0", "connect": "2.1.0", - "connect_router": "1.8.6", - "underscore": "1.3.3" + "connect_router": "1.8.6" }, "main": "./index", diff --git a/src/scripts/google-images.coffee b/src/scripts/google-images.coffee index f6caaa1a7..8574d2c21 100644 --- a/src/scripts/google-images.coffee +++ b/src/scripts/google-images.coffee @@ -7,15 +7,13 @@ # hubot mustache me - Adds a mustache to the specified URL. # hubot mustache me - Searches Google Images for the specified query and mustaches it. -_ = require('underscore')._ - module.exports = (robot) -> robot.respond /(image|img)( me)? (.*)/i, (msg) -> imageMe msg, msg.match[3], (url) -> msg.send url - robot.respond /animate me (.*)/i, (msg) -> - imageMe msg, msg.match[1], as_filetype: "gif", (url) -> + robot.respond /animate( me)? (.*)/i, (msg) -> + imageMe msg, msg.match[2], true, (url) -> msg.send url robot.respond /(?:mo?u)?sta(?:s|c)he?(?: me)? (.*)/i, (msg) -> @@ -29,10 +27,12 @@ module.exports = (robot) -> imageMe msg, imagery, (url) -> msg.send "#{mustachify}#{url}" -imageMe = (msg, query, queryOptions, cb) -> - cb = queryOptions if typeof queryOptions == 'function' +imageMe = (msg, query, animated, cb) -> + cb = animated if typeof animated == 'function' + q = v: '1.0', rsz: '8', q: query, safe: 'active' + q.as_filetype = 'gif' if typeof animated is 'boolean' and animated is true msg.http('http://ajax.googleapis.com/ajax/services/search/images') - .query(_.extend({v: "1.0", rsz: '8', q: query, safe: 'active'}, queryOptions ? {})) + .query(q) .get() (err, res, body) -> images = JSON.parse(body) images = images.responseData.results