From 910d60d8c0ac607a8c4c462c7f095cf48ecabe71 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 15 Aug 2015 15:40:13 -0400 Subject: [PATCH] oh this is old --- client.go | 152 ++++++++++-------------------------------- cmd/steam/commands.go | 2 +- dota.go | 2 +- 3 files changed, 39 insertions(+), 117 deletions(-) diff --git a/client.go b/client.go index 7234ac7..59f01e6 100644 --- a/client.go +++ b/client.go @@ -85,8 +85,44 @@ func (c *Client) GetPlayerSummaries(steamids ...uint64) ([]PlayerSummary, error) return response.V.Players, nil } -func (c *Client) DotaMatchHistory() ([]DotaMatch, error) { +func (c *Client) DotaMatchSequence(lastId uint64, n int) ([]DotaMatch, error) { + // http://api.steampowered.com/IDOTA2Match_/GetMatchHistoryBySequenceNum/v1 + url := fmt.Sprintf("https://api.steampowered.com/IDOTA2Match_570/GetMatchHistoryBySequenceNum/v1/?key=%s", c.key) + if lastId > 0 { + url = fmt.Sprintf("%s&start_at_match_seq_num=%d", url, lastId) + } + if n > 0 { + url = fmt.Sprintf("%s&matches_requested=%d", url, n) + } + fmt.Println(url) + var response struct { + V struct { + Status int `json:"status"` + NumResults int `json:"num_results"` + Total int `json:"total_results"` + Remaining int `json:"results_remaining"` + Matches []DotaMatch `json:"matches"` + } `json:"result"` + } + res, err := http.Get(url) + if err != nil { + return nil, errorf(err, "unable to get match history") + } + if err := json.NewDecoder(res.Body).Decode(&response); err != nil { + return nil, errorf(err, "unable to parse match history response") + } + return response.V.Matches, nil +} + +func (c *Client) DotaMatchHistory(lastId uint64, n int) ([]DotaMatch, error) { url := fmt.Sprintf("https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v0001/?key=%s", c.key) + if lastId > 0 { + url = fmt.Sprintf("%s&last_match_id=%d", url, lastId) + } + if n > 0 { + url = fmt.Sprintf("%s&matches_requested=%d", url, n) + } + fmt.Println(url) var response struct { V struct { Status int `json:"status"` @@ -120,117 +156,3 @@ func (c *Client) DotaMatchDetails(id uint64) (*DotaMatchDetails, error) { } return &result.V, nil } - -/* - "name": "ISteamUser", - "methods": [ - { - "name": "GetPlayerBans", - "version": 1, - "httpmethod": "GET", - "parameters": [ - { - "name": "key", - "type": "string", - "optional": false, - "description": "access key" - }, - { - "name": "steamids", - "type": "string", - "optional": false, - "description": "Comma-delimited list of SteamIDs" - } - ] - - }, - { - "name": "GetPlayerSummaries", - "version": 1, - "httpmethod": "GET", - "parameters": [ - { - "name": "key", - "type": "string", - "optional": false, - "description": "access key" - }, - { - "name": "steamids", - "type": "string", - "optional": false, - "description": "Comma-delimited list of SteamIDs" - } - ] - - }, - { - "name": "GetPlayerSummaries", - "version": 2, - "httpmethod": "GET", - "parameters": [ - { - "name": "key", - "type": "string", - "optional": false, - "description": "access key" - }, - { - "name": "steamids", - "type": "string", - "optional": false, - "description": "Comma-delimited list of SteamIDs (max: 100)" - } - ] - - }, - { - "name": "GetUserGroupList", - "version": 1, - "httpmethod": "GET", - "parameters": [ - { - "name": "key", - "type": "string", - "optional": false, - "description": "access key" - }, - { - "name": "steamid", - "type": "uint64", - "optional": false, - "description": "SteamID of user" - } - ] - - }, - { - "name": "ResolveVanityURL", - "version": 1, - "httpmethod": "GET", - "parameters": [ - { - "name": "key", - "type": "string", - "optional": false, - "description": "access key" - }, - { - "name": "vanityurl", - "type": "string", - "optional": false, - "description": "The vanity URL to get a SteamID for" - }, - { - "name": "url_type", - "type": "int32", - "optional": true, - "description": "The type of vanity URL. 1 (default): Individual profile, 2: Group, 3: Official game group" - } - ] - - } - ] - - }, -*/ diff --git a/cmd/steam/commands.go b/cmd/steam/commands.go index 5a34e33..9d0fe59 100644 --- a/cmd/steam/commands.go +++ b/cmd/steam/commands.go @@ -75,7 +75,7 @@ func init() { }, "dota-match-history": command{ handler: func(c *steam.Client, args ...string) { - matches, err := c.DotaMatchHistory() + matches, err := c.DotaMatchHistory(0, 0) if err != nil { bail(1, "%v", err) } diff --git a/dota.go b/dota.go index 5e624e4..ef5176c 100644 --- a/dota.go +++ b/dota.go @@ -12,7 +12,7 @@ type DotaMatch struct { SeqNum uint64 `json:"match_seq_num"` StartTime uint64 `json:"start_time"` LobbyType int `json:"lobby_type"` - RadiantTeamId int `json:"radian_team_id"` + RadiantTeamId int `json:"radiant_team_id"` DireTeamId int `json:"dire_team_id"` Players []DotaMatchPlayer `json:"players"` }