feat(score): add simple suspicious score check

TODO: use another lib to check the beatmap is whether suspicious or not
This commit is contained in:
MingxuanGame
2025-08-14 07:44:13 +00:00
parent 48b075d99d
commit 2c7c761a44
4 changed files with 17 additions and 1 deletions

View File

@@ -55,6 +55,7 @@ ENABLE_ALL_MODS_PP=false # 启用所有 Mod 的 PP 计算
ENABLE_SUPPORTER_FOR_ALL_USERS=false # 启用所有新注册用户的支持者状态
ENABLE_ALL_BEATMAP_LEADERBOARD=false # 启用所有谱面的排行榜(没有排行榜的谱面会以 APPROVED 状态返回)
ENABLE_ALL_BEATMAP_PP=false # 允许任何谱面获得 PP
SUSPICIOUS_SCORE_CHECK=true # 是否检查可疑的分数,默认开启
SEASONAL_BACKGROUNDS='[]' # 季节背景图 URL 列表
# 存储服务设置

View File

@@ -115,6 +115,7 @@ Fetcher 用于从 osu! 官方 API 获取数据,使用 osu! 官方 API 的 OAut
| `ENABLE_SUPPORTER_FOR_ALL_USERS` | 启用所有新注册用户的支持者状态 | `false` |
| `ENABLE_ALL_BEATMAP_LEADERBOARD` | 启用所有谱面的排行榜 | `false` |
| `ENABLE_ALL_BEATMAP_PP` | 允许任何谱面获得 PP | `false` |
| `SUSPICIOUS_SCORE_CHECK` | 启用可疑分数检查star>25&acc<80 或 pp>2300 | `true` |
| `SEASONAL_BACKGROUNDS` | 季节背景图 URL 列表 | `[]` |
### 存储服务设置

View File

@@ -3,6 +3,8 @@ from __future__ import annotations
import math
from typing import TYPE_CHECKING
from app.config import settings
from app.log import logger
from app.models.beatmap import BeatmapAttributes
from app.models.mods import APIMod
from app.models.score import GameMode
@@ -75,7 +77,18 @@ def calculate_pp(
misses=score.nmiss,
)
attrs = perf.calculate(map)
return attrs.pp
pp = attrs.pp
# mrekk bp1: 2048pp; ppy-sb top1 rxbp1: 2198pp
if settings.suspicious_score_check and (
(attrs.difficulty.stars > 25 and score.accuracy < 0.8) or pp > 2300
):
logger.warning(
f"User {score.user_id} played {score.beatmap_id} with {pp=} "
f"acc={score.accuracy}. The score is suspicious and return 0pp"
f"({score.id=})"
)
return 0
return pp
# https://osu.ppy.sh/wiki/Gameplay/Score/Total_score

View File

@@ -94,6 +94,7 @@ class Settings(BaseSettings):
enable_supporter_for_all_users: bool = False
enable_all_beatmap_leaderboard: bool = False
enable_all_beatmap_pp: bool = False
suspicious_score_check: bool = True
seasonal_backgrounds: list[str] = []
# 存储设置