Sign in to follow this  
Followers 0
Obi-w00t

Teamspeak Status Viewer

3 posts in this topic

#1 ·  Posted (edited)

OK, seeing as a Teamspeak admin program has already been posted I thought I should post my Teamspeak 2 status viewer. I should tell you a few things about this version:

1) It was made for use in a web-based script so the output is text from an array, somebody might want to add a GUI tree view if they want to use it in a GUI-based program.

2) The player list and channel list are dumped to text files, this is for debugging purposes and if you don't want these files then by all means simply change those bits of code.

3) I know there isn't much error-checking, this I may add later but if it bothers you that much then by all means add your own error checking routines.

With that said here is the script, it has some comments to clear stuff up.

$q = InputBox("TSIP:QueryPort:TSPort","Please enter the server details, in the format" & @CRLF & "Server IP:Query Port (usually 51234):Server Port")

$strings = StringSplit($q,":")

$szIPAddress = $strings[1]
$szTSPort = $strings[3]
$nPORT = $strings[2]

$sEnd = "Server: "

; Start The TCP Services
;==============================================
TCPStartUp()

; Initialize a variable to represent a connection
;==============================================
Dim $ConnectedSocket = -1

;Attempt to connect to SERVER at its IP and PORT 33891
;=======================================================
Do
$ConnectedSocket = TCPConnect($szIPAddress,$nPORT)
Until $ConnectedSocket <> -1

MsgBox(0,"","Connected")

Dim $szData

$level = 0

While $level <6
    Do
        $recv = TCPRecv( $ConnectedSocket, 2048 )
    Until $recv <> ""
    
    ;Find out which stage of transmission we are on
    Select
        ;List server ports (not strictly required)
        Case $level = 0
            $szData = "sl"
            $level = 1
        ;Select the server port we want
        Case $level = 1
            $szData = "sel " & $szTSPort
            $level = 2
        ;List users (file gets dumped on next level)
        Case $level = 2
            $szData = "pl"
            $level = 3  
        ;List channels (file gets dumped on next level)
        Case $level = 3
            $szData = "cl"
            FileWrite("pl.log", $recv)
            $plarray = DecodePL()
            FileDelete("pl.log")
            $level = 4  
        ;Get some server info (dump the server info to a file, gets the name)
        Case $level = 4
            $szData = "si"
            FileWrite("cl.log", $recv)
            $clarray = DecodeCL()
            FileDelete("cl.log")
            $level = 5
        ;Get some server info (dump the server info to a file, gets the name)
        Case $level = 5
            $szData = ""
            FileWrite("si.log", $recv)
            $servername = "Server Name" ;DecodeSI()
            FileDelete("si.log")
            $level = 6
    EndSelect
    ;Send what we just set
    TCPSend($ConnectedSocket,$szData & @CRLF)
WEnd

$sEnd &= $servername & " @ " & $szIPAddress & ":" & $szTSPort & @CRLF

For $n = 0 to UBound($clarray) - 1
    If $clarray[$n][2] = "-1" Then 
        ;If it is a parent, put the channel name and its ID surrounded by our control characters to the string
        $sEnd &= "[]: " & $clarray[$n][0] & "  " & CHR(173) & $clarray[$n][1] & CHR(173) & @CRLF
        ;Cycle through the players and if the player is in that channel put it in the array
        For $i = 0 to UBound($plarray) - 1
            If $plarray[$i][1] = $clarray[$n][1] Then 
                $sEnd = StringReplace($sEnd,CHR(173) & $clarray[$n][1] & CHR(173),CHR(173) & $clarray[$n][1] & CHR(173) & @CRLF &  "   -=" & $plarray[$i][0])
            EndIf
        Next
    Else
        ;If it is a child find the parent's ID surrounded by our control characters and replace it with the name of the sub-channel
        $sEnd = StringReplace($sEnd,CHR(173) & $clarray[$n][2] & CHR(173),CHR(173) & $clarray[$n][2] & CHR(173) & @CRLF & "--[]: " & $clarray[$n][0] & "  " & CHR(173) & $clarray[$n][1] & CHR(173))
        For $i = 0 to UBound($plarray) - 1
            If $plarray[$i][1] = $clarray[$n][1] Then 
                $sEnd = StringReplace($sEnd,CHR(173) & $clarray[$n][1] & CHR(173),CHR(173) & $clarray[$n][1] & CHR(173) & @CRLF &  "   -=" & $plarray[$i][0])
            EndIf
        Next
    EndIf
Next

;Strips out the control characters and strings used in the above, they do not need to be seen by the user
$sEnd = StringRegExpReplace($sEnd, "\" & CHR(173) & ".+\" & CHR(173), "")

MsgBox(0,"End Result",$sEnd)

TCPCloseSocket($ConnectedSocket)

TCPShutDown()

;These functions decode the text files, first the channel list
Func DecodeCL()
Local $iRows
Local $iVar = 0
Local $array[1][3]
$lfile = FileOpen("cl.log", 0)
$vClipboardData = FileReadLine($lfile)
Do
    $vClipboardData = FileReadLine($lfile)
    $vElement=stringsplit($vClipboardData, @TAB)
    $iRows = $vElement[0]
    If $iRows < 9 Then ExitLoop
    If $iVar >= UBound($array,1) Then ReDim $array[$iVar+1][3] ;Resize to fit
    $array[$iVar][0] = StringReplace($vElement[$iRows-3],CHR(173),"=") ;Name to array, changes our control character
    $array[$iVar][1] = $vElement[1]        ;ID to array
    $array[$iVar][2] = $vElement[3]        ;Parent to array
    $iVar += 1
Until @error Or $vClipboardData = "OK" & @CRLF
FileClose($lfile)
Return $array
EndFunc

;Then decode the player list
Func DecodePL()
Local $iRows
Local $iVar
Local $array[1][3]
$lfile = FileOpen("pl.log", 0)
$vClipboardData = FileReadLine($lfile)
Do
    $vClipboardData = FileReadLine($lfile)
    $vElement=stringsplit($vClipboardData, @TAB)
    $iRows = $vElement[0]
    If $iRows < 16 Then ExitLoop
    If $iVar >= UBound($array,1) Then ReDim $array[$iVar+1][3] ;Resize to fit
    $array[$iVar][0] = $vElement[$iRows-2] ;Name to array
    $array[$iVar][1] = $vElement[2]        ;ID to array
    $iVar += 1
Until @error Or $vClipboardData = "OK" & @CRLF
FileClose($lfile)
Return $array
EndFunc

;Then decode the player list
Func DecodeSI()
Local $sName = "server_name="
Local $sPlatform = "server_platform"
Local $sSName = ""
$lfile = FileOpen("si.log", 0)
$vClipboardData = FileRead($lfile)
$len = StringLen($vClipboardData)
$iName = StringInStr($vClipboardData,$sName) + 12
$iPlatform = StringInStr($vClipboardData,$sPlatform)
$sSName = StringMid($vClipboardData,$iName,$iPlatform - 28 )
$sSName = StringStripCR(StringStripWS($sSName,3))
FileClose($lfile)
Return $sSName
EndFunc

Criticise away, people :)

Edit: Only a few views so far so for anyone that is confused:

1) You find a Teamspeak server, get the IP and port.

2) Enter those details in the input box when you open the program. It will ask for a query port, unless you know otherwise, it will be the default, like so: 123.123.123.123:51234:8087

3) Wait, then the program will tell you the name of the server, who is online, in which channel and show you the channel structure, all without logging in.

4) Normally to view this you would need to actually log on to the server in the Teamspeak client, however this program lets you view all that information without logging on to the server.

Edited by Obi-w00t

Share this post


Link to post
Share on other sites



Looks like nobody here uses Teamspeak...or just does not want this script.

Share this post


Link to post
Share on other sites

Heya!

First i have to say this Script is so great cause i use ts2 evry day! :)

BUT 1 problem its not listing all channels :)

Bye Posted Image


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0