Code: Select all
package require http
package require tls
http::register https 443 [list ::tls::socket -require 0 -request 1]
proc s:wget { url } {
http::config -useragent "Mozilla/EggdropWget"
catch {set token [http::geturl $url -binary 1 -timeout 10000]} error
if {![string match -nocase "::http::*" $error]} {
s:debug "Error: [string totitle [string map {"\n" " | "} $error]] \( $url \)"
return 0
}
if {![string equal -nocase [::http::status $token] "ok"]} {
s:debug "Http error: [string totitle [::http::status $token]] \( $url \)"
http::cleanup $token
return 0
}
if {[string match "*[http::ncode $token]*" "303|302|301" ]} {
upvar #0 $token state
foreach {name value} $state(meta) {
if {[regexp -nocase ^location$ $name]} {
if {![string match "http*" $value]} {
if {![string match "/" [string index $value 0]]} {
set value "[join [lrange [split $url "/"] 0 2] "/"]/$value"
} else {
set value "[join [lrange [split $url "/"] 0 2] "/"]$value"
}
}
s:wget $value
return
}
}
}
if {[string match 4* [http::ncode $token]] || [string match 5* [http::ncode $token]]} {
s:debug "Http resource is not evailable: [http::ncode $token] \( $url \)"
return 0
}
set data [http::data $token]
http::cleanup $token
return $data
}
bind pub - !btc get_bitcoin
proc get_bitcoin {nick uhost handle chan arg} {
set data2 [s:wget https://mtgox.com/api/0/data/ticker.php]
set btc [regexp {high\":(.*?),\"low\":(.*?),\"avg\":(.*?),\"vwap\":.*?,\"vol\":(.*?),\"last_all\":.*?,\"last_local\":.*?,\"last\":.*?,\"buy\":(.*?),\"sell\":(.*?)\}} $data2 match btchigh btclow btcavg btcvol btcbuy btcsell]
putserv "PRIVMSG $chan :\002Bitcoin Market Data\002 (MtGox): High: \$$btchigh Low: \$$btclow Volume: $btcvol Buy: \$$btcbuy Sell: \$$btcsell"
}
i am also getting tls error any one will help ?khalidxpert wrote:hi there
i am getting error tls please help me to install bitcoin.tcl how i can fix tls problem
https://www.coingecko.comcaesar wrote:There's nothing that can be fixed at this moment since mtgox.com is down. Find another website that offers this service and we can take it from there.