~xenrox/faceit_checker

0faca944121af2c851ee579c80a44e0b6af304d0 — Thorben Günther 3 months ago c19ee39
Fix some linter (revive) complaints
3 files changed, 12 insertions(+), 12 deletions(-)

M api.go
M config.go
M faceit.go
M api.go => api.go +2 -2
@@ 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 == errNoCSGOFaceit {
				// 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 == errNoCSGOFaceit {
				// Set default elo
				data.Games.CSGO.Elo = 1000
			} else {

M config.go => config.go +2 -2
@@ 8,7 8,7 @@ import (
)

type config struct {
	HttpAddress  string `scfg:"http-address"`
	HTTPAddress  string `scfg:"http-address"`
	FaceitBearer string `scfg:"faceit-bearer"`
	LogLevel     string `scfg:"log-level"`
	LogFormat    string `scfg:"log-format"`


@@ 23,7 23,7 @@ func readConfig(path string) (*config, error) {

	config := new(config)
	// Set default values
	config.HttpAddress = ":8080"
	config.HTTPAddress = ":8080"
	config.LogLevel = "info"
	config.LogFormat = "text"


M faceit.go => faceit.go +8 -8
@@ 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 errNoCSGOFaceit = errors.New("no associated CS:GO Faceit account")

type statsError struct {
	ErrorMessage string


@@ 88,7 88,7 @@ type match struct {
	StartedAt int64 `json:"started_at"`
}

type FaceitPlayer struct {
type faceitPlayer struct {
	Elo       int
	Kd        string
	Matches   string


@@ 154,11 154,11 @@ func main() {

	srv := &http.Server{
		Handler:      r,
		Addr:         cfg.HttpAddress,
		Addr:         cfg.HTTPAddress,
		WriteTimeout: 60 * time.Second,
		ReadTimeout:  60 * time.Second,
	}
	logger.Info(fmt.Sprintf("Starting faceit_checker, listening on %s", cfg.HttpAddress))
	logger.Info(fmt.Sprintf("Starting faceit_checker, listening on %s", cfg.HTTPAddress))

	go func() {
		err = srv.ListenAndServe()


@@ 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, errNoCSGOFaceit
		}
		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, errNoCSGOFaceit
	}

	return info, nil


@@ 440,7 440,7 @@ func (fc *faceitChecker) requestHandler(w http.ResponseWriter, r *http.Request) 

	accountList := accountsFromContext.([]steamAccount)
	length := len(accountList)
	var playerList []*FaceitPlayer
	var playerList []*faceitPlayer

	for _, account := range accountList {
		select {


@@ 449,7 449,7 @@ func (fc *faceitChecker) requestHandler(w http.ResponseWriter, r *http.Request) 
				slog.String("error", r.Context().Err().Error()))
			return
		default:
			player := &FaceitPlayer{}
			player := &faceitPlayer{}
			playerList = append(playerList, player)

			// Information is only needed if multiple accounts are displayed