Permalink
Browse files

Grab the session ID from the response.

This will allow for persistent function and var definitions.
  • Loading branch information...
1 parent f511837 commit a17779cc99df4252ddd7977ccb6f219fddeeee0b @smerrill smerrill committed Aug 6, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/scripts/clojure.coffee
View
@@ -13,14 +13,20 @@
# Author:
# jingweno
+ringSessionID = ''
+
module.exports = (robot) ->
robot.respond /(clojure|clj)\s+(.*)/i, (msg)->
- script = encodeURIComponent(msg.match[2])
+ script = msg.match[2]
- msg.http("http://tryclj.com/eval.json?expr=#{script}")
+ msg.http("http://tryclj.com/eval.json")
+ .query(expr: script)
+ .headers(Cookie: "ring-session=#{ringSessionID}")
.get() (err, res, body) ->
switch res.statusCode
when 200
+ if res.headers["set-cookie"]
+ ringSessionID = res.headers["set-cookie"][0].match(/ring-session=([-a-z0-9]+);/)[1]
result = JSON.parse(body)
if result.error

0 comments on commit a17779c

Please sign in to comment.