This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Getting a list from a Homepage

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
N
Nimos
Halfop
Posts: 80
Joined: Sun Apr 20, 2008 9:58 am

Getting a list from a Homepage

Post by Nimos »

is it possible to get THIS online list into the channel, by using egghttp or anything similiar?
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

Yes, egghttp, regexp stuff and make it list :-)
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: Getting a list from a Homepage

Post by speechles »

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.
N
Nimos
Halfop
Posts: 80
Joined: Sun Apr 20, 2008 9:58 am

Post by Nimos »

Well...this is the "Request" Forum, so could you make me the script? :P
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Nimos wrote:Well...this is the "Request" Forum, so could you make me the script? :P
Please Read Before Posting
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Nimos wrote:Well...this is the "Request" Forum, so could you make me the script? :P
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).
N
Nimos
Halfop
Posts: 80
Joined: Sun Apr 20, 2008 9:58 am

Post by Nimos »

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!
Example:

Someone: !online
Eggie: Online Players:
Eggie: person1, person2, person3
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

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
}
Edit: modified code to use while with regexp/regsub vs inline regexp.
Last edited by speechles on Sat May 31, 2008 5:27 am, edited 2 times in total.
N
Nimos
Halfop
Posts: 80
Joined: Sun Apr 20, 2008 9:58 am

Post by Nimos »

If I use !online, the bot says:

"Online players: <td class="name">mastre</td>, mastre"

( mastre was the first player in the list... )
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

use the modified code above.
N
Nimos
Halfop
Posts: 80
Joined: Sun Apr 20, 2008 9:58 am

Post by Nimos »

thank u! :D :D :D
M
Mogour
Voice
Posts: 17
Joined: Sun Feb 10, 2008 12:58 pm

Post by Mogour »

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.
N
Nimos
Halfop
Posts: 80
Joined: Sun Apr 20, 2008 9:58 am

Post by Nimos »

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?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

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: 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."
Setting 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
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 ;)
Last edited by speechles on Mon Oct 26, 2009 8:15 pm, edited 5 times in total.
h
haha456
Voice
Posts: 1
Joined: Sat Oct 04, 2008 4:44 pm

Post by haha456 »

when i use !online i get Tcl error [pub:online]: can't read "state(status)": no such variable @ party line.. the link is set to
http://www.game-monitor.com/sa-mp_GameS ... Clan..html

Can anyone help me?
Post Reply