package require http package require json bind pub - !gw2 pub:gw2Stats proc pub:gw2Stats { nick uhost handle channel arg } { set urlMatch "http://gw2stats.net/api/matches.json" set urlRank "http://gw2stats.net/api/ratings.json" set jsonMatch [http::data [http::geturl $urlMatch]] set jsonRank [http::data [http::geturl $urlRank]] set apiMatch [json::json2dict $jsonMatch] set apiRank [json::json2dict $jsonRank] namespace eval gw2Utils { set tsvPath "tsvgw2/" proc parsePairs { tsvName } { set f [open [file nativename $gw2Utils::tsvPath$tsvName] r] while { [eof $f] == 0 } { set splitLine [split [gets $f] "\t"] set pairMap([lindex $splitLine 0]) [lindex $splitLine 1] } return [array get pairMap] } proc insertCommas { num {sep ,} } { while { [regsub {^([-+]?\d+)(\d\d\d)} $num "\\1$sep\\2" num] } {} return $num }