Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

require the callback, previous code didn't work

  • Loading branch information...
commit 5abab75e5db76ec6bfce4b3a82c5d95b7144eba7 1 parent 7bc5d06
@atmos atmos authored
View
2  README.md
@@ -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
View
10 scripts/google-images.coffee
@@ -9,10 +9,12 @@
# 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]
@@ -20,7 +22,7 @@ module.exports = (robot) ->
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
2  test/robot_test.coffee
@@ -25,6 +25,6 @@ server.listen 9001, ->
assert.equal 4, helper.sent.length
assert.equal 'fetched', helper.sent[3]
server.close()
-
+
helper.receive 'http'
Please sign in to comment.
Something went wrong with that request. Please try again.