Closed bdeb1337 closed 9 months ago
As not everyone will want all of this information this should really be an extension not a hard coded set.
Thanks for your reply, I agree. I tried implementing this as an optional string parameter for the ClientList()
function with the ability to request "all". Don't know if there would be a better way of doing this.
I have added a new commit in which I have tried to address the remarks and questions you made earlier. On the remarks you made above I have added a response with what I wrote this time. Also I have tried editing the *_test.go files to add testing for the standard ClientList and extended Clientlist requests, but I am not that sure if I handled that correctly.
I have added a new commit trying to implement your recommendations and remarks. Kind regards.
In the new commit, an embedded struct pointer that holds all optional struct pointers and values for options of clientlist has been added. The mapstructure
library didn't support the combination of reflection and nil values to determine the type when squashing embedded pointers from map to struct. But it does work with regular structs: (https://github.com/mitchellh/mapstructure/blob/bf980b35cac4dfd34e05254ee5aba086504c3f96/mapstructure_test.go#L729C17-L729C54).
I have added a workaround by injecting the correct type while decoding, and nil'ling them after if needed.
Hi @stevenh , I hope you are doing well. Time has gone by fast since September and I apologize for not bumping this earlier. I was wondering if you have had a chance to look at my latest commit and share your thoughts about the implementation. I appreciate your feedback and suggestions because I already learned a lot from you. Thank you for your time and attention. Kind regards!
Thanks for the bump @bdeb1337 will try to look over the next few days, but as I no longer have merge access, also poking @lwaddicor
Hey!
Just had a quick look and ran the change against a local teamspeak server I fired up in docker, and it looks as populated as I'd expect.
Just a couple of minor things around the comments to please the linters and make it easier for users in their IDEs. Other than that it looks very nice!
package main
import (
"fmt"
"log"
"github.com/kr/pretty"
"github.com/multiplay/go-ts3"
)
func main() {
c, err := ts3.NewClient("localhost:10011")
if err != nil {
log.Fatal(err)
}
defer c.Close()
if err := c.Login("serveradmin", "M2EhMOoP"); err != nil {
log.Fatal(err)
}
v, err := c.Version()
if err != nil {
log.Fatal(fmt.Errorf("fail to version list: %w", err))
}
fmt.Println("Server is running:")
pretty.Print(v)
if err := c.Server.Use(1); err != nil {
log.Fatal(err)
}
fmt.Println("Client fist full:")
cl, err := c.Server.ClientList(ts3.ClientListFull)
if err != nil {
log.Fatal(fmt.Errorf("fail to client list: %w", err))
}
pretty.Print(cl)
}
Output:
Server is running:
&ts3.Version{Version:"3.13.7", Platform:"Linux", Build:1655727713}
Client fist full:
[]*ts3.OnlineClient{
&ts3.OnlineClient{
ID: 13,
ChannelID: 1,
DatabaseID: 1,
Nickname: "serveradmin",
Type: 1,
Away: false,
AwayMessage: "",
OnlineClientExt: &ts3.OnlineClientExt{
UniqueIdentifier: &"serveradmin",
OnlineClientVoice: &ts3.OnlineClientVoice{
FlagTalking: &bool(false),
InputMuted: &bool(false),
OutputMuted: &bool(false),
InputHardware: &bool(false),
OutputHardware: &bool(false),
TalkPower: &int(0),
IsTalker: &bool(false),
IsPrioritySpeaker: &bool(false),
IsRecording: &bool(false),
IsChannelCommander: &bool(false),
},
OnlineClientTimes: &ts3.OnlineClientTimes{
IdleTime: &int(6),
Created: &int(0),
LastConnected: &int(0),
},
OnlineClientGroups: &ts3.OnlineClientGroups{
ChannelGroupID: &int(8),
ChannelGroupInheritedChannelID: &int(1),
ServerGroups: &[]int{2},
},
OnlineClientInfo: &ts3.OnlineClientInfo{
Version: &"ServerQuery",
Platform: &"ServerQuery",
},
Country: &"",
IP: &"172.17.0.1",
Badges: &"",
IconID: &int(0),
},
},
&ts3.OnlineClient{
ID: 6,
ChannelID: 1,
DatabaseID: 3,
Nickname: "Lewis",
Type: 0,
Away: true,
AwayMessage: "",
OnlineClientExt: &ts3.OnlineClientExt{
UniqueIdentifier: &"lnxjPE/99+DR/wFXWawTtpeMBg4=",
OnlineClientVoice: &ts3.OnlineClientVoice{
FlagTalking: &bool(false),
InputMuted: &bool(false),
OutputMuted: &bool(false),
InputHardware: &bool(true),
OutputHardware: &bool(true),
TalkPower: &int(75),
IsTalker: &bool(false),
IsPrioritySpeaker: &bool(false),
IsRecording: &bool(false),
IsChannelCommander: &bool(true),
},
OnlineClientTimes: &ts3.OnlineClientTimes{
IdleTime: &int(312470),
Created: &int(1701366169),
LastConnected: &int(1701366169),
},
OnlineClientGroups: &ts3.OnlineClientGroups{
ChannelGroupID: &int(8),
ChannelGroupInheritedChannelID: &int(1),
ServerGroups: &[]int{6},
},
OnlineClientInfo: &ts3.OnlineClientInfo{
Version: &"3.6.1 [Build: 1690193193]",
Platform: &"OS X",
},
Country: &"",
IP: &"172.17.0.1",
Badges: &"",
IconID: &int(0),
},
},
}
Hey!
Just had a quick look and ran the change against a local teamspeak server I fired up in docker, and it looks as populated as I'd expect.
Just a couple of minor things around the comments to please the linters and make it easier for users in their IDEs. Other than that it looks very nice!
Thanks a bunch for checking it out so quickly! I've added your latest suggestions in a new commit.
Hi @lwaddicor and @stevenh
My best wishes for the starting of the new year :fireworks: . I would kindly like to bump this PR again as I am looking forward to what you guys think and what I should try to improve or change.
Thank you! Kind regards
No problem, thank you @lwaddicor for checking and merging. And also @stevenh thanks again for the guidance in this PR, appreciate that. Kind regards, Bob.
Hello,
First off thank you for this great library, which is working great for a project of mine.
I was having somewhat the same request as @30 of wanting to expand the basic
clientlist
command. I've read the latest serverquery documentation that ships with ts3 server version 3.13.7 and included all parameters regarding this command:I haven't included
servergroups
yet, since trying to map it as a[]int
didn't immediately work. I guess it would have something to do with helpers.go line 74 which states// TODO(steve): support groups
but I could be wrong. If you are OK with this I could try to give it a go later in a separate pull request? I feel like it might be a little much for one PR otherwise and I could use some guidance in the right direction for that change.Kind regards
Bob