totem3
8/10/2014 - 1:39 AM

clojure.coffee

# Description:
#   clojure bot

https = require 'https'

module.exports = (robot) ->
  bot_url = process.env.HUBOT_CLOJUREBOT_URL
  bot_port = process.env.HUBOT_CLOJUREBOT_PORT
  robot.hear /^(\(.*\))$/ig, (msg) ->
    httprequest = msg.http("http://" + bot_url + ":" + bot_port)
    data = JSON.stringify({"events":[ {"message": {"text": msg.match[0]}} ]})
    try
      httprequest.post(data) (err, res, body) ->
        try
          msg.send body
        catch e
          console.log(err, body)
    catch e
      console.log e