pls pull #1

Merged
haveachin merged 6 commits from haveachin/go-tsviewer:master into master 2019-01-16 22:12:42 +00:00
3 changed files with 26 additions and 4 deletions
Showing only changes of commit 99f99ab235 - Show all commits

View file

@ -29,8 +29,8 @@ The config file is generated automatically on first startup.
- **`GET`** `/v1/channels` - **`GET`** `/v1/channels`
```json ```json
{ {
"id": 1,
"databaseId": 1, "databaseId": 1,
"channelId": 1,
"nickname": "serveradmin from 127.0.0.1:58359", "nickname": "serveradmin from 127.0.0.1:58359",
"type": 1, "type": 1,
"away": false, "away": false,
@ -51,3 +51,21 @@ The config file is generated automatically on first startup.
"neededSubscribePower": 0 "neededSubscribePower": 0
} }
``` ```
## Server
- **`GET`** `/v1/server/info`
```json
{
"name": "TeamSpeak ]I[ Server",
"status": "online",
"version": "3.5.1 [Build: 1545076855]",
"welcomeMessage": "Welcome to TeamSpeak, check [URL]www.teamspeak.com[/URL] for latest information",
"maxClients": 32,
"clientsOnline": 2,
"reservedSlots": 0,
"uptime": 5976,
"totalPing": 0,
"minAndroidVersion": 1502275280,
"minClientVersion": 1513163251,
"miniOSVersion": 1502275280
}
```

View file

@ -6,8 +6,8 @@ type Service interface {
} }
type Client struct { type Client struct {
ID int `json:"id"`
DatabaseID int `json:"databaseId"` DatabaseID int `json:"databaseId"`
ChannelID int `json:"channelId"`
Nickname string `json:"nickname"` Nickname string `json:"nickname"`
Type int `json:"type"` Type int `json:"type"`
Away bool `json:"away"` Away bool `json:"away"`

View file

@ -16,7 +16,7 @@ func (s Service) Client(id int) (*client.Client, error) {
var c *client.Client var c *client.Client
for _, client := range clients { for _, client := range clients {
if client.ID == id { if client.DatabaseID == id {
c = convertClient(client) c = convertClient(client)
break break
} }
@ -26,6 +26,10 @@ func (s Service) Client(id int) (*client.Client, error) {
return nil, errors.New("client does not exist") return nil, errors.New("client does not exist")
} }
/* if _, err := s.TSClient.Server.ExecCmd(ts3.NewCmd(fmt.Sprintf("clientinfo clid=%d", c.ID)).WithResponse(&c)); err != nil {
return nil, err
} */
return c, nil return c, nil
} }
@ -46,8 +50,8 @@ func (s Service) Clients() ([]*client.Client, error) {
func convertClient(c *ts3.OnlineClient) *client.Client { func convertClient(c *ts3.OnlineClient) *client.Client {
return &client.Client{ return &client.Client{
ID: c.ID,
DatabaseID: c.DatabaseID, DatabaseID: c.DatabaseID,
ChannelID: c.ID,
Nickname: c.Nickname, Nickname: c.Nickname,
Type: c.Type, Type: c.Type,
Away: c.Away, Away: c.Away,