@@ -7,6 +7,29 @@ import (
7
7
const (
8
8
// ExtendedServerList can be passed to List to get extended server information.
9
9
ExtendedServerList = "-extended"
10
+
11
+ // ClientUID can be passed to ClientList to retrieve client UID information.
12
+ ClientUID = "-uid"
13
+ // ClientAway can be passed to ClientList to retrieve client away information.
14
+ ClientAway = "-away"
15
+ // ClientVoice can be passed to ClientList to retrieve client voice information.
16
+ ClientVoice = "-voice"
17
+ // ClientTimes can be passed to ClientList to retrieve client time information.
18
+ ClientTimes = "-times"
19
+ // ClientGroups can be passed to ClientList to retrieve client groups information.
20
+ ClientGroups = "-groups"
21
+ // ClientInfo can be passed to ClientList to retrieve client information.
22
+ ClientInfo = "-info"
23
+ // ClientIcon can be passed to ClientList to retrieve client icon information.
24
+ ClientIcon = "-icon"
25
+ // ClientCountry can be passed to ClientList to retrieve client country information.
26
+ ClientCountry = "-country"
27
+ // ClientIP can be passed to ClientList to retrieve client IP information.
28
+ ClientIP = "-ip"
29
+ // ClientBadges can be passed to ClientList to retrieve client badge information.
30
+ ClientBadges = "-badges"
31
+ // ClientListFull can be passed to ClientList to get all extended client information.
32
+ ClientListFull = "-uid -away -voice -times -groups -info -icon -country -ip -badges"
10
33
)
11
34
12
35
// ServerMethods groups server methods.
@@ -351,19 +374,70 @@ func (s *ServerMethods) PrivilegeKeyAdd(ttype, id1, id2 int, options ...CmdArg)
351
374
352
375
// OnlineClient represents a client online on a virtual server.
353
376
type OnlineClient struct {
354
- ID int `ms:"clid"`
355
- ChannelID int `ms:"cid"`
356
- DatabaseID int `ms:"client_database_id"`
357
- Nickname string `ms:"client_nickname"`
358
- Type int `ms:"client_type"`
359
- Away bool `ms:"client_away"`
360
- AwayMessage string `ms:"client_away_message"`
377
+ // Following variables are always returned by ClientList().
378
+ ID int `ms:"clid"`
379
+ ChannelID int `ms:"cid"`
380
+ DatabaseID int `ms:"client_database_id"`
381
+ Nickname string `ms:"client_nickname"`
382
+ Type int `ms:"client_type"`
383
+ // Following variables are optional and can be requested in ClientList() to get extended client information.
384
+ // note: Away and AwayMessage are currently optional but not using pointers for compatibility considerations.
385
+ Away bool `ms:"client_away"` // Only populated if ClientAway or ClientListFull is passed to ClientList.
386
+ AwayMessage string `ms:"client_away_message"` // Only populated if ClientAway or ClientListFull is passed to ClientList.
387
+ * OnlineClientExt `ms:",squash"` // Only populated if any of the options is passed to ClientList.
388
+ }
389
+
390
+ // OnlineClientExt represents all ClientList extensions.
391
+ type OnlineClientExt struct {
392
+ UniqueIdentifier * string `ms:"client_unique_identifier"` // Only populated if ClientUID or ClientListFull is passed to ClientList.
393
+ * OnlineClientVoice `ms:",squash"` // Only populated if ClientVoice or ClientListFull is passed to ClientList.
394
+ * OnlineClientTimes `ms:",squash"` // Only populated if ClientTimes or ClientListFull is passed to ClientList.
395
+ * OnlineClientGroups `ms:",squash"` // Only populated if ClientGroups or ClientListFull is passed to ClientList.
396
+ * OnlineClientInfo `ms:",squash"` // Only populated if ClientInfo or ClientListFull is passed to ClientList.
397
+ Country * string `ms:"client_country"` // Only populated if ClientCountry or ClientListFull is passed to ClientList.
398
+ IP * string `ms:"connection_client_ip"` // Only populated if ClientIP or ClientListFull is passed to ClientList.
399
+ Badges * string `ms:"client_badges"` // Only populated if ClientBadges or ClientListFull is passed to ClientList.
400
+ IconID * int `ms:"client_icon_id"` // Only populated if ClientIcon or ClientListFull is passed to ClientList.
401
+ }
402
+
403
+ // OnlineClientVoice represents all ClientList extensions when the ClientVoice parameter is passed.
404
+ type OnlineClientVoice struct {
405
+ FlagTalking * bool `ms:"client_flag_talking"`
406
+ InputMuted * bool `ms:"client_input_muted"`
407
+ OutputMuted * bool `ms:"client_output_muted"`
408
+ InputHardware * bool `ms:"client_input_hardware"`
409
+ OutputHardware * bool `ms:"client_output_hardware"`
410
+ TalkPower * int `ms:"client_talk_power"`
411
+ IsTalker * bool `ms:"client_is_talker"`
412
+ IsPrioritySpeaker * bool `ms:"client_is_priority_speaker"`
413
+ IsRecording * bool `ms:"client_is_recording"`
414
+ IsChannelCommander * bool `ms:"client_is_channel_commander"`
415
+ }
416
+
417
+ // OnlineClientTimes represents all ClientList extensions when the ClientTimes parameter is passed.
418
+ type OnlineClientTimes struct {
419
+ IdleTime * int `ms:"client_idle_time"`
420
+ Created * int `ms:"client_created"`
421
+ LastConnected * int `ms:"client_lastconnected"`
422
+ }
423
+
424
+ // OnlineClientGroups represents all ClientList extensions when the ClientGroups parameter is passed.
425
+ type OnlineClientGroups struct {
426
+ ChannelGroupID * int `ms:"client_channel_group_id"`
427
+ ChannelGroupInheritedChannelID * int `ms:"client_channel_group_inherited_channel_id"`
428
+ ServerGroups * []int `ms:"client_servergroups"`
429
+ }
430
+
431
+ // OnlineClientInfo represents all ClientList extensions when the ClientInfo parameter is passed.
432
+ type OnlineClientInfo struct {
433
+ Version * string `ms:"client_version"`
434
+ Platform * string `ms:"client_platform"`
361
435
}
362
436
363
437
// ClientList returns a list of online clients.
364
- func (s * ServerMethods ) ClientList () ([]* OnlineClient , error ) {
438
+ func (s * ServerMethods ) ClientList (options ... string ) ([]* OnlineClient , error ) {
365
439
var clients []* OnlineClient
366
- if _ , err := s .ExecCmd (NewCmd ("clientlist" ).WithResponse (& clients )); err != nil {
440
+ if _ , err := s .ExecCmd (NewCmd ("clientlist" ).WithOptions ( options ... ). WithResponse (& clients )); err != nil {
367
441
return nil , err
368
442
}
369
443
return clients , nil
0 commit comments