Code: Select all
proc time:getrank {min hour day mon year} {
global clansys
if {![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)} $line 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
This works coz 1 is allways 1.while (1) {
}