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 

>> Hard MIRC -> TCL Script Conversion <<

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Hamish
Voice


Joined: 27 Mar 2006
Posts: 25

PostPosted: Sat Apr 01, 2006 6:08 am    Post subject: >> Hard MIRC -> TCL Script Conversion << Reply with quote

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

Code:
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.
Back to top
View user's profile Send private message Send e-mail
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sat Apr 01, 2006 10:04 am    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message MSN Messenger
Hamish
Voice


Joined: 27 Mar 2006
Posts: 25

PostPosted: Sat Apr 01, 2006 12:29 pm    Post subject: Reply with quote

Oh, sorry... I don't much about TCL scripts... Do you think you could help with it anyway?
_________________
Thanks, Hamish.
Back to top
View user's profile Send private message Send e-mail
Alchera
Revered One


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

PostPosted: Tue Apr 04, 2006 9:16 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
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