1
0
mirror of https://github.com/Adam-Ant/TeamspeakBot-Go synced 2024-11-05 05:36:23 +00:00
TeamspeakBot-Go/lockcheck.go

53 lines
1.0 KiB
Go
Raw Permalink Normal View History

2017-12-01 23:15:59 +00:00
package main
import (
"github.com/darfk/ts3"
"log"
"strings"
)
2017-12-03 21:53:30 +00:00
func doLockandGuest(client *ts3.Client, clid string) {
var groupAssigned bool
2017-12-01 23:15:59 +00:00
data, err := client.Exec(ClientInfo(clid))
if err != nil {
log.Fatal(err)
}
cldbid := data.Params[0]["client_database_id"]
groups := strings.Split(data.Params[0]["client_servergroups"], ",")
2017-12-03 21:53:30 +00:00
nickname := data.Params[0]["client_nickname"]
2017-12-01 23:15:59 +00:00
for i := range groups {
if groups[i] == "9" {
2017-12-03 21:53:30 +00:00
_, err := client.Exec(ServerGroupDelClient("9", cldbid))
2017-12-01 23:15:59 +00:00
if err != nil {
log.Fatal(err)
}
2017-12-03 21:53:30 +00:00
log.Println("Removed lock group from client " + nickname)
//_, err = client.Exec(SendMessageChannel(false, "Removed Lock group from you!"))
//if err != nil {
// log.Println(err)
//}
}
if groups[i] == "8" {
groupAssigned = true
2017-12-01 23:15:59 +00:00
}
}
2017-12-03 21:53:30 +00:00
log.Println(groupAssigned)
if !groupAssigned {
// Guest group missing, needs assigning.
_, err := client.Exec(ServerGroupAddClient("8", cldbid))
if err != nil {
log.Fatal(err)
}
log.Println("Gave guest group to client " + nickname)
}
2017-12-01 23:15:59 +00:00
}