1
0
mirror of https://github.com/Adam-Ant/TeamspeakBot-Go synced 2024-11-05 13:46:22 +00:00
TeamspeakBot-Go/main.go
2017-12-01 23:15:59 +00:00

60 lines
1.0 KiB
Go

package main
import (
"github.com/darfk/ts3"
"log"
)
// Username and password in Constants.go, not on github :D
func processNotify(client *ts3.Client, notification chan ts3.Notification) {
for i := range notification {
//log.Println(i)
if i.Type == "notifyclientmoved" {
// We need to check for lock group
doLock(client, i.Params[0]["clid"])
}
}
}
func main() {
client, err := ts3.NewClient("ts3.cwgaming.co.uk:10011")
if err != nil {
log.Fatal(err)
}
_, err = client.Exec(ts3.Login(user, pass))
if err != nil {
log.Fatal(err)
}
_, err = client.Exec(ts3.Use(1))
if err != nil {
log.Fatal(err)
}
// Start listening to client join and move events
_, err = client.Exec(ts3.Command{
Command: "servernotifyregister",
Params: map[string][]string{
"event": []string{"channel"},
"id": []string{"0"},
},
})
if err != nil {
log.Fatal(err)
}
notification := make(chan ts3.Notification)
go processNotify(client, notification)
client.NotifyHandler(func(n ts3.Notification) {
notification <- n
})
for {
}
}