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.

convert irc script -> tcl script

Old posts that have not been replied to for several years.
Locked
m
m0de
Voice
Posts: 12
Joined: Mon Jun 09, 2003 11:33 am

convert irc script -> tcl script

Post by m0de »

i've tried converting an irc script to tcl but i just end up screwing things up more. will someone please help me out with the converting?

Heres the script:

Code: Select all

;; Modified to use a website which gave explicit permission to use it

;; [WonID] ------- Text event
on *:text:@wonid *:#script: {
  if ($2 !isnum 0-100000000) return
  inc -u30 %wonflood. [ $+ [ $nick ] ]
  if ((%wonflood. [ $+ [ $nick ] ] > 3) || ($var(%wonflood.*,0) > 4)) return
  sockclose wonid
  sockopen wonid wonid.elite-pimps.com 80
  ; sockmark wonid $2 n $+ $nick $ticks
  sockmark wonid $2 c $+ $chan $ticks
}

;; [WonID] ------- Sockopen event
on *:sockopen:wonid:{
  sockwrite -n $sockname GET /?action=search&type=single&key=wonid&query= $+ $gettok($sock(wonid).mark,1,32) $+ &game=&league=&div=&output=xml HTTP/1.1
  sockwrite -n $sockname Host: wonid.elite-pimps.com
  sockwrite -n $sockname Connection: Close
  sockwrite -n $sockname User-Agent: byte-at-ircscripting.net v1.20
  sockwrite -n $sockname $crlf
  set %wonid.ok no
}

;; [WonID] ------- Sockread event
on *:sockread:wonid:{
  if ($sockerr > 0) return
  while ($sock(wonid)) {
    sockread %temp
    set -l %data $gettok($gettok(%temp,2,$asc(>)),1,$asc(<))
    if ($sockbr == 0) return
    if (%temp == <disabled>) {
      if ($left($gettok($sock(wonid).mark,2,32),1) == n) notice $right($gettok($sock(wonid).mark,2,32),-1) error. source db disabled contact script author.
      else msg $right($gettok($sock(wonid).mark,2,32),-1) error. source db disabled contact script author.
    }
    else if (%temp == </results>) && (%wonid.ok == no) {
      if ($left($gettok($sock(wonid).mark,2,32),1) == n) notice $right($gettok($sock(wonid).mark,2,32),-1) Sorry, no results found.
      else msg $right($gettok($sock(wonid).mark,2,32),-1) Sorry, no results found.
    }
    else if (%temp == </results>) {
      sockclose wonid
    }
    else if (%temp == <result>) set %wonid.ok yes
    else if (<ban_status>*</ban_status> iswm %temp) set %wonid.ban_status %data
    else if (<player_id>*</player_id> iswm %temp) set %wonid.player_id %data
    else if (<player_alias>*</player_alias> iswm %temp) set %wonid.player_alias %data
    else if (<player_name>*</player_name> iswm %temp) set %wonid.player_name %data
    else if (<player_wonid>*</player_wonid> iswm %temp) set %wonid.player_wonid %data
    else if (<team_id>*</team_id> iswm %temp) set %wonid.team_id %data
    else if (<team_game>*</team_game> iswm %temp) set %wonid.team_game %data
    else if (<team_league>*</team_league> iswm %temp) set %wonid.team_league %data
    else if (<team_division>*</team_division> iswm %temp) set %wonid.team_division %data
    else if (<team_location>*</team_location> iswm %temp) set %wonid.team_location %data
    else if (<team_name>*</team_name> iswm %temp) set %wonid.team_name %data
    else if (<team_tag>*</team_tag> iswm %temp) set %wonid.team_tag %data
    else if (<team_irc>*</team_irc> iswm %temp) set %wonid.team_irc %data
    else if (<team_website>*</team_website> iswm %temp) set %wonid.team_website %data
    else if (%temp == </result>) {
      set %wonid.return ID: %wonid.player_wonid :: Team: %wonid.team_name :: Handle: %wonid.player_alias :: Name: %wonid.player_name :: League: %wonid.team_league $+ - $+ %wonid.team_division :: Response time: $calc(($ticks - $gettok($sock(wonid).mark,3,32)) / 1000) seconds [wonid.elite-pimps.com]
      if ($left($gettok($sock(wonid).mark,2,32),1) == n) notice $right($gettok($sock(wonid).mark,2,32),-1) %wonid.return
      else msg $right($gettok($sock(wonid).mark,2,32),-1) %wonid.return
      unset %wonid.*
    }
  }
}

it searches wonid.elite-pimps.com for the id and then returns the data.. but after several attempts on making this for my eggdrop bot i failed ;[
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Let's see how you've converted it so far.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

lol, yeah I would like to see that too :P cuz u make it sound so easy to do.

m0de read doc/tcl-commands.doc to know how to bind. In tcl binds are used instead of the IRC on :events:.
like for example: bind pub - "@wonid *" pub:elite-pimps
and then u create the pub:elite-pimps proc which is the hard part... also u must bind a sock, which u can do with the help of tcl-commands.doc.
Locked