http package or the egghttp script can be used. It's fairly simple. build a header regexp which will pull the info to display to begin with, the game name, server whatever. Then build an inline regexp and extract your playernames/scores to it. For output simply relay the gamename/server info, then use a foreach to step thru the playernames/scores list which the inline regexp created (in place of the inline regexp, can be used the while regexp/regsub method). Pretty basic stuff.Nimos wrote:is it possible to get THIS online list into the channel, by using egghttp or anything similiar?
Please Read Before PostingNimos wrote:Well...this is the "Request" Forum, so could you make me the script?
Without knowing 'what you want to display?', 'how you want it displayed?', 'seperate triggers for server info vs player info?', 'etc?', 'etc?' it is just a waste of my time. There is no clear goal.Nimos wrote:Well...this is the "Request" Forum, so could you make me the script?
Example:
Someone: !online
Eggie: Online Players:
Eggie: person1, person2, person3
Code: Select all
# put the url we are going to scrape here
variable online_url "http://www.game-monitor.com/sa-mp_GameServer/84.16.234.167:6666/GermanFunServer.html"
# put your channels here, seperate with spaces
variable online_chans "#yourchan #thischan #thatchan"
package require http
bind pub - !online pub:online
proc pub:online {nick host hand chan text} {
if {[lsearch -exact [split $::online_chans] $chan] == -1} {return}
set token [http::config -useragent "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e"]
catch {set token [http::geturl $::online_url -timeout 5000]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
puthelp "PRIVMSG $chan :Sorry, cannot create a socket to \"$::online_url\"."
return 0
} elseif {[::http::status $token] == "timeout"} {
puthelp "PRIVMSG $chan :Sorry, your request to \"$::online_url\" has timed out."
return 0
}
set html [http::data $token]
http::cleanup $token
regsub -all {(?:\t|\n|\r|\v)} $html "" html
set onames {}
while {[regexp -nocase {<td class="name">(.*?)</td>} $html - oname]} {
lappend onames $oname
regsub -nocase {<td class="name">} $html "" html
}
putserv "privmsg $chan :Online players: [join $onames ", "]"
return 1
}
Looks like it is because the url now redirects somewhere else so try this code instead.Nimos wrote:A new Problem appeared!
I used this script without changing something... from one day to another there was an error in partyline when using !online:
Tcl error [pub:online]: can't read "state(body)": no such variable
can someone help me?
Code: Select all
# Game-Monitor.com GameServer Scrape
# v1.0 - egghelp version yay!!
# put the url we are going to scrape here
variable online_url "http://www.game-monitor.com/sa-mp_GameServer/84.16.234.167:6666/GermanFunServer.html"
# put your channels here, seperate with spaces
variable online_chans "#yourchan #thischan #thatchan"
# -- script begins, changes aren't needed below here --
package require http
bind pub - !online pub:online
proc pub:online {nick host hand chan text} {
if {[lsearch -exact [split $::online_chans] $chan] == -1} {return}
set token [http::config -useragent "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e"]
catch {set token [http::geturl [set query $::online_url] -timeout 5000]} error
# errors and a redirect
if {![string match -nocase "::http::*" $error]} {
foreach line [split $error "\n"] {
putserv "privmsg $chan : $line"
}
return 0
} elseif {![string equal -nocase [::http::status $http] "ok"]} {
putserv "privmsg $chan :[string totitle [::http::status $http]] \( $query \)"
return 0
} elseif {[string match *[::http::ncode $token]* "301|302"]} {
upvar #0 $token state
foreach {name value} $state(meta) {
if {[regexp -nocase ^location$ $name]} {
catch {set token [::http::geturl "[set query $value]" -query "" -timeout 5000]} error
}
}
}
set html [http::data $token]
http::cleanup $token
regsub -all {(?:\t|\n|\r|\v)} $html "" html
if {[regexp -- {<div class="sumtitle">(.+?)</td></tr></table>} $html - i]} {
regsub -all {<b>|</b>} $i "\002" i
regsub -all {<td>| |<td colspan="2">} $i " | " i
regsub -all {<.*?>} $i "" i
putserv "privmsg $chan :$i"
}
set onames {}
while {[regexp -nocase {<td class="name">(.*?)</td>} $html - oname]} {
lappend onames $oname
regsub -nocase {<td class="name">} $html "" html
}
if {![llength $onames] } {
putserv "privmsg $chan :There are no online players, nobody is playing. :("
} else {
for {set x 0} {x < [llength $onames]} {incr x 8} {
putserv "privmsg $chan :Online players: [join [lrange $onames $x [expr {$x + 7}]] ", "]"
}
}
return 0
}
putlog "GameServer Scrape ready for action."
This is exactly how it should look on IRC. You can change the url to any of the other gameservers that site offers and it will work identically. Added a single redirect catch so now hopefully will get to the correct url before attempting to pull the page body.. which it appears to be doing now. EnjoySetting the variable 'online_url' to:
"http://www.game-monitor.com/sa-mp_GameS ... erver.html"
<speechles> !online
<bot> GermanFunServer | IP: 84.16.234.167:6666 | Players: 0/40 (average: 7.67) | Bots: 0 | Map: San Andreas (310) | Consecutive Failed: 0 / 30 | Game: San Andreas Multiplayer | Last Updated: 43s ago (cached: 0s) | Month Uptime: 89.8753% (3675 / 4089) | Last DB Update: 43s ago (last check: 0s) | Added: days ago
<bot> There are no online players, nobody is playing. :(
Setting the variable 'online_url' to:
"http://www.game-monitor.com/sa-mp_GameS ... SLT__.html"
<speechles> !online
<bot> | RUSSIAN SERVER | [RUS]/[LT] | | IP: 77.220.180.62:7777 | Players: 25/60 (average: 35.84) | Bots: 0 | Map: www.rsrl.ru (1) | Consecutive Failed: 0 / 30 | Game: San Andreas Multiplayer | Last Updated: 49s ago (cached: 25s) | Month Uptime: 93.6201% (3830 / 4091) | Last DB Update: 49s ago (last check: 25s) | Added: days ago
<bot> Online players: K2_KORSAR, Kain, RuSsiAn_Pimp, VAV, Sandra_K, XISHNIK, Gagarin1964, [AZTEC]MC, DJ_Energi, _Dim_, [AstroD]Lexa, ba9n, Kilimangaro, GreeNShark, [DVpro]DSLX5, [PRoFFI]_Cat, [RV]1KlaSS, [Redman], Bi_Gear, KloUngGM, [ALN]SectoR, Hacker, BOSSS, [SR]Splinter, RimasLT