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.

ppslim, can u make this script now?

Old posts that have not been replied to for several years.
C
Commari

Post by Commari »

hey, I decided to change the URL of the script I asked.
It's now
http://www.clanbase.com/claninfo.php?wa ... 88&lid=222
And the script should fetch POINTS of that clan and RANK.

Thx
B
BassTeQ

Post by BassTeQ »

How about saying 'PLEASE' ??
C
Commari

Post by Commari »

lol m8 :smile:
I previously asked that script from ppslim :smile:
I just announced that there's info on that page now.

(Please)

:grin:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

To be perfectly honest, I don't understand the output on that page.

I can see a points system, but I can't see any rank.
E
Errtu

Post by Errtu »

Rank: 198 (1062 points)

Unfortunately i have no idea how to do that with tcl only. I could do it using a bash script with a wget and some awk commands, store the 198 and 1062 in a file and let the tcl script read those values, but i'm curious to see how all this could be done with just tcl.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

/me slaps /me with a extra large trout.

I will look into it in the morning. Friday nights are not my best moments (just read my signature, and forget the joke portion).
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

OK - while looking into it (yes, while drunk), I found I needed to get some help on this one.

I can make the basic script, but the bit that gets the details, will be a "regular expression".

Or to me, a NIGHTMARE.

If some 1 can into some way, make a regexp that can extract the rank and points out of this string, it would be perfect.

"<div class='default'>Rank: 198 (1062 points) - <a "
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Try

regexp {Rank: (.*) ((.*) points} $line match rank points

Hope it helps
C
Commari

Post by Commari »

lol @ ppslim :wink:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

What, so I needed help. To be honest, I hate regexp. I used to know perl very well, but game up because more of it's power is regexps.

Anyhow, here is the script, untested.

Code: Select all

proc time:getrank {min hour day mon year} {
  global clansys
  if {![info commands "::http::geturl"]} {
    if {[catch {package require http} ver]} {
      putlog "Loading problem "${ver}""
      return
    } else {
      putlog "Loaded http v${ver}"
    }
  }
  set q [::http::formatquery wars 1 cid 63888 lid 222]
  ::http::config -useragent "Eggdrop clan ranker"
  set tok [::http::geturl http://www.clanbase.com/claninfo.php -query $q]
  if {[::http::ncode $tok] != 200} {
    set clansys 0
  } else {
    if {[regexp {Rank: (.*) ((.*) points)} $line match rank points]} {
      set clansys [list $rank $points [clock seconds]]
    } else {
      set clansys 0
    }
  }
  ::http::cleanup $tok
}

proc pub:getrank {nick uh hand chan arg} {
  global clansys
  if {$clansys == "0"} {
    puthelp "PRIVMSG $chan :There was a problem last time I grabbed the rank - try again later"
    return
  }
  set ts [expr [clock seconds] - [lindex $clansys 2]]
  set t [expr $ts / 60] mins, [expr $ts % 60] seconds ago"
  puthelp "PRIVMSG $chan :Clan : Rank: [lindex $clansys 0] Points: [lindex $clansys 1] Updated: $t"
}
bind time - "01 *" time:getrank
bind pub - "!clanrank" pub:getrank
It will grab the rank and points every hour, saving cpu usage and time. Every time it updates, the eggdrop will lock a few seconds, while it downloads the page, this methods saves it having to lock every time.

The code is untested, allthough, I have made a few small tests.
C
Commari

Post by Commari »

Thx ppslim :smile:
I'll test that right away. (hope it works)
And what do u mean by that my eggdrop will lock? Like freeze, like u can't do anything when it locks?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

OK, to explain (in a basic way) how eggdrop works.

Eggdrop (and other software that runs over and over) runs in a loop

EG
while (1) {

}
This works coz 1 is allways 1.

The code that runs between the {} is run over and over. If everything is taken care of, then you get smooth running automatic software.

The problem with this script is, somwhere in that loop, the timer will be called. The TCL http package will basicaly create it's own loop (there are ways around it, but they are long winded, and not needed).

While it is stuck in this loop, eggdrops own loop is locked in one place until TCL finishes it's own loop. After X seconds (the time it take to download the webpage), TCL will complete, and eggdrops loop will continue.

Any network trafic (IRC, botnet) received during this lock will then be processed.

So, while eggdrop is downloading the page, it will not respond. After it is finished downloading, any commands that you are waiting to complete, will do so at this time.
C
Commari

Post by Commari »

Bad news: the script isn't working at all :sad:
I typed !clanrank @ #clan.rok , but nothing happened.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Check your logs, there should be some sort of error.

If no error, there should be some sort of garbled output while typing !getrank.

Where abouts did you type "!getrank"?
C
Commari

Post by Commari »

Umm, I checked my logs, and I found this:
[12:01] TCL error [time:getrank]: can't use empty string as operand of "!"
It's in there many times...
What to do?
Locked