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.

[need help] TeamSpeak Info v2.0

Support & discussion of released scripts, and announcements of new releases.
Post Reply
g
genti
Voice
Posts: 7
Joined: Wed Nov 30, 2005 5:32 pm

[need help] TeamSpeak Info v2.0

Post by genti »

Hi all! I've a problem with a script downloaded from egghelp.org.

If ther's no user on my ts server the script works fine, but with someone connected if I try to retrieve info about ts server, in the telnet window to the eggdrop i have this error:

"Tcl error [TS:control]: can't read "nik": no such variable"

in "ts.tcl" the only line with "TS:control" are:

-bash-2.05b$ cat ts.tcl |grep TS:control
control $sock TS:control
proc TS:control {sock input} {

can you help me?

thx a lot

(sorry for my english :oops: )
User avatar
]Kami[
Owner
Posts: 590
Joined: Thu Jul 24, 2003 2:59 pm
Location: Slovenia
Contact:

Post by ]Kami[ »

Copy whole script here and output of .tcl set errorInfo / .set errorInfo
g
genti
Voice
Posts: 7
Joined: Wed Nov 30, 2005 5:32 pm

Post by genti »

ts.tcl:

Code: Select all

##################################################
#  Teamspeak v2.0                                #
#    Author: PezCore aka DieSucker               #
#  Tested on Eggdrop v1.6.17                     # 
##################################################
#                                                #
#                                                #
#                                                #
# This is a TCL Script designed to query a       #
# TeamSpeak server and post the nick and their   #
# time one the server into a channel.            #
# 3/30/2005 v2.0 - Added channels list           #
#                  Server info                   #
#                  cleaned up some outputs       #
# 3/20/2005 v1.2 - Added multi-server support    #
# 3/11/2005 v1.1 - Fixed The server time out     #
#                  it now gives an error if the  #
#                  server is offline or you      #
#                  give a BAD IP/PORT. It will   #
#                  take a minute for the it to   #
#                  time-out                      #
# 2/23/2005 v1.0 - rewrote most of the script    #
# 8/13/2004 v0.9 - Intial script by Vitto        #
# Many THANKS goes to MC_8                       #
# If you need me, #donuthole on irc.protium.org  #
# or email me diesucker@kc.rr.com                #
#                                                #
# Things-To-Do: Maybe add an HTML setting        #
#               Also add/delete servers          #
##################################################
array unset ts_server

# Configuration: 

# Set here a list of TeamSpeak servers, and there information. 
# Specify as many ts_server(<short_name>)'s as you need. 
# Syntax: 
#   set ts_server(<short_name>) [list "<full name>" "<ip>" "<port>" "<tcpquery>"] 

#set ts_server(TEST) [list "Servername" "127.2.0.0" "8767" "51234"]

set ts_server(mxb) [list "###" "#######" "8767" "51234"]

######################################################################################
###############Coding, Please don't edit below########################################
######################################################################################
unset -nocomplain Name 
unset -nocomplain Value
foreach {Name Value} [array get ts_server] { 
  array unset ts_server $Name 
  array set ts_server [list [string tolower $Name] $Value] 
} 
unset -nocomplain Name 
unset -nocomplain Value 

#Public Binding
bind pub - !ts TS:start
bind pub - !tsc TS:channels
bind pub - !tsi TS:serverinfo
bind pub - !tsservers TS:servers
bind pub - !tshelp TS:help

proc TS:servers {nick uhost handle channel text} { 
  set list [array names ::ts_server] 
  if {![llength $list]} { 
    putserv "PRIVMSG $channel :\0034,0There are no TeamSpeak servers currently defined, sorry." 
  } else { 
    putserv "PRIVMSG $channel :\0034,0List of availble TeamSpeak servers:\0033,0 [join $list ", "]" 
  } 
} 
#######Grabbing Server Info#############


proc TS:serverinfo {nick uhost handle channel text} {
   global ts
   set text [string tolower $text] 
   if {$text == ""} {
     putserv "PRIVMSG $channel :\0034,0Sorry, please specify a valid server selection. Use !tsservers to find supported servers"
     return 0
   } 
   if {[lsearch -exact [array names ::ts_server] $text] == "-1"} { 
     putserv "PRIVMSG $channel :\0034,0 Sorry, '$text' isn't a valid server selection. Please us !tsservers to find supported servers" 
     return 0 
   } 
   foreach {ts(servername) ts(ip) ts(port) ts(tcpquery)} $::ts_server($text) break
   set sock [connect $ts(ip) $ts(tcpquery)]
   close [open "scripts/tsserverinfo.txt" w]
   close [open "scripts/tsserverinfo2.txt" w]
   set ts(user:$sock) "" ; set ts(count:$sock) 0
   set ts(chan:$sock) "" ; set ts(arg:$sock) "$channel"
   set ts(arg) "$channel"
   set ts(players:$sock) 0
   set ts(last:$sock) ""
   control $sock TS:servercontrol
}
proc TS:servercontrol {sock input} {
   global ts
   if {$input == ""} {
     putserv "PRIVMSG $ts(arg) :\0034,0 The TeamSpeak Server has timed-out. Either The TeamSpeak server is offline or an Invalid IP
                                   was specified"
     return 1
   }
   if {$ts(last:$sock) == ""} {
     if {$input == {[TS]}} {
     putdcc $sock "sel $ts(port)"
     set ts(last:$sock) sel
     return 0
    }
   }
   if {$ts(last:$sock) == "sel"} {
     if {$input == "OK"} {
       putdcc $sock "si"
       set ts(last:$sock) si
       return 0
     }
    }
   if {$ts(last:$sock) == "si"} {
     if {$input == "OK"} {
       putdcc $sock "gi"
       set ts(last:$sock) gi
       return 0
     }
   set io2 [open "scripts/tsserverinfo.txt" a]
    puts $io2 "$input"; close $io2; return 0
   }
   if {$ts(last:$sock) == "gi"} {
     if {$input == "OK"} {
       TS:serverend
       return 1
     }
    set io3 [open "scripts/tsserverinfo2.txt" a]
    puts $io3 "$input"
    close $io3
    return 0
    }
 return 0
}

proc TS:serverend {} {
    global ts
    set info [open "scripts/tsserverinfo.txt" r]
    set info1 [read -nonewline $info]  
    close $info
    set vers [open "scripts/tsserverinfo2.txt" r]
    set vers1 [read -nonewline $vers]
    close $vers
    file delete -force -- "scripts/tsserverinfo.txt"
    set vers2 [split $vers1 "\n"]
    set vers3 [lindex $vers2 1]
    set vers4 [split $vers3 "="]
    set vers5 [lindex $vers4 1]
    set info2 [split $info1 "\n"]
    set name1 [lindex $info2 1]
    set name2 [split $name1 "="]
    set name3 [lindex $name2 1]
    set welcome1 [lindex $info2 3]
    set welcome2 [lindex [split $welcome1 "="] 1]
    set max1 [lindex $info2 9]
    set max2 [lindex [split $max1 "="] 1]
    set plat [lindex $info2 2]
    set plat2 [lindex [split $plat "="] 1]
    set users [lindex $info2 28]
    set users2 [lindex [split $users "="] 1]
    set channs [lindex $info2 29]
    set channs2 [lindex [split $channs "="] 1]
    set uptime [lindex $info2 27]
    set uptime2 [lindex [split $uptime "="] 1]
    set uptime3 [duration $uptime2]
    set uptime5 [split $uptime3 " "]
    set uptime4 [llength $uptime5]
    if {$uptime4 == "10"} {
      set test14 "[lindex $uptime5 0]w[lindex $uptime5 2]d[lindex $uptime5 4]h[lindex $uptime5 6]m"
    }
    if {$uptime4 == "8"} {
      set test14 "[lindex $uptime5 0]d[lindex $uptime5 2]h[lindex $uptime5 4]m"
    }
    if {$uptime4 == "6"} { 
      set test14 "[lindex $uptime5 0]h[lindex $uptime5 2]m" 
    } 
    if {$uptime4 == "4"} { 
      set test14 "0h[lindex $uptime5 0]m"
    } 
    if {$uptime4 == "2"} { 
      set test14 "[lindex $uptime5 0]s" 
    } 
    putserv "PRIVMSG $ts(arg) :\0034,0Server Info For\0033,0 $ts(servername)($ts(ip):$ts(port)) :\0031,0 \002Name:\002 $name3 \002Welcome Message:\002 $welcome2 \002Max Users:\002 $max2 \002Platform:\002 $plat2 \002Current users:\002 $users2 \002 Total Channels:\002 $channs2 \002Uptime:\002 $test14 \002Version:\002 $vers5"
} 

#################End Of Server Info################################


#################Server channels###################################


proc TS:channels {nick uhost handle channel text} {
    global ts
    if {$text == ""} {
      putserv "PRIVMSG $channel :\0034,0Sorry, please specify a valid server selection. Use !tsservers to find supported servers"
      return 0
    } 
    set text [string tolower $text] 
    if {[lsearch -exact [array names ::ts_server] $text] == "-1"} { 
      putserv "PRIVMSG $channel :\0034,0Sorry, '$text' isn't a valid server selection. Use !tsservers to find supported servers"
      return 0 
    } 
    foreach {ts(servername) ts(ip) ts(port) ts(tcpquery)} $::ts_server($text) break
    set sock [connect $ts(ip) $ts(tcpquery)]
    close [open "scripts/tschannels.txt" w]
    set ts(user:$sock) "" ; set ts(count:$sock) 0
    set ts(chan:$sock) "" ; set ts(arg:$sock) "$channel"
    set ts(arg) "$channel"
    set ts(players:$sock) 0
    set ts(last:$sock) ""
    control $sock TS:chancontrol
}

proc TS:chancontrol {sock input} {
    global ts
    if {$input == ""} {
      putserv "PRIVMSG $ts(arg) :\0034,0 The TeamSpeak Server has timed-out. Either The TeamSpeak server is offline or an Invalid IP
                                   was specified" 
      return 1
      }
    if {$ts(last:$sock) == ""} { 
      if {$input == {[TS]}} { 
      putdcc $sock "sel $ts(port)"
      set ts(last:$sock) sel 
      return 0 
      }
    } 
    if {$ts(last:$sock) == "sel"} { 
      if {$input == "OK"} {
        putdcc $sock "cl"
        set ts(last:$sock) cl
        return 0
       }
   }
   if {$ts(last:$sock) == "cl"} {
     if {$input == "OK"} {
       TS:chanend
       return 1
       }
   set io [open "scripts/tschannels.txt" a]
   puts $io "/ $input"
   close $io
   return 0
  }
 return 0 
}

proc TS:chanend {} {
   global ts
   set ts(channels1) [open "scripts/tschannels.txt" r]
   set ts(channels2) [read $ts(channels1)]
   set ts(channels3) [split $ts(channels2) "\n"]
   close $ts(channels1)
   file delete -force -- "scripts/tschannels.txt"
   set ts(channels3) [lreplace $ts(channels3) 0 0]
   set ts(channels4) [llength $ts(channels3)]
   set ts(channels4) [expr "$ts(channels4) - 1"]
   set ts(ch1) [lindex $ts(channels3) 0]
   set ts(ch2) [lindex [split $ts(ch1) \t] 5]
   set ts(ch3) [lindex [split $ts(ch2) {"}] 1]
   set ts(channelsoutput) ": $ts(ch3)"
   set j 1 
   while {$j < $ts(channels4)} {
        set ts(channels6) [lindex $ts(channels3) $j]
        set ts(channels7) [lindex [split $ts(channels6) \t] 5]
        set ts(channels8) [split $ts(channels7) {"}]
        set ts(channels9) [lindex $ts(channels8) 1]
        append ts(channelsoutput) ", " $ts(channels9)
        incr j
        }
   putserv "PRIVMSG $ts(arg) :\0034,0 Channels on\0033,0 $ts(servername)($ts(ip):$ts(port)):\0036,0($ts(channels4))\0031,0$ts(channelsoutput)"
}

#############End of channels#####################

#############Users Connected#####################


proc TS:start {nick uhost handle channel text} { 
    global ts
    set text [string tolower $text]
    if {$text == ""} {
      putserv "PRIVMSG $channel :\0034,0Sorry, please specify a valid server selection. Use !tsservers to find supported servers"
      return 0
     } 
    if {[lsearch -exact [array names ::ts_server] $text] == "-1"} { 
      putserv "PRIVMSG $channel :\0034,0Sorry, '$text' isn't a valid server selection. Use !tsservers to find supported servers" 
      return 0 
     } 
    foreach {ts(servername) ts(ip) ts(port) ts(tcpquery)} $::ts_server($text) break 
    set sock [connect $ts(ip) $ts(tcpquery)] 
    close [open "scripts/tstester.txt" w] 
    set ts(user:$sock) "" ; set ts(count:$sock) 0 
    set ts(chan:$sock) "" ; set ts(arg:$sock) "$channel" 
    set ts(arg) "$channel" 
    set ts(players:$sock) 0
    set ts(last:$sock) ""
    control $sock [b]TS:control
}

proc TS:control {sock input} { 
    global ts
    if {$input == ""} {
      putserv "PRIVMSG $ts(arg) :\0034,0 The TeamSpeak Server has timed-out. Either The TeamSpeak server is offline or an Invalid IP was specified"
      return 1
    } 
    if {$ts(last:$sock) == ""} { 
      if {$input == {[TS]}} { 
        putdcc $sock "sel $ts(port)" 
        set ts(last:$sock) sel 
        return 0 
      }
    } 
    if {$ts(last:$sock) == "sel"} { 
      if {$input == "OK"} { 
        putdcc $sock "pl" 
        set ts(last:$sock) pl 
        return 0 
      }
    }
    if {$ts(last:$sock) == "pl"} { 
      if {$input == "OK"} {  
        TS:end
        return 1 
      } 
    set io [open "scripts/tstester.txt" a] 
    puts $io "/ $input"; close $io; return 0 
    }
  return 0 
}

proc TS:end {} {
    global ts
    set ts(players2) "scripts/tstester.txt"
    set ts(players3) [open $ts(players2) r]
    set ts(playerdata) [read $ts(players3)]
    set ts(plines) [split $ts(playerdata) "\n"]
    close $ts(players3)
    file delete -force -- "scripts/tstester.txt"
    set ltd 0 
    set ts(plines) [lreplace $ts(plines) $ltd $ltd]
    set i [open $ts(players2) w]
    puts $i [join $ts(plines) ""]
    close $i
    set ts(nlines) [llength $ts(plines)]
    set ts(lines2) [expr "$ts(nlines) - 1"]
    set channeloutput [list ":"]
    set i 0 
    while {$i < $ts(lines2)} {
         set users2 [lindex $ts(plines) $i]
         set users1 [regexp {\d\t(\d+?)\t[\d|\t]+?\t".+?"\t"(.+?)"\t"(.*?)"\t} [lindex $ts(plines) $i] {\1\2\3} input nik Name] 
         set test11 [duration [lindex [split $users2 \t] 8]]
         set test12 [split $test11 " "]
         set test13 [llength $test12]
         if {$test13 == "10"} {
           set test14 "([lindex $test12 0]w[lindex $test12 2]d[lindex $test12 4]h[lindex $test12 6]m)"
         }
         if {$test13 == "8"} {
           set test14 "([lindex $test12 0]d[lindex $test12 2]h[lindex $test12 4]m)"
         }
         if {$test13 == "6"} { 
           set test14 "([lindex $test12 0]h[lindex $test12 2]m)" 
         } 
         if {$test13 == "4"} { 
           set test14 "(0h[lindex $test12 0]m)" 
         } 
         if {$test13 == "2"} { 
           set test14 "([lindex $test12 0]s)" 
         } 
         lappend channeloutput  $nik $test14
         incr i 
    }
   if {$ts(lines2) == 0} { 
     putserv "PRIVMSG $ts(arg) :\0034,0There Are NO Users Connected to\0033,0 $ts(servername)($ts(ip):$ts(port))"
     } else {
           putserv "PRIVMSG $ts(arg) :\0034,0Current Users Connected to \0033,0$ts(servername)($ts(ip):$ts(port)): \0036,0($ts(lines2))\0031,0 $channeloutput" 
     }
}

###########End of Users Connected##############

###########TS Script Help######################

proc TS:help {nick uhost handle channel text} {
     putserv "NOTICE $nick : TeamSpeak TCL v2.0 "
     putserv "NOTICE $nick : Commands :"
     putserv "NOTICE $nick : !ts (servername) - returns current users connected"
     putserv "NOTICE $nick : !tsi (servername) - returns information for the given server"
     putserv "NOTICE $nick : !tsc (servername) - returns channels from the server"
     putserv "NOTICE $nick : !tsservers - returns list of supported servers" 
     
}

##########TS Script Help END######################
putlog " TeamSpeak Info v2.0 "

The only error message is:
"Tcl error [TS:control]: can't read "nik": no such variable"
when i write in my channel !ts mxb, to know if someone is connected to the ts server.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

obviously the regexp doesnt match the input string and therefor the var gets not created. you could use 'if $users1 {lappend...}' to prevent the TCL error to occur, however it won't display what it should until the regular expression or the source of the script is fixed.
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...
S
Syntax1980
Voice
Posts: 2
Joined: Fri Jun 13, 2008 2:38 pm

Post by Syntax1980 »

Hello,

i have similar mistake !

Code: Select all

Tcl error [TS:start]: invalid command name "b"
my tcl with my data (Thanks for Help)

Code: Select all

##################################################
#  Teamspeak v2.0                                #
#    Author: PezCore aka DieSucker               #
#  Tested on Eggdrop v1.6.17                     #
##################################################
#                                                #
#                                                #
#                                                #
# This is a TCL Script designed to query a       #
# TeamSpeak server and post the nick and their   #
# time one the server into a channel.            #
# 3/30/2005 v2.0 - Added channels list           #
#                  Server info                   #
#                  cleaned up some outputs       #
# 3/20/2005 v1.2 - Added multi-server support    #
# 3/11/2005 v1.1 - Fixed The server time out     #
#                  it now gives an error if the  #
#                  server is offline or you      #
#                  give a BAD IP/PORT. It will   #
#                  take a minute for the it to   #
#                  time-out                      #
# 2/23/2005 v1.0 - rewrote most of the script    #
# 8/13/2004 v0.9 - Intial script by Vitto        #
# Many THANKS goes to MC_8                       #
# If you need me, #donuthole on irc.protium.org  #
# or email me diesucker@kc.rr.com                #
#                                                #
# Things-To-Do: Maybe add an HTML setting        #
#               Also add/delete servers          #
##################################################
array unset ts_server

# Configuration:

# Set here a list of TeamSpeak servers, and there information.
# Specify as many ts_server(<short_name>)'s as you need.
# Syntax:
#   set ts_server(<short_name>) [list "<full name>" "<ip>" "<port>" "<tcpquery>"]

#set ts_server(TEST) [list "TCTS" "84.201.42.164" "12819" "32800"]

set ts_server(mxb) [list "TCTS" "84.201.42.164" "12819" "32800"]

######################################################################################
###############Coding, Please don't edit below########################################
######################################################################################
unset -nocomplain Name
unset -nocomplain Value
foreach {Name Value} [array get ts_server] {
  array unset ts_server $Name
  array set ts_server [list [string tolower $Name] $Value]
}
unset -nocomplain Name
unset -nocomplain Value

#Public Binding
bind pub - !ts TS:start
bind pub - !tsc TS:channels
bind pub - !tsi TS:serverinfo
bind pub - !tsservers TS:servers
bind pub - !tshelp TS:help

proc TS:servers {nick uhost handle channel text} {
  set list [array names ::ts_server]
  if {![llength $list]} {
    putserv "PRIVMSG $channel :\0034,0There are no TeamSpeak servers currently defined, sorry."
  } else {
    putserv "PRIVMSG $channel :\0034,0List of availble TeamSpeak servers:\0033,0 [join $list ", "]"
  }
}
#######Grabbing Server Info#############


proc TS:serverinfo {nick uhost handle channel text} {
   global ts
   set text [string tolower $text]
   if {$text == ""} {
     putserv "PRIVMSG $channel :\0034,0Sorry, please specify a valid server selection. Use !tsservers to find supported servers"
     return 0
   }
   if {[lsearch -exact [array names ::ts_server] $text] == "-1"} {
     putserv "PRIVMSG $channel :\0034,0 Sorry, '$text' isn't a valid server selection. Please us !tsservers to find supported servers"
     return 0
   }
   foreach {ts(servername) ts(ip) ts(port) ts(tcpquery)} $::ts_server($text) break
   set sock [connect $ts(ip) $ts(tcpquery)]
   close [open "scripts/tsserverinfo.txt" w]
   close [open "scripts/tsserverinfo2.txt" w]
   set ts(user:$sock) "" ; set ts(count:$sock) 0
   set ts(chan:$sock) "" ; set ts(arg:$sock) "$channel"
   set ts(arg) "$channel"
   set ts(players:$sock) 0
   set ts(last:$sock) ""
   control $sock TS:servercontrol
}
proc TS:servercontrol {sock input} {
   global ts
   if {$input == ""} {
     putserv "PRIVMSG $ts(arg) :\0034,0 The TeamSpeak Server has timed-out. Either The TeamSpeak server is offline or an Invalid IP
                                   was specified"
     return 1
   }
   if {$ts(last:$sock) == ""} {
     if {$input == {[TS]}} {
     putdcc $sock "sel $ts(port)"
     set ts(last:$sock) sel
     return 0
    }
   }
   if {$ts(last:$sock) == "sel"} {
     if {$input == "OK"} {
       putdcc $sock "si"
       set ts(last:$sock) si
       return 0
     }
    }
   if {$ts(last:$sock) == "si"} {
     if {$input == "OK"} {
       putdcc $sock "gi"
       set ts(last:$sock) gi
       return 0
     }
   set io2 [open "scripts/tsserverinfo.txt" a]
    puts $io2 "$input"; close $io2; return 0
   }
   if {$ts(last:$sock) == "gi"} {
     if {$input == "OK"} {
       TS:serverend
       return 1
     }
    set io3 [open "scripts/tsserverinfo2.txt" a]
    puts $io3 "$input"
    close $io3
    return 0
    }
 return 0
}

proc TS:serverend {} {
    global ts
    set info [open "scripts/tsserverinfo.txt" r]
    set info1 [read -nonewline $info] 
    close $info
    set vers [open "scripts/tsserverinfo2.txt" r]
    set vers1 [read -nonewline $vers]
    close $vers
    file delete -force -- "scripts/tsserverinfo.txt"
    set vers2 [split $vers1 "\n"]
    set vers3 [lindex $vers2 1]
    set vers4 [split $vers3 "="]
    set vers5 [lindex $vers4 1]
    set info2 [split $info1 "\n"]
    set name1 [lindex $info2 1]
    set name2 [split $name1 "="]
    set name3 [lindex $name2 1]
    set welcome1 [lindex $info2 3]
    set welcome2 [lindex [split $welcome1 "="] 1]
    set max1 [lindex $info2 9]
    set max2 [lindex [split $max1 "="] 1]
    set plat [lindex $info2 2]
    set plat2 [lindex [split $plat "="] 1]
    set users [lindex $info2 28]
    set users2 [lindex [split $users "="] 1]
    set channs [lindex $info2 29]
    set channs2 [lindex [split $channs "="] 1]
    set uptime [lindex $info2 27]
    set uptime2 [lindex [split $uptime "="] 1]
    set uptime3 [duration $uptime2]
    set uptime5 [split $uptime3 " "]
    set uptime4 [llength $uptime5]
    if {$uptime4 == "10"} {
      set test14 "[lindex $uptime5 0]w[lindex $uptime5 2]d[lindex $uptime5 4]h[lindex $uptime5 6]m"
    }
    if {$uptime4 == "8"} {
      set test14 "[lindex $uptime5 0]d[lindex $uptime5 2]h[lindex $uptime5 4]m"
    }
    if {$uptime4 == "6"} {
      set test14 "[lindex $uptime5 0]h[lindex $uptime5 2]m"
    }
    if {$uptime4 == "4"} {
      set test14 "0h[lindex $uptime5 0]m"
    }
    if {$uptime4 == "2"} {
      set test14 "[lindex $uptime5 0]s"
    }
    putserv "PRIVMSG $ts(arg) :\0034,0Server Info For\0033,0 $ts(servername)($ts(ip):$ts(port)) :\0031,0 \002Name:\002 $name3 \002Welcome Message:\002 $welcome2 \002Max Users:\002 $max2 \002Platform:\002 $plat2 \002Current users:\002 $users2 \002 Total Channels:\002 $channs2 \002Uptime:\002 $test14 \002Version:\002 $vers5"
}

#################End Of Server Info################################


#################Server channels###################################


proc TS:channels {nick uhost handle channel text} {
    global ts
    if {$text == ""} {
      putserv "PRIVMSG $channel :\0034,0Sorry, please specify a valid server selection. Use !tsservers to find supported servers"
      return 0
    }
    set text [string tolower $text]
    if {[lsearch -exact [array names ::ts_server] $text] == "-1"} {
      putserv "PRIVMSG $channel :\0034,0Sorry, '$text' isn't a valid server selection. Use !tsservers to find supported servers"
      return 0
    }
    foreach {ts(servername) ts(ip) ts(port) ts(tcpquery)} $::ts_server($text) break
    set sock [connect $ts(ip) $ts(tcpquery)]
    close [open "scripts/tschannels.txt" w]
    set ts(user:$sock) "" ; set ts(count:$sock) 0
    set ts(chan:$sock) "" ; set ts(arg:$sock) "$channel"
    set ts(arg) "$channel"
    set ts(players:$sock) 0
    set ts(last:$sock) ""
    control $sock TS:chancontrol
}

proc TS:chancontrol {sock input} {
    global ts
    if {$input == ""} {
      putserv "PRIVMSG $ts(arg) :\0034,0 The TeamSpeak Server has timed-out. Either The TeamSpeak server is offline or an Invalid IP
                                   was specified"
      return 1
      }
    if {$ts(last:$sock) == ""} {
      if {$input == {[TS]}} {
      putdcc $sock "sel $ts(port)"
      set ts(last:$sock) sel
      return 0
      }
    }
    if {$ts(last:$sock) == "sel"} {
      if {$input == "OK"} {
        putdcc $sock "cl"
        set ts(last:$sock) cl
        return 0
       }
   }
   if {$ts(last:$sock) == "cl"} {
     if {$input == "OK"} {
       TS:chanend
       return 1
       }
   set io [open "scripts/tschannels.txt" a]
   puts $io "/ $input"
   close $io
   return 0
  }
 return 0
}

proc TS:chanend {} {
   global ts
   set ts(channels1) [open "scripts/tschannels.txt" r]
   set ts(channels2) [read $ts(channels1)]
   set ts(channels3) [split $ts(channels2) "\n"]
   close $ts(channels1)
   file delete -force -- "scripts/tschannels.txt"
   set ts(channels3) [lreplace $ts(channels3) 0 0]
   set ts(channels4) [llength $ts(channels3)]
   set ts(channels4) [expr "$ts(channels4) - 1"]
   set ts(ch1) [lindex $ts(channels3) 0]
   set ts(ch2) [lindex [split $ts(ch1) \t] 5]
   set ts(ch3) [lindex [split $ts(ch2) {"}] 1]
   set ts(channelsoutput) ": $ts(ch3)"
   set j 1
   while {$j < $ts(channels4)} {
        set ts(channels6) [lindex $ts(channels3) $j]
        set ts(channels7) [lindex [split $ts(channels6) \t] 5]
        set ts(channels8) [split $ts(channels7) {"}]
        set ts(channels9) [lindex $ts(channels8) 1]
        append ts(channelsoutput) ", " $ts(channels9)
        incr j
        }
   putserv "PRIVMSG $ts(arg) :\0034,0 Channels on\0033,0 $ts(servername)($ts(ip):$ts(port)):\0036,0($ts(channels4))\0031,0$ts(channelsoutput)"
}

#############End of channels#####################

#############Users Connected#####################


proc TS:start {nick uhost handle channel text} {
    global ts
    set text [string tolower $text]
    if {$text == ""} {
      putserv "PRIVMSG $channel :\0034,0Sorry, please specify a valid server selection. Use !tsservers to find supported servers"
      return 0
     }
    if {[lsearch -exact [array names ::ts_server] $text] == "-1"} {
      putserv "PRIVMSG $channel :\0034,0Sorry, '$text' isn't a valid server selection. Use !tsservers to find supported servers"
      return 0
     }
    foreach {ts(servername) ts(ip) ts(port) ts(tcpquery)} $::ts_server($text) break
    set sock [connect $ts(ip) $ts(tcpquery)]
    close [open "scripts/tstester.txt" w]
    set ts(user:$sock) "" ; set ts(count:$sock) 0
    set ts(chan:$sock) "" ; set ts(arg:$sock) "$channel"
    set ts(arg) "$channel"
    set ts(players:$sock) 0
    set ts(last:$sock) ""
    control $sock [b]TS:control
}

proc TS:control {sock input} {
    global ts
    if {$input == ""} {
      putserv "PRIVMSG $ts(arg) :\0034,0 The TeamSpeak Server has timed-out. Either The TeamSpeak server is offline or an Invalid IP was specified"
      return 1
    }
    if {$ts(last:$sock) == ""} {
      if {$input == {[TS]}} {
        putdcc $sock "sel $ts(port)"
        set ts(last:$sock) sel
        return 0
      }
    }
    if {$ts(last:$sock) == "sel"} {
      if {$input == "OK"} {
        putdcc $sock "pl"
        set ts(last:$sock) pl
        return 0
      }
    }
    if {$ts(last:$sock) == "pl"} {
      if {$input == "OK"} { 
        TS:end
        return 1
      }
    set io [open "scripts/tstester.txt" a]
    puts $io "/ $input"; close $io; return 0
    }
  return 0
}

proc TS:end {} {
    global ts
    set ts(players2) "scripts/tstester.txt"
    set ts(players3) [open $ts(players2) r]
    set ts(playerdata) [read $ts(players3)]
    set ts(plines) [split $ts(playerdata) "\n"]
    close $ts(players3)
    file delete -force -- "scripts/tstester.txt"
    set ltd 0
    set ts(plines) [lreplace $ts(plines) $ltd $ltd]
    set i [open $ts(players2) w]
    puts $i [join $ts(plines) ""]
    close $i
    set ts(nlines) [llength $ts(plines)]
    set ts(lines2) [expr "$ts(nlines) - 1"]
    set channeloutput [list ":"]
    set i 0
    while {$i < $ts(lines2)} {
         set users2 [lindex $ts(plines) $i]
         set users1 [regexp {\d\t(\d+?)\t[\d|\t]+?\t".+?"\t"(.+?)"\t"(.*?)"\t} [lindex $ts(plines) $i] {\1\2\3} input nik Name]
         set test11 [duration [lindex [split $users2 \t] 8]]
         set test12 [split $test11 " "]
         set test13 [llength $test12]
         if {$test13 == "10"} {
           set test14 "([lindex $test12 0]w[lindex $test12 2]d[lindex $test12 4]h[lindex $test12 6]m)"
         }
         if {$test13 == "8"} {
           set test14 "([lindex $test12 0]d[lindex $test12 2]h[lindex $test12 4]m)"
         }
         if {$test13 == "6"} {
           set test14 "([lindex $test12 0]h[lindex $test12 2]m)"
         }
         if {$test13 == "4"} {
           set test14 "(0h[lindex $test12 0]m)"
         }
         if {$test13 == "2"} {
           set test14 "([lindex $test12 0]s)"
         }
         lappend channeloutput  $nik $test14
         incr i
    }
   if {$ts(lines2) == 0} {
     putserv "PRIVMSG $ts(arg) :\0034,0There Are NO Users Connected to\0033,0 $ts(servername)($ts(ip):$ts(port))"
     } else {
           putserv "PRIVMSG $ts(arg) :\0034,0Current Users Connected to \0033,0$ts(servername)($ts(ip):$ts(port)): \0036,0($ts(lines2))\0031,0 $channeloutput"
     }
}

###########End of Users Connected##############

###########TS Script Help######################

proc TS:help {nick uhost handle channel text} {
     putserv "NOTICE $nick : TeamSpeak TCL v2.0 "
     putserv "NOTICE $nick : Commands :"
     putserv "NOTICE $nick : !ts (servername) - returns current users connected"
     putserv "NOTICE $nick : !tsi (servername) - returns information for the given server"
     putserv "NOTICE $nick : !tsc (servername) - returns channels from the server"
     putserv "NOTICE $nick : !tsservers - returns list of supported servers"
     
}

##########TS Script Help END######################
putlog " TeamSpeak Info v2.0 " 
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Syntax1980 wrote:Hello,

i have similar mistake !

Code: Select all

Tcl error [TS:start]: invalid command name "b"
my tcl with my data (Thanks for Help)
LMAO... it's php forum bbcode, that's supposed to make things bold (normally, but not within code tags). It's safe to remove the ..heh

Code: Select all

#change
control $sock [b]TS:control 
#into
control $sock TS:control 
S
Syntax1980
Voice
Posts: 2
Joined: Fri Jun 13, 2008 2:38 pm

Post by Syntax1980 »

Thanks,


I now have the error as above! How or what do I need to change so that it works my English is not so good

Code: Select all

[21:31] Tcl-Fehler [TS:control]: can't read "nik": no such variable
Problem..

line: 352 //

Code: Select all

set users1 [regexp {\d\t(\d+?)\t[\d|\t]+?\t".+?"\t"(.+?)"\t"(.*?)"\t} [lindex $ts(plines) $i] {\1\2\3} input nik Name] 
or

line 371/372/373

Code: Select all

lappend channeloutput  $nik $test14
         incr i 
    }
I must rename nik in nick ?


THx
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

set users1 [regexp {\d\t(\d+?)\t[\d|\t]+?\t".+?"\t"(.+?)"\t"(.*?)"\t} [lindex $ts(plines) $i] {\1\2\3} input nik Name] 
This is your problem. Understanding how regexp works helps a bit. The regexp will compare it's pattern against $ts(plines). But not the entire contents of $ts(plines) only the lindex position represented by the variable $i.

If this lindex position matches the pattern within the regexp it will transpose these values into the variables input, nik, and name. If this regexp pattern is successful users1 will be set to 1 (which is stupid because this script never uses the users1 variable again). The values caught by the regexp patterns will be transposed to the variables.

If this regexp pattern fails users1 will be set to 0 (again for no reason). The values caught by the regexp patterns will not be transposed to the variables, if these variables existed prior to processing this regexp their values will remain what they were before. If these variables didn't exist prior to processing this regexp they shall not be created as well.

Code: Select all

[21:31] Tcl-Fehler [TS:control]: can't read "nik": no such variable
Which is exactly why nik is not a variable, the regexp has failed and value transposition/variable creation did not take place...

To solve this requires doing as De Kus has already stated. Either fixing the source text which this script parses, or fixing this script to parse altered source text.
Post Reply