Skip to content

Instantly share code, notes, and snippets.

@atmos
Created October 25, 2011 21:34
Show Gist options
  • Save atmos/1314377 to your computer and use it in GitHub Desktop.
Save atmos/1314377 to your computer and use it in GitHub Desktop.
# Automatically add mustaches to any images it can
#
#
module.exports = (robot) ->
robot.hear /^(https?:\/\/[^ #]+\.(?:png|jpg|jpeg))(?:[#]\.png)?$/i, (msg) ->
src = msg.match[1]
unless src.match(/^http:\/\/mustachify.me/)
msg.http("http://stacheable.herokuapp.com")
.query(src: src)
.get() (err, res, body) ->
img = JSON.parse body
if img.count > 0
msg.send "http://mustachify.me/?src=#{escape img.src}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment