I have tested it, but not on eggdrop, so there may still be a few oddities left.
Code: Select all
proc time:getrank {args} {
global clansys
if {![llength [info commands "::http::geturl"]]} {
if {[catch {package require http} ver]} {
putlog "Loading problem "${ver}""
return
} else {
putlog "Loaded http v${ver}"
}
}
set q [::http::formatQuery wars 1 cid 63888 lid 222]
::http::config -useragent "Eggdrop clan ranker"
set tok [::http::geturl http://www.clanbase.com/claninfo.php -query $q]
if {[::http::ncode $tok] != 200} {
set clansys 0
} else {
if {[regexp {Rank: (.*) ((.*) points)} [::http::data $tok] match rank points]} {
set clansys [list $rank $points [clock seconds]]
} else {
set clansys 0
}
}
::http::cleanup $tok
}
proc pub:getrank {nick uh hand chan arg} {
global clansys
if {$clansys == "0"} {
puthelp "PRIVMSG $chan :There was a problem last time I grabbed the rank - try again later"
return
}
set ts [expr [clock seconds] - [lindex $clansys 2]]
set t [expr $ts / 60] mins, [expr $ts % 60] seconds ago"
puthelp "PRIVMSG $chan :Clan : Rank: [lindex $clansys 0] Points: [lindex $clansys 1] Updated: $t"
}
bind time - "01 *" time:getrank
bind pub - "!clanrank" pub:getrank