Skip to content

Instantly share code, notes, and snippets.

@jpalumickas
Forked from atmos/auto-stache.coffee
Created February 6, 2013 00:30
Show Gist options
  • Save jpalumickas/4719129 to your computer and use it in GitHub Desktop.
Save jpalumickas/4719129 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