-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbans.go
43 lines (36 loc) · 998 Bytes
/
bans.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package steamapi
import (
"net/url"
"strconv"
"strings"
)
type playerBansJSON struct {
Players []PlayerBan
}
// PlayerBan contains all ban status for community, VAC and economy
type PlayerBan struct {
SteamID uint64 `json:"SteamId,string"`
CommunityBanned bool
VACBanned bool
EconomyBan string
NumberOfVACBans uint
DaysSinceLastBan uint
NumberOfGameBans uint
}
// GetPlayerBans takes a list of steamIDs and returns PlayerBan slice
func GetPlayerBans(steamIDs []uint64, apiKey string) ([]PlayerBan, error) {
var getPlayerBans = NewSteamMethod("ISteamUser", "GetPlayerBans", 1)
strSteamIDs := make([]string, len(steamIDs))
for _, id := range steamIDs {
strSteamIDs = append(strSteamIDs, strconv.FormatUint(id, 10))
}
data := url.Values{}
data.Add("key", apiKey)
data.Add("steamids", strings.Join(strSteamIDs, ","))
var resp playerBansJSON
err := getPlayerBans.Request(data, &resp)
if err != nil {
return nil, err
}
return resp.Players, nil
}