| View previous topic :: View next topic |
| Author |
Message |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Mon Jul 28, 2008 12:06 am Post subject: |
|
|
| 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? |
Looks like it is because the url now redirects somewhere else so try this code instead. | Code: | # 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." |
| Quote: | Setting the variable 'online_url' to:
"http://www.game-monitor.com/sa-mp_GameServer/84.16.234.167:6666/GermanFunServer.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_GameServer/77.220.180.62:7777/__RUSSIAN_SERVER__RUSLT__.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 |
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. Enjoy
Edit(10-26-2009): Condensed entire script and corrected a few long outstanding bugs. Should work as promised  _________________ speechles' eggdrop tcl archive
Last edited by speechles on Mon Oct 26, 2009 8:15 pm; edited 5 times in total |
|
| Back to top |
|
 |
haha456 Voice
Joined: 04 Oct 2008 Posts: 1
|
|
| Back to top |
|
 |
lenooxx Voice
Joined: 24 Mar 2009 Posts: 27 Location: Hungarian
|
Posted: Fri Oct 23, 2009 10:35 am Post subject: helloe |
|
|
| Tcl error [pub:online]: can't read "http": no such variable |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Mon Oct 26, 2009 8:14 pm Post subject: Re: helloe |
|
|
| lenooxx wrote: | | Tcl error [pub:online]: can't read "http": no such variable |
I updated my older post, see here..  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|