From ac66b805ed07c7d487816a371706c06787817a71 Mon Sep 17 00:00:00 2001 From: CSNAE Date: Fri, 19 Sep 2014 21:33:37 -0400 Subject: [PATCH 1/2] Small improvements Network queries no longer end in a dash if blocks remaining to next retarget >= 660 Allow users to query for just polo or just bittrex to avoid spam (or both via 'market') Allow first letter to be capitalized in queries and still recognized (Good for mobile users whose devices autocapitalize the first letter) --- scripts/bitmark.coffee | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/scripts/bitmark.coffee b/scripts/bitmark.coffee index f1f9154..8b7657b 100644 --- a/scripts/bitmark.coffee +++ b/scripts/bitmark.coffee @@ -8,7 +8,7 @@ # address
- get btm address info module.exports = (robot) -> - robot.hear /^(network|net)$/i, (msg) -> + robot.hear /^(network|net|Network|Net)$/i, (msg) -> robot.http("http://bitmark.co/statistics/data/livesummary.json") .get() (err, res, body) -> json = JSON.parse(body) @@ -39,18 +39,18 @@ module.exports = (robot) -> net += "Diff: #{json.data.current.difficulty} - " net += "Target: #{target} - " net += "Hashrate: #{hl} #{hm} #{hs} MH/s - " - net += "Change: #{change} (Approx #{timetoretarget}) - " - net += "Performance: #{performance}% - " if change < 660 + net += "Change: #{change} (Approx #{timetoretarget})" + net += " - Performance: #{performance}% - " if change < 660 net += "Next Diff: ~#{nextdiff} (confidence #{confidence}%)" if change < 660 msg.send net - robot.hear /^(address) b([\w\S]+)$/i, (msg) -> + robot.hear /^(address|Address) b([\w\S]+)$/i, (msg) -> checkAddress msg, "b#{msg.match[2]}" - robot.hear /^(address) foundation$/i, (msg) -> + robot.hear /^(address|Address) foundation$/i, (msg) -> checkAddress msg, "bQmnzVS5M4bBdZqBTuHrjnzxHS6oSUz6cG" - robot.hear /^(supply)$/i, (msg) -> + robot.hear /^(supply|Supply)$/i, (msg) -> robot.http("http://bitmark.co/statistics/data/livesummary.json") .get() (err, res, body) -> json = JSON.parse(body) @@ -62,16 +62,39 @@ module.exports = (robot) -> net += "there is #{diff} less BTM in the world" msg.send net - robot.hear /^(market|markets|polo)$/i, (msg) -> + robot.hear /^(polo|Polo|poloniex|Poloniex)$/i, (msg) -> robot.http("https://poloniex.com/public?command=returnTicker") .get() (err, res, body) -> json = JSON.parse(body) btm = json.BTC_BTM pc = Math.round(btm.percentChange * 100, 2) price = "*POLO*: Last: #{btm.last} - " - price += "Volume: #{btm.baseVolume} BTC / #{btm.quoteVolume} BTM - " + price += "Volume: #{btm.baseVolume} BTC / #{btm.quoteVolume} BTM " vwa = (btm.baseVolume/btm.quoteVolume).toFixed(8) - price += "VWAP: #{vwa}\n" + price += " - VWAP: #{vwa}\n" + msg.send price + + robot.hear /^(trex|Trex|bittrex|Bittrex)$/i, (msg) -> + robot.http("https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-btm") + .get() (err, res, body) -> + json = JSON.parse(body) + btm = json.result[0] + price = "*BITT*: Last: #{btm.Last} - " + price += "Volume: #{btm.BaseVolume} BTC / #{btm.Volume} BTM" + vwa = (btm.BaseVolume/btm.Volume).toFixed(8) + price += " - VWAP: #{vwa}\n" + msg.send price + + robot.hear /^(market|Market|markets|Markets)$/i, (msg) -> + robot.http("https://poloniex.com/public?command=returnTicker") + .get() (err, res, body) -> + json = JSON.parse(body) + btm = json.BTC_BTM + pc = Math.round(btm.percentChange * 100, 2) + price = "*POLO*: Last: #{btm.last} - " + price += "Volume: #{btm.baseVolume} BTC / #{btm.quoteVolume} BTM" + vwa = (btm.baseVolume/btm.quoteVolume).toFixed(8) + price += " - VWAP: #{vwa}\n" msg.send price robot.http("https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-btm") .get() (err, res, body) -> From 949eace84a76e54a8166d639dc9b14d93772ab55 Mon Sep 17 00:00:00 2001 From: CSNAE Date: Sat, 20 Sep 2014 23:52:24 -0400 Subject: [PATCH 2/2] Update bitmark.coffee --- scripts/bitmark.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/bitmark.coffee b/scripts/bitmark.coffee index 8b7657b..9dc23ed 100644 --- a/scripts/bitmark.coffee +++ b/scripts/bitmark.coffee @@ -8,7 +8,7 @@ # address
- get btm address info module.exports = (robot) -> - robot.hear /^(network|net|Network|Net)$/i, (msg) -> + robot.hear /^(network|net)$/i, (msg) -> robot.http("http://bitmark.co/statistics/data/livesummary.json") .get() (err, res, body) -> json = JSON.parse(body) @@ -44,10 +44,10 @@ module.exports = (robot) -> net += "Next Diff: ~#{nextdiff} (confidence #{confidence}%)" if change < 660 msg.send net - robot.hear /^(address|Address) b([\w\S]+)$/i, (msg) -> + robot.hear /^(address) b([\w\S]+)$/i, (msg) -> checkAddress msg, "b#{msg.match[2]}" - robot.hear /^(address|Address) foundation$/i, (msg) -> + robot.hear /^(address) foundation$/i, (msg) -> checkAddress msg, "bQmnzVS5M4bBdZqBTuHrjnzxHS6oSUz6cG" robot.hear /^(supply|Supply)$/i, (msg) -> @@ -62,7 +62,7 @@ module.exports = (robot) -> net += "there is #{diff} less BTM in the world" msg.send net - robot.hear /^(polo|Polo|poloniex|Poloniex)$/i, (msg) -> + robot.hear /^(polo|poloniex)$/i, (msg) -> robot.http("https://poloniex.com/public?command=returnTicker") .get() (err, res, body) -> json = JSON.parse(body) @@ -74,7 +74,7 @@ module.exports = (robot) -> price += " - VWAP: #{vwa}\n" msg.send price - robot.hear /^(trex|Trex|bittrex|Bittrex)$/i, (msg) -> + robot.hear /^(trex|bittrex)$/i, (msg) -> robot.http("https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-btm") .get() (err, res, body) -> json = JSON.parse(body) @@ -85,7 +85,7 @@ module.exports = (robot) -> price += " - VWAP: #{vwa}\n" msg.send price - robot.hear /^(market|Market|markets|Markets)$/i, (msg) -> + robot.hear /^(market|markets)$/i, (msg) -> robot.http("https://poloniex.com/public?command=returnTicker") .get() (err, res, body) -> json = JSON.parse(body)