Files
zhenxun_bot-sdgb_api/info.py
2025-10-15 19:42:27 +08:00

46 lines
1.5 KiB
Python

EXCLUDE_KEYS = {"isNetMember", "isInherit", "dispRate", "dailyBonusDate", "headPhoneVolume", "nameplateId", "iconId", "trophyId"}
MAPPING = {
"userName": "玩家昵称",
"isLogin": "是否在线",
"lastGameId": "最后游玩游戏ID",
"lastRomVersion": "最后ROM版本",
"lastDataVersion": "最后数据版本",
"lastLoginDate": "最后登录时间",
"lastPlayDate": "最后游玩时间",
"playerRating": "玩家Rating",
"totalAwake": "觉醒总数",
"banState": "封禁状态",
}
async def handle_info_logic(bot: Bot, message: UniMsg, session: EventSession):
user_qq = str(session.id1)
if user_qq not in bind_data:
await MessageUtils.build_message("❌ zako~又不绑定账号吗,请先使用 /bind 绑定。").send(reply_to=True)
return
user_id = bind_data[user_qq]
try:
raw = apiGetUserPreview(user_id)
data = json.loads(raw)
except Exception as e:
logger.error(f"获取用户预览失败: {e}")
await MessageUtils.build_message("❌ zako~获取用户信息失败了呢").send(reply_to=True)
return
for k in EXCLUDE_KEYS:
data.pop(k, None)
lines = []
for k, v in data.items():
if k == "userId":
continue
zh_key = MAPPING.get(k, k)
lines.append(f"{zh_key}: {v}")
msg = "📋 用户信息:\n" + "\n".join(lines)
await MessageUtils.build_message(msg).send(reply_to=True)