| View previous topic :: View next topic |
| Author |
Message |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Fri May 30, 2008 8:52 am Post subject: Getting a list from a Homepage |
|
|
| is it possible to get THIS online list into the channel, by using egghttp or anything similiar? |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Fri May 30, 2008 3:03 pm Post subject: |
|
|
Yes, egghttp, regexp stuff and make it list  |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri May 30, 2008 4:45 pm Post subject: Re: Getting a list from a Homepage |
|
|
| Nimos wrote: | | is it possible to get THIS online list into the channel, by using egghttp or anything similiar? |
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. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Fri May 30, 2008 5:43 pm Post subject: |
|
|
Well...this is the "Request" Forum, so could you make me the script?  |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Fri May 30, 2008 9:32 pm Post subject: |
|
|
| Nimos wrote: | Well...this is the "Request" Forum, so could you make me the script?  |
Please Read Before Posting _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat May 31, 2008 12:43 am Post subject: |
|
|
| Nimos 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.
If you leave your request open ended and completely vague, the help you desire simply won't. I can tell you how to do it yourself, but without knowing how it should work, it simply won't. If your request involves tons of work, this makes it less likely to happen and won't get realized. So keep your request simple at first, solicit your inital request, and wait for it hopefully to be realized. Once you accomplish this step (realization), you can further amend your request to address shortcomings/additions (refinement). _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Sat May 31, 2008 2:50 am Post subject: |
|
|
ok! I just want a script, with a pub trigger maybe !online , which makes the bot output the Player Names in the list ( this link!) to the channel!
| Quote: |
Example:
Someone: !online
Eggie: Online Players:
Eggie: person1, person2, person3
|
|
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat May 31, 2008 3:21 am Post subject: |
|
|
| Code: | # 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
} |
Edit: modified code to use while with regexp/regsub vs inline regexp. _________________ speechles' eggdrop tcl archive
Last edited by speechles on Sat May 31, 2008 5:27 am; edited 2 times in total |
|
| Back to top |
|
 |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Sat May 31, 2008 5:06 am Post subject: |
|
|
If I use !online, the bot says:
"Online players: <td class="name">mastre</td>, mastre"
( mastre was the first player in the list... ) |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
|
| Back to top |
|
 |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Sat May 31, 2008 7:07 am Post subject: |
|
|
thank u!  |
|
| Back to top |
|
 |
Mogour Voice
Joined: 10 Feb 2008 Posts: 17
|
Posted: Sun Jun 29, 2008 10:14 am Post subject: |
|
|
Nice script .
It would be nice to look up players, like:
<User:> !info Test
<Bot:> Test is currently playing - Score: 88692
<User:> !info Test2
<Bot:> Test2 is currently not playing.
I hope someone can help me with that. |
|
| Back to top |
|
 |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Sun Jul 27, 2008 7:16 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
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 |
|
 |
|