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.

Revisions

  1. atmos created this gist Oct 25, 2011.
    16 changes: 16 additions & 0 deletions auto-stache.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # 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}"