Obviously, it needs to make updates based on that web page.
So...
Doing !topscorer 1-2 would give you:
Top Scorer | Team | Prem | CC | FA | UEFA | CL | Other | Total
Nicolas Anelka | Chelsea | 15 | 0 | 4 | 0 | 2 | 0 | 21
Steven Gerrard | Liverpool | 9 | 0 | 1 | 0 | 5 | 0 | 15
script requires http package which should be available by default on eggdrops, but not windrops.
script requires +football flag setting in partyline for channel(s) you require it to function in, for example as follows :-
.chanset #eggTCL +football
as it stands, the script outputs text embelished with colour so the network/channel must allow it. for example a channel setting of +c on dalnet would prevent it working.
syntax is !topscorer <non-zero integer> ?non-zero integer?
package require http
setudef flag football
set vTimeout 10
set vUrl http://www.4thegame.com/football-statistics/premiership/topscorers/
bind PUB - !topscorer pTopScorer
proc pTopScorer {nick uhost hand channel txt} {
global vTimeout vUrl
if {[channel get $channel football]} {
set arguments [string trim $txt]
set args_len [llength [split $arguments]]
if {$args_len == 1} {
if {[regexp {^[1-9]+\-[1-9]+$} $arguments]} {
set arg_split [split $arguments "-"]
set min [lindex $arg_split 0]
set max [lindex $arg_split 1]
} {
set min $arguments
set max $arguments
}
} {
set arg_split [split $arguments]
set min [lindex $arg_split 0]
set max [lindex $arg_split 1]
}
if {([regexp {^[1-9][0-9]*$} $min]) && ([regexp {^[1-9][0-9]*$} $max])} {
set agent [::http::config -useragent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"]
if {![catch {set http [::http::geturl $vUrl -timeout [expr {$vTimeout * 1000}]]}]} {
switch -- [::http::status $http] {
"timeout" {putserv "PRIVMSG $channel :attempt to scrape $vUrl timed out after $vTimeout seconds"}
"error" {putserv "PRIVMSG $channel :attempt to scrape $vUrl returned error [::http::error $http]"}
"ok" {
switch -- [::http::ncode $http] {
200 {
regexp -- {wastarget="_blank">(.+?)<br>Prem} [::http::data $http] -> table
if {[info exists table]} {
set table [regsub -all -- {<[^>]+>} $table " "]; set table [regsub -all -- {[\n]} $table ""]
set table [regsub -all -- {[\s]{5}} $table \n]; set table [regsub -all -- {[\s]{2}\*} $table ""]
set table [regsub -all -- {[\s]{2,4}} $table |]
set playerlist [split $table \n]
set count 0
foreach line $playerlist {
set itemlist [split $line |]
if {[llength $itemlist] != 0} {
incr count
set player($count) [lindex $itemlist 0]; set team($count) [lindex $itemlist 1]
set prem($count) [lindex $itemlist 2]; set cc($count) [lindex $itemlist 3]
set fa($count) [lindex $itemlist 4]; set uefa($count) [lindex $itemlist 5]
set cl($count) [lindex $itemlist 6]; set other($count) [lindex $itemlist 7]
set total($count) [lindex $itemlist 8]
}
}
switch -- $count {
0 {putserv "PRIVMSG $channel :top score table found from $vUrl but empty"}
default {
if {[expr {$min <= $max}]} {
if {[expr {$min <= $count}]} {
for {set loop $min} {$loop <= $max} {incr loop} {
if {[info exists player($loop)]} {
lappend outputlist \00312$player($loop)\003 ($team($loop)) Premier League ($prem($loop))
lappend outputlist Carling Cup ($cc($loop)) FA Cup ($fa($loop)) UEFA Cup ($uefa($loop))
lappend outputlist Champions League ($cl($loop)) Other ($other($loop)) Total ($total($loop))
set output [regsub -all -- {\(} [join $outputlist] \(\00314]
set output [regsub -all -- {\)} $output \003\)]
putserv "PRIVMSG $channel :$output"
unset outputlist
}
}
} else {putserv "PRIVMSG $channel :results from $vUrl do not include top scorer $min onwards"}
} else {putserv "PRIVMSG $channel :the first argument must be equal to or less than any second argument"}
}
}
} else {putserv "PRIVMSG $channel :top score table not found from $vUrl"}
}
default {putserv "PRIVMSG $channel :attempt to scrape $vUrl returned ncode [::http::ncode $http]"}
}
}
}
::http::cleanup $http
} else {putserv "PRIVMSG $channel :attempted connection to $vUrl failed"}
} else {putserv "PRIVMSG $channel :correct syntax is !topscorer <non-zero integer> ?integer?"}
}
return 0
}