Jump to content
Sign in to follow this  
4nt1h4cker

Teamspeak Send Message

Recommended Posts

4nt1h4cker

Hey @ all

I am currently try to code a Teamspeak Bot, so i search for a way to Send a Player a colored Message, but Teamspeak must be in the background.

Oh my current code ^^

But there is nothing with Msg sending , only over telnet for now.

CODE

#include <Array.au3>

#include <String.au3>

; ### INIT ####

;Bot

$cnick = read ("Bot", "Name")

$username = read ( "Bot", "Login")

$userpw = read ( "Bot", "Passwort")

global $pw = read ("Bot" , "PasswortfuerBot")

;SSA

$loginname = read ( "SSA", "Login")

$loginpw = read ( "SSA", "Passwort")

;Server

$ip = read ( "Server", "ip")

$serverport = read ( "Server" , "port")

$port = int ( read ( "Server", "tcp") )

func read ( $section, $name)

$v = IniRead ( "settings.ini", $section, $name, $name)

return $v

EndFunc

; ##############

$ssasocket = telnet_login ()

$sasocket = telnet_login ( true )

$text = ControlGetText ( "TeamSpeak 2", "Connected as HQ BOT", "[CLASS:TRichEditWithLinks; INSTANCE:2]")

while 1

$newtext = ControlGetText ( "TeamSpeak 2", "Connected as HQ BOT", "[CLASS:TRichEditWithLinks; INSTANCE:2]")

if $text = $newtext then

ContinueLoop

Else

$p = stringmid ( $newtext, stringlen ( $text ))

$text = $newtext

$avarray = StringSplit($p, @LF)

for $i = 2 to _arraymax ( $avarray) -1

parse ( $avarray[$i] )

Next

EndIf

WEnd

func parse ( $line )

$line = StringTrimRight ( $line , 1 )

$array = Stringsplit ( $line , " ")

$arraymax = _arraymax ( $array )

; Privat Message

if isdef ( $array , 2 ) And $array[2] == "*priv*" Then

$nick = _StringBetween ( $line , "*priv* ", ": ")

$nick = $nick[0]

$msg = stringmid ( $line, stringinstr( $line , ": ")+2)

parse_private_message ( $nick, $msg)

;player joined

ElseIf $array[$arraymax-1] = "joined" and $array[$arraymax] = "channel" Then

$start = stringinstr ( $line , " ")

$nick = stringmid ( $line , $start+1, stringlen ( $line ) - stringlen (" joined channel") - $start)

;play left

ElseIf $array[$arraymax] = "quit" Then

$start = stringinstr ( $line , " ")

$nick = stringmid ( $line , $start+1, stringlen ( $line ) - stringlen (" quit") - $start)

EndIf

EndFunc

; MsgBox (0 , "Nickname", "[" & $nick & "]" )

; +

func parse_private_message ( $nick, $msg)

if $nick = "" then Return

; Player kicked or banned

if $nick = "SERVER" Then

MsgBox (0 , "msg", "[" & $msg & "]" )

$match = StringRegExp ( $msg , 'Client "(.+?)" got kicked|banned from Server by', 1)

$knick = $match[0]

Return

EndIf

$array = StringSplit ( $msg , " ")

switch stringlower($array[1])

case "help"

$id = getplayerid ( $nick )

if $id > -1 Then

$s = $ssasocket

telnet_send ( $s, "msgu " & $id & "@ === Die Hilfe ===")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @== Öffentliche Befehle ==")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @version : Gibt die Version zurück")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @thetime : Akktuelle Uhrzeit")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @help : Hilfe")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @ == Geschütze Befehle ==")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @! Leerzeichen im Nick dürch einen _ ersetzen !")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @login <Passwort> : Login")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @same : Gibt dir SA")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @sa <Nickanme> : Gibt dem User Server Admin")

sleep (10)

telnet_send( $s, "msgu " & $id & " @switch <Nickname> <Teil des Channelnamens> : Switch den Nick in einen Channel")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @!Du darfst den Channelnamen nur so angeben das er keine Leerzeichen enthält, also zb stat Zocker Bude , Bude oder Zocker, und dürch einen _ ersetzen geht hier auch nicht!")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @remove <Nickname> : Lässt den Spieler leaven")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @ban <Nickname> [<Reason>] : Ban den Spieler (bald auch auf Zeit muttley")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @kick <Nickname> [<Reason>] : Kickt den angebenen User")

sleep (10)

telnet_send ( $s, "msgu " & $id & " @quit : Schaltet den Bot ab")

telnet_recv ( $ssasocket )

EndIf

case "thetime"

$id = getplayerid ( $nick )

if $id > -1 Then

$msg = @MDAY & "." & @MON & "." & @YEAR & " "& @hour & ":" & @MIN & ":" & @SEC

sendmsg ( $ssasocket, $id, $msg)

EndIf

case "version"

$id = getplayerid ( $nick )

if $id > -1 Then

sendmsg ( $ssasocket, $id, "Version 0.2 (Complete Rewite)")

sendmsg ( $ssasocket, $id, "by 4nt1h4cker")

EndIf

case else

$id = getplayerid ( $nick )

if $id > -1 Then

sendmsg ( $ssasocket, $id, "Unbekannter Befehl, help für hilfe")

EndIf

EndSwitch

EndFunc

func sendmsg ( $socket ,$id, $msg )

telnet_send ( $socket , "msgu " & $id & " @" & $msg )

telnet_recv ( $socket )

EndFunc

func isdef ( $array, $index )

if Not IsArray ( $array ) Then return False

$u = UBound ( $array ) -1

if $index > $u Then

return False

Else

return True

EndIf

EndFunc

func getplayerid ($search)

telnet_send ( $ssasocket, "pl" )

$recv = telnet_recv ($ssasocket)

$split = stringsplit ( $recv, @CRLF )

$s = $search

for $i = 3 to $split[0] -4 step 2

$split2 = stringsplit ( $split[$i] , @tab )

$nickname = stringmid ( $split2[15], 2 , stringlen ( $split2[15] ) -2 )

$id = $split2[1]

if $nickname == $s then return $id

Next

return -1

EndFunc

Func telnet_login ($b = False)

if $b Then

$tempname = $username

$temppw = $userpw

Else

$tempname = $loginname

$temppw = $loginpw

EndIf

TCPStartup ()

$socket = TCPConnect ( $ip , $port )

if $socket == - 1 Then

msgbox (0, "Error", "Kann nich zum TS Server connecten" )

Exit

EndIf

telnet_recv ( $socket )

TCPSend ( $socket, "sel " & $serverport & @CRLF)

telnet_recv ( $socket )

if $b Then

TCPSend ( $socket, "login " & $tempname & " " & $temppw & @CRLF)

Else

TCPSend ( $socket, "slogin " & $tempname & " " & $temppw & @CRLF)

EndIf

telnet_recv ( $socket )

return $socket

EndFunc

func telnet_send ($socket, $str)

sleep ( 100 )

TCPSend ( $socket, $str & @CRLF)

EndFunc

func telnet_recv ($socket)

$recv = ""

;$timer = TimerInit ()

while stringcompare ( $recv , "" ) == 0

sleep ( 100 )

$recv &= TCPRecv ( $socket, 100000000 )

WEnd

return $recv

EndFunc

Edited by 4nt1h4cker

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  

×