~xenrox/faceit_checker

ebba7edf514fc6877fb58d49db3cfcdd713a1b05 — Thorben Günther 11 months ago 71f9fad
Sanitize the nicknames

Removing the space chars should be enough for now.
2 files changed, 6 insertions(+), 4 deletions(-)

M faceit.go
M steam.go
M faceit.go => faceit.go +1 -3
@@ 366,7 366,6 @@ func (fc *faceitChecker) faceitHandler(w http.ResponseWriter, r *http.Request) {
				fc.logger.Errorf("faceitHandler: failed to parse SteamID (%s): %v", steamID, err)
				continue
			}
			// TODO: sanitize name
			steamAccountList = append(steamAccountList, fmt.Sprintf("%s_%s", id64, nickname))
		}
	} else {


@@ 380,8 379,7 @@ func (fc *faceitChecker) faceitHandler(w http.ResponseWriter, r *http.Request) {
				}
				return
			}
			// TODO: sanitize name
			steamAccountList = append(steamAccountList, fmt.Sprintf("%s_%s", steamProfile.ID64, steamProfile.Name))
			steamAccountList = append(steamAccountList, fmt.Sprintf("%s_%s", steamProfile.ID64, sanitizeName(steamProfile.Name)))
		}
	}


M steam.go => steam.go +5 -1
@@ 55,8 55,12 @@ func parseStatus(status string) (map[string]string, error) {
		if len(match) != 3 {
			continue
		}
		players[match[2]] = match[1]
		players[match[2]] = sanitizeName(match[1])
	}

	return players, nil
}

func sanitizeName(name string) string {
	return strings.ReplaceAll(name, " ", "")
}