feat: Implement core voicebot functionality with TeamSpeak 3 and xAI integration.

This commit is contained in:
Jose Luis Montañes Ojados
2026-01-16 10:39:27 +01:00
parent aa8c0dbcbc
commit fb17813dcb
10 changed files with 460 additions and 287 deletions

View File

@@ -132,9 +132,11 @@ func (c *Client) Connect() error {
err := c.internal.Connect(c.address)
if err != nil {
c.emit(EventDisconnected, &DisconnectedEvent{Reason: err.Error()})
log.Printf("[TS3Client] Connect returning with error: %v", err)
return err
}
log.Printf("[TS3Client] Connect returning cleanly")
return nil
}
@@ -154,18 +156,24 @@ func (c *Client) ConnectAsync() <-chan error {
// Disconnect closes the connection gracefully
func (c *Client) Disconnect() {
log.Println("[Disconnect] Starting disconnect sequence...")
if c.internal != nil {
// Send disconnect command to server
log.Println("[Disconnect] Sending disconnect command...")
c.sendDisconnect("leaving")
// Small delay to allow packet to be sent
time.Sleep(100 * time.Millisecond)
// Wait for packet to be sent and ACKed - the internal loop must still be running
log.Println("[Disconnect] Waiting for disconnect to be processed...")
time.Sleep(1000 * time.Millisecond)
// Stop the internal loop
log.Println("[Disconnect] Stopping internal loop...")
c.internal.Stop()
if c.internal.Conn != nil {
log.Println("[Disconnect] Closing connection...")
c.internal.Conn.Close()
}
}
c.connected = false
log.Println("[Disconnect] Done")
c.emit(EventDisconnected, &DisconnectedEvent{Reason: "client disconnect"})
}