上传文件至 /

This commit is contained in:
2025-10-15 19:42:27 +08:00
parent 4c142d19e6
commit 5cfee507f0
7 changed files with 660 additions and 0 deletions

70
delete.py Normal file
View File

@@ -0,0 +1,70 @@
bind_lock = asyncio.Lock()
async def _ensure_login(userId: int):
ts = generateTimestamp()
loginResult = apiLogin(ts, userId)
return ts, loginResult
async def delete(bot: Bot, event: MessageEvent, session: EventSession, message: UniMsg):
user_qq = str(event.user_id)
async with bind_lock:
if user_qq not in bind_data:
await MessageUtils.build_message("请先绑定 /bind").send(reply_to=True)
return
userId = bind_data[user_qq]
args = event.get_plaintext().strip().split()
if len(args) < 3:
await MessageUtils.build_message("用法: /del musicId levelId").send(reply_to=True)
return
try:
musicId = int(args[1])
levelId = int(args[2])
except Exception:
await MessageUtils.build_message("参数错误: musicId 和 levelId 必须是数字").send(reply_to=True)
return
ts, loginResult = await _ensure_login(userId)
return_code = loginResult.get("returnCode")
if return_code == 1:
pass
elif return_code == 100:
await MessageUtils.build_message("用户正在上机游玩,请下机后再试,或等待 15 分钟。").send(reply_to=True)
return
elif return_code == 102:
await MessageUtils.build_message("zako~zako~又不获取二维码吗").send(reply_to=True)
return
elif return_code == 103:
await MessageUtils.build_message("登录的账号 UID 无效,请检查账号是否正确。").send(reply_to=True)
return
else:
error_details = loginResult.get("message", str(loginResult))
await MessageUtils.build_message(f"登录失败!这不应该发生,请反馈此问题。\n错误详情:{error_details}").send(reply_to=True)
return
try:
result_str = implDeleteMusicRecord(userId, ts, loginResult, musicId, levelId)
msg = None
try:
result_json = json.loads(result_str) if isinstance(result_str, str) else result_str
if isinstance(result_json, dict):
if result_json.get("returnCode") == 1:
msg = f"🗑 成功删除成绩: musicId={musicId}, levelId={levelId}"
else:
msg = f"❌ 删除失败: {result_json.get('message', result_json)}"
except Exception:
pass
if not msg:
msg = f"删除成绩返回: {result_str}"
await MessageUtils.build_message(msg).send(reply_to=True)
except Exception as e:
await MessageUtils.build_message(f"❌ 删除成绩异常: {e}").send(reply_to=True)
logger.error(f"删除成绩异常: {e}")