Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Grab the session ID from the response.

This will allow for persistent function and var definitions.
  • Loading branch information...
commit a17779cc99df4252ddd7977ccb6f219fddeeee0b 1 parent f511837
Steven Merrill smerrill authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/scripts/clojure.coffee
10 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
Please sign in to comment.
Something went wrong with that request. Please try again.