Code: Select all
proc bcp { min hour day month weekday } {
set query "https://api.bitcoinaverage.com/ticker/global/USD/"
::http::register https 443 [list ::tls::socket -require 0 -request 1]
http::config -useragent {Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)}
set token [http::geturl $query -timeout 6000]
set rawData [http::data $token]
http::cleanup $token
regexp -nocase {"24h_avg":([^\,]*)} $rawData noop avg
regexp -nocase {"ask":([^\,]*)} $rawData noop ask
regexp -nocase {"bid":([^\,]*)} $rawData noop bid
regexp -nocase {"last":([^\,]*)} $rawData noop last
regexp -nocase {"timestamp":\s?"([^\"]*)} $rawData noop timestamp
putserv "PRIVMSG $channel :\0030,12BITCOIN\017\00303 24hr Average\017 \002$avg\017 |\00312 Last \017\002$last\017 |\00303 Bid \017\002$bid\017 |\00304 Ask \017\002$ask\017 | $timestamp"
}