Ban if vouchers over a certain threshold

oauth2
maru 2024-04-28 20:59:53 -04:00
parent bc8084b70b
commit e184e9da91
No known key found for this signature in database
GPG Key ID: 37689350E9CD0F0D
2 changed files with 16 additions and 0 deletions

View File

@ -39,6 +39,13 @@ func Update(uuid []byte, slot int, save any) error {
return fmt.Errorf("client version out of date")
}
if save.VoucherCounts["0"] > 300 ||
save.VoucherCounts["1"] > 150 ||
save.VoucherCounts["2"] > 100 ||
save.VoucherCounts["3"] > 10 {
db.UpdateAccountBanned(uuid, true)
}
err = db.UpdateAccountStats(uuid, save.GameStats, save.VoucherCounts)
if err != nil {
return fmt.Errorf("failed to update account stats: %s", err)

View File

@ -127,6 +127,15 @@ func UpdateAccountStats(uuid []byte, stats defs.GameStats, voucherCounts map[str
return nil
}
func UpdateAccountBanned(uuid []byte, banned bool) error {
_, err := handle.Exec("UPDATE accounts SET banned = ? WHERE uuid = ?", banned, uuid)
if err != nil {
return err
}
return nil
}
func FetchAndClaimAccountCompensations(uuid []byte) (map[int]int, error) {
var compensations = make(map[int]int)