Skip to content

Commit

Permalink
Remove underscore dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tombell committed Jun 22, 2012
1 parent d86f3dc commit 7974598
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions src/scripts/google-images.coffee
Expand Up @@ -7,15 +7,13 @@
# hubot mustache me <url> - Adds a mustache to the specified URL.
# hubot mustache me <query> - 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) ->
Expand All @@ -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
Expand Down

0 comments on commit 7974598

Please sign in to comment.