egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting a list from a Homepage
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Nimos
Halfop


Joined: 20 Apr 2008
Posts: 80

PostPosted: Fri May 30, 2008 8:52 am    Post subject: Getting a list from a Homepage Reply with quote

is it possible to get THIS online list into the channel, by using egghttp or anything similiar?
Back to top
View user's profile Send private message
ztian299
Halfop


Joined: 19 Apr 2008
Posts: 59
Location: *.no

PostPosted: Fri May 30, 2008 3:03 pm    Post subject: Reply with quote

Yes, egghttp, regexp stuff and make it list Smile
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri May 30, 2008 4:45 pm    Post subject: Re: Getting a list from a Homepage Reply with quote

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
View user's profile Send private message
Nimos
Halfop


Joined: 20 Apr 2008
Posts: 80

PostPosted: Fri May 30, 2008 5:43 pm    Post subject: Reply with quote

Well...this is the "Request" Forum, so could you make me the script? Razz
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Fri May 30, 2008 9:32 pm    Post subject: Reply with quote

Nimos wrote:
Well...this is the "Request" Forum, so could you make me the script? Razz

Please Read Before Posting
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat May 31, 2008 12:43 am    Post subject: Reply with quote

Nimos wrote:
Well...this is the "Request" Forum, so could you make me the script? Razz

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
View user's profile Send private message
Nimos
Halfop


Joined: 20 Apr 2008
Posts: 80

PostPosted: Sat May 31, 2008 2:50 am    Post subject: Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat May 31, 2008 3:21 am    Post subject: Reply with quote

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
View user's profile Send private message
Nimos
Halfop


Joined: 20 Apr 2008
Posts: 80

PostPosted: Sat May 31, 2008 5:06 am    Post subject: Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat May 31, 2008 5:22 am    Post subject: Reply with quote

use the modified code above.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Nimos
Halfop


Joined: 20 Apr 2008
Posts: 80

PostPosted: Sat May 31, 2008 7:07 am    Post subject: Reply with quote

thank u! Very Happy Very Happy Very Happy
Back to top
View user's profile Send private message
Mogour
Voice


Joined: 10 Feb 2008
Posts: 17

PostPosted: Sun Jun 29, 2008 10:14 am    Post subject: Reply with quote

Nice script Smile.

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
View user's profile Send private message
Nimos
Halfop


Joined: 20 Apr 2008
Posts: 80

PostPosted: Sun Jul 27, 2008 7:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon Jul 28, 2008 12:06 am    Post subject: Reply with quote

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>|&nbsp;|<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 Wink

Edit(10-26-2009): Condensed entire script and corrected a few long outstanding bugs. Should work as promised Wink
_________________
speechles' eggdrop tcl archive


Last edited by speechles on Mon Oct 26, 2009 8:15 pm; edited 5 times in total
Back to top
View user's profile Send private message
haha456
Voice


Joined: 04 Oct 2008
Posts: 1

PostPosted: Sat Oct 04, 2008 4:46 pm    Post subject: Reply with quote

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_GameServer/78.111.75.182:7777/GermanStuntServer_.by_TST_Clan..html

Can anyone help me?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber