Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
28 lines (24 sloc) 0.585 kb
# Description:
# Automatically add mustaches to any images it can
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# None
#
# Author:
# atmos
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}"
Jump to Line
Something went wrong with that request. Please try again.