Permalink
Browse files

require the callback, previous code didn't work

  • Loading branch information...
1 parent 7bc5d06 commit 5abab75e5db76ec6bfce4b3a82c5d95b7144eba7 @atmos atmos committed Aug 28, 2011
Showing with 9 additions and 5 deletions.
  1. +2 −0 README.md
  2. +6 −4 scripts/google-images.coffee
  3. +1 −1 test/robot_test.coffee
View
@@ -52,6 +52,8 @@ if you're having issues.
Local Testing
=============
+Install all of the required dependencies by running `npm install`
+
It's easy to test scripts locally with the shell:
% bin/hubot
@@ -9,18 +9,20 @@
# mustaches it.
module.exports = (robot) ->
robot.hear /(image|img)( me)? (.*)/i, (msg) ->
- imageMe msg, msg.match[3]
+ imageMe msg, msg.match[3], (url) ->
+ msg.send url
robot.hear /animate me (.*)/i, (msg) ->
- imageMe msg, "animated #{msg.match[1]}"
+ imageMe msg, "animated #{msg.match[1]}", (url) ->
+ msg.send url
robot.hear /(?:mo?u)?sta(?:s|c)he?(?: me)? (.*)/i, (msg) ->
imagery = msg.match[1]
if imagery.match /^https?:\/\//i
msg.send "#{mustachify}#{imagery}"
else
imageMe msg, imagery, (url) ->
- msg.send "#{mustachify}#{url}#.png"
+ msg.send "#{mustachify}#{url}"
mustachify = "http://mustachify.me/?src="
@@ -31,5 +33,5 @@ imageMe = (msg, query, cb) ->
images = JSON.parse(body)
images = images.responseData.results
image = msg.random images
- (cb || msg.send) "#{image.unescapedUrl}#.png"
+ cb "#{image.unescapedUrl}#.png"
View
@@ -25,6 +25,6 @@ server.listen 9001, ->
assert.equal 4, helper.sent.length
assert.equal 'fetched', helper.sent[3]
server.close()
-
+
helper.receive 'http'

0 comments on commit 5abab75

Please sign in to comment.