mirror of
https://github.com/aramperes/ts-activity.git
synced 2025-09-09 06:18:31 -04:00
Clean-up
This commit is contained in:
parent
7e93beb132
commit
71ed01df58
2 changed files with 14 additions and 14 deletions
|
@ -46,6 +46,6 @@ helm repo update
|
||||||
helm upgrade --install ts-activity momoperes/ts-activity \
|
helm upgrade --install ts-activity momoperes/ts-activity \
|
||||||
--set config.serverQueryAddr=teamspeak:10011 \
|
--set config.serverQueryAddr=teamspeak:10011 \
|
||||||
--set config.discordUsername=Jeff \
|
--set config.discordUsername=Jeff \
|
||||||
--set serverQuerySecret=ts-activity \
|
--set config.serverQuerySecret=ts-activity \
|
||||||
--set webhookSecret=ts-activity
|
--set config.webhookSecret=ts-activity
|
||||||
```
|
```
|
||||||
|
|
24
cmd.go
24
cmd.go
|
@ -73,7 +73,7 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
clientId, ok := event.Data["clid"]
|
clientID, ok := event.Data["clid"]
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Println("User has no client id", event.Data)
|
log.Println("User has no client id", event.Data)
|
||||||
continue
|
continue
|
||||||
|
@ -81,36 +81,36 @@ func main() {
|
||||||
|
|
||||||
clientNick, ok := event.Data["client_nickname"]
|
clientNick, ok := event.Data["client_nickname"]
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Println("User has no nickname:", clientId)
|
log.Println("User has no nickname:", clientID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, previous := clientMap[clientId]
|
_, previous := clientMap[clientID]
|
||||||
clientMap[clientId] = clientNick
|
clientMap[clientID] = clientNick
|
||||||
|
|
||||||
if !previous {
|
if !previous {
|
||||||
ClientConnected(discord, clientNick)
|
clientConnected(discord, clientNick)
|
||||||
}
|
}
|
||||||
} else if event.Type == "clientleftview" {
|
} else if event.Type == "clientleftview" {
|
||||||
clientId, ok := event.Data["clid"]
|
clientID, ok := event.Data["clid"]
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Println("User has no client id", event.Data)
|
log.Println("User has no client id", event.Data)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
clientNick, ok := clientMap[clientId]
|
clientNick, ok := clientMap[clientID]
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Println("Unknown user left:", clientId)
|
log.Println("Unknown user left:", clientID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(clientMap, clientId)
|
delete(clientMap, clientID)
|
||||||
ClientDisconnected(discord, clientNick)
|
clientDisconnected(discord, clientNick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClientConnected(discord string, nick string) {
|
func clientConnected(discord string, nick string) {
|
||||||
bot := os.Getenv("TS_DISCORD_USERNAME")
|
bot := os.Getenv("TS_DISCORD_USERNAME")
|
||||||
if bot == "" {
|
if bot == "" {
|
||||||
bot = "Jeff"
|
bot = "Jeff"
|
||||||
|
@ -127,7 +127,7 @@ func ClientConnected(discord string, nick string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClientDisconnected(discord string, nick string) {
|
func clientDisconnected(discord string, nick string) {
|
||||||
bot := os.Getenv("TS_DISCORD_USERNAME")
|
bot := os.Getenv("TS_DISCORD_USERNAME")
|
||||||
if bot == "" {
|
if bot == "" {
|
||||||
bot = "Jeff"
|
bot = "Jeff"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue