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.

>> Hard MIRC -> TCL Script Conversion <<

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

>> Hard MIRC -> TCL Script Conversion <<

Post by Hamish »

Hi, I have another script request... I think this one is quite hard...
If anyone can manage it I am very thankful. :)

Code: Select all

alias stats { 
  if ($1) { 
    /var %i 1 

    while ($sock(stats. $+ %i)) { 
      /inc %i 
    } 

    /set %stats. $+ %i $+ .user $1- 
    /set %stats. $+ %i $+ .self 1 

    /sockopen stats. $+ %i hiscore.runescape.com 80 
  } 
} 

#stats on 
on *:TEXT:!stats *:*:{ 
  if ($2) { 
    /var %i 1 

    while ($sock(stats. $+ %i)) { 
      /inc %i 
    } 

    /set %stats. $+ %i $+ .user $2- 

    if ($chan) { 
      /set %stats. $+ %i $+ .target $chan 
    } 
    else { 
      /set %stats. $+ %i $+ .target $nick 
    } 

    /sockopen stats. $+ %i hiscore.runescape.com 80 
  } 
} 
#stats end 

on *:SOCKOPEN:stats.*:{ 
  /sockwrite -t $sockname GET /lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ $eval(% $+ $sockname $+ .user, 2) HTTP/1.1 $+ $crlf 
  /sockwrite -t $sockname Host: hiscore.runescape.com $+ $crlf 
  /sockwrite -t $sockname $crlf 
} 

on *:SOCKREAD:stats.*:{ 
  if ($sockerr) { 
    if ($eval(% $+ $sockname $+ .self, 2)) { 
      /echo -s Socket error while looking up $eval(% $+ $sockname $+ .user, 2) $+ : $sockerr 
    } 
    else { 
      /msg $eval(% $+ $sockname $+ .target, 2) Socket error while looking up $eval(% $+ $sockname $+ .user, 2) $+ : $sockerr 
    } 

    /cleanup $sockname 
  } 
  else { 
    /sockread &read 
    /bwrite $sockname -1 -1 &read 

    if ($bfind(&read, 1, </html>).text) { 
      /results $sockname 
    } 
  } 
} 

on *:SOCKCLOSE:stats.*:{ 
  /cleanup $sockname 
} 

alias -l results { 
  if ($1) { 
    /bread $1 1 $file($1).size &statspage 

    /var %statsstring $chr(91) 04 $+ $upper($eval(% $+ $1 $+ .user, 2)) $+  $chr(93) $+ : 

    if ($bfind(&statspage, 1, does not feature in the hiscores.).text) { 
      %statsstring = %statsstring does not feature in the hiscores. 
    } 
    else { 
      /var %currentstat 
      /var %i 0 

      while (1) { 
        %i = $bfind(&statspage, $calc(%i + 1), <td align="left"><a href="overall.ws?table=).text 

        if (!%i) { 
          /break 
        } 

        %currentstat = $striphtml($bvar(&statspage, %i, 150).text) 
        if ($gettok(%currentstat, 3, 32)) { 
          %statsstring = %statsstring $gettok(%currentstat, 1, 32) 02 $+ $gettok(%currentstat, 3, 32) $+  $chr(124) 
        } 
      } 

      %statsstring = $left(%statsstring, -2) 
    } 

    if ($eval(% $+ $1 $+ .self, 2)) { 
      /echo -s %statsstring 
    } 
    else { 
      /msg $eval(% $+ $1 $+ .target, 2) %statsstring 
    } 

    /cleanup $1 
  } 
} 

alias -l striphtml { 
  /var %charcount 1 
  /var %tag 0 
  /var %strippedstring 

  while (%charcount <= $len($1-)) { 
    if ($mid($1-, %charcount, 1) == <) { 
      %tag = 1 
    } 
    elseif ($mid($1-, %charcount, 1) == >) { 
      %tag = 0 
    } 
    elseif (!%tag) { 
      if ($mid($1-, %charcount, 1) == $chr(32)) { 
        %strippedstring = %strippedstring $chr(32) 
      } 
      else { 
        %strippedstring = %strippedstring $+ $mid($1-, %charcount, 1) 
      } 
    } 
    /inc %charcount 1 
  } 

  /return %strippedstring 
} 

alias -l cleanup { 
  if ($1) { 
    /.remove $1 
    /unset % $+ $1 $+ .* 
    /sockclose $1 
  } 
}
So this is what should happen:

<@Hamish> !stats hamish150
-ClanBot- Hamish150: Overall 913 | Attack 62 | Defence 60 | Strength 58 | Hitpoints 60 | Ranged 50 | Prayer 41 | Magic 50 | Cooking 61 | Woodcutting 50 | Fletching 34 | Fishing 61 | Firemaking 40 | Crafting 47 | Mining 55 | Agility 40 | Thieving 37
Thanks, Hamish.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

this script simply gets a webpage and prints the stats from there to the channel?! Sounds like it would be easier to write from scratch.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

Post by Hamish »

Oh, sorry... I don't much about TCL scripts... Do you think you could help with it anyway?
Thanks, Hamish.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Hamish wrote:Oh, sorry... I don't much about TCL scripts... Do you think you could help with it anyway?
You should learn Tcl and convert the "code" yourself. The following will be of assistance:

Guide to TCL scripting for Eggdrop 1.6
man/tcl8.4/TclCmd/
A beginners guide to TCL with focus on Eggdrop
Eggdrop Tcl Commands
How to write eggdrop scripts that won't choke on special characters
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Post Reply