@@ 27,7 27,7 @@ func (fc *faceitChecker) getCSGOElo(w http.ResponseWriter, r *http.Request) {
url := "https://steamcommunity.com/profiles/" + steamID64
steamProfile, errSteam := fc.getSteamProfile(r.Context(), url)
if errSteam == nil && steamProfile.ID64 == steamID64 {
- if err == errNoCSGOFaceit {
+ if err == errNoCSFaceit {
// Set default elo
data.Games.CSGO.Elo = 1000
} else {
@@ 78,7 78,7 @@ func (fc *faceitChecker) getCS2Elo(w http.ResponseWriter, r *http.Request) {
url := "https://steamcommunity.com/profiles/" + steamID64
steamProfile, errSteam := fc.getSteamProfile(r.Context(), url)
if errSteam == nil && steamProfile.ID64 == steamID64 {
- if err == errNoCSGOFaceit {
+ if err == errNoCSFaceit {
// Set default elo
data.Games.CSGO.Elo = 1000
} else {
@@ 30,7 30,7 @@ var templates embed.FS
//go:embed css
var css embed.FS
-var errNoCSGOFaceit = errors.New("no associated CS:GO Faceit account")
+var errNoCSFaceit = errors.New("no associated Counter-Strike Faceit account")
type statsError struct {
ErrorMessage string
@@ 65,7 65,7 @@ type faceitInfo struct {
} `json:"games"`
}
-type faceitCSGO struct {
+type faceitCS struct {
//Bans []string `json:"bans"` //todo: wait for faceit api fix
Stats struct {
Matches string `json:"Matches"`
@@ 183,8 183,8 @@ func main() {
}
}
-func (fc *faceitChecker) checkStats(ctx context.Context, playerid string, data *faceitCSGO) error {
- url := "https://open.faceit.com/data/v4/players/" + playerid + "/stats/csgo"
+func (fc *faceitChecker) checkStats(ctx context.Context, playerid string, data *faceitCS) error {
+ url := "https://open.faceit.com/data/v4/players/" + playerid + "/stats/cs2"
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
return &statsError{"request"}
@@ 246,7 246,7 @@ func (fc *faceitChecker) checkBan(ctx context.Context, faceitID string) (bool, s
func (fc *faceitChecker) lastMatch(ctx context.Context, faceitID string) (time.Time, error) {
var lastMatch time.Time
- url := "https://open.faceit.com/data/v4/players/" + faceitID + "/history?game=csgo&limit=1"
+ url := "https://open.faceit.com/data/v4/players/" + faceitID + "/history?game=cs2&limit=1"
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
return lastMatch, err
@@ 352,7 352,7 @@ func (fc *faceitChecker) getFaceitPlayer(ctx context.Context, steamID64 string)
if resp.StatusCode != http.StatusOK {
if resp.StatusCode == http.StatusNotFound {
- return info, errNoCSGOFaceit
+ return info, errNoCSFaceit
}
return info, fmt.Errorf("received status code %d", resp.StatusCode)
}
@@ 369,7 369,7 @@ func (fc *faceitChecker) getFaceitPlayer(ctx context.Context, steamID64 string)
info.FaceitURL = strings.ReplaceAll(info.FaceitURL, "{lang}", "en")
if !strings.Contains(info.FaceitURL, "faceit") {
- return info, errNoCSGOFaceit
+ return info, errNoCSFaceit
}
return info, nil
@@ 455,7 455,7 @@ func (fc *faceitChecker) requestHandler(w http.ResponseWriter, r *http.Request)
continue
}
- var data2 faceitCSGO
+ var data2 faceitCS
err = fc.checkStats(r.Context(), data.PlayerID, &data2)
if err != nil {
playerLogger.Error("Failed to check stats",
@@ 487,7 487,7 @@ func (fc *faceitChecker) requestHandler(w http.ResponseWriter, r *http.Request)
continue
}
- player.Elo = data.Games.CSGO.Elo
+ player.Elo = data.Games.CS2.Elo
player.Kd = data2.Stats.KD
player.Matches = data2.Stats.Matches
player.Winrate = data2.Stats.Winrate