• Hey Guest, we're evolving the future of TeaSpeak.
    You're invited to join the discussion here!

Golang TSQuery connection

BIOS

TeaSpeak Team
Staff member
TeaTeam
So idk what's the difference between golang framework and the php framework so, I can't tell you how to use it.
 

ramonster

New member
Hi, that package for Tea*Speak 3 can work for TeaSpeak, you only need to change a few lines of code.

By default, escaping for Tea*Speak when responding is a \n\r, because of that, you can fork that project and change 2 lines of code:

```
func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
if atEOF && len(data) == 0 {
return 0, nil, nil
}

// original line if i := strings.Index(string(data), "\n"\r); i >= 0 {
if i := strings.Index(string(data), "\n"); i >= 0 {
// We have a full end-of-line terminated line.
//original line return i + 2, data[0:i], nil
return i + 1, data[0:i], nil
}

// If we're at EOF, we have a final, non-terminated line. Return it.
if atEOF {
return len(data), data, nil
}

// Request more data.
return 0, nil, nil
}
```

Also you need to change the header, as the TS3 header is just "TS3", and one Tea*Speak server I connect it was just "Tea*Speak", and for the TeaSpeak server I connected, the header was "Teaspeak", this you can change in the client.go file, where they have this:


DefaultConnectHeader = "TS3"

Header is the first line of response after you succefully connect to a server.

With these changes I've been able to connect to TeaSpeak, but using that package. This screenshot shows a connection to a TS3 server, but the same worked for a TeaSpeak server, you can adjust the function so it can accept both Ts3 and teaspeak connections, which I did, as my clients can use one or the other

1762423955442.png

This screenshot is a sample of one of the commands I ran, ts3Client.Server.ChannelList()
 

Attachments