· 7 years ago · Mar 06, 2018, 02:42 PM
1spun = (msg) ->
2 timestamp = gmdatenow()
3 signature = get_signature(host, path, secret_key, access_key, timestamp, version)
4 msg.http(scheme + "://" + host + path)
5 .query
6 type: 'json'
7 .post(msg.match[1]) (err, res, body) ->
8 if err
9 msg.send err
10 else if res.statusCode is not 200
11 msg.send "Service not available! Status code: " + res.statusCode
12 else
13 # set to the memory so user can spin it with separate "spin the last spun" command
14 body = JSON.parse(body)
15 if body.response is 'error'
16 msg.send body.message
17 msg.send body.data
18 else
19 msg.send body.message
20 body.message