From aa0907c00360e1e6527f2516e7332c7255967bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Wed, 27 Nov 2024 10:36:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=9A=E6=8E=A8=E9=80=81undefined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/task/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/models/task/index.js b/models/task/index.js index 8f24a53..6d4810e 100644 --- a/models/task/index.js +++ b/models/task/index.js @@ -73,7 +73,7 @@ export function startTimer () { state: [] } } - if (player.gameid != lastPlay.appid && Config.push.enable) { + if (Config.push.enable && player.gameid && player.gameid != lastPlay.appid) { state.time = now userList[i.groupId][i.botId].start.push({ name: player.gameextrainfo, @@ -82,7 +82,7 @@ export function startTimer () { header_image: iconUrl }) } - if (lastPlay.name != player.gameextrainfo && Config.push.enable) { + if (Config.push.enable && lastPlay.name != player.gameextrainfo) { state.time = now userList[i.groupId][i.botId].end.push({ name: lastPlay.name, @@ -92,7 +92,7 @@ export function startTimer () { }) } // 在线状态改变 - if (player.personastate != lastPlay.state && Config.push.stateChange) { + if (Config.push.stateChange && player.personastate != lastPlay.state) { state.time = now userList[i.groupId][i.botId].state.push({ name: `${nickname}(${player.personaname})`, @@ -105,7 +105,7 @@ export function startTimer () { } } else { // 如果有gameid就是开始玩 - if (player.gameid != lastPlay.appid && Config.push.enable) { + if (Config.push.enable && player.gameid && player.gameid != lastPlay.appid) { state.time = now msg.push(`${nickname}(${player.personaname}) 正在玩 ${player.gameextrainfo}`) // 看看上次有没有在玩别的游戏 @@ -116,10 +116,10 @@ export function startTimer () { } // 记录这一次的状态 // 如果有上次记录就是结束游玩 - } else if (lastPlay.name != player.gameextrainfo && Config.push.enable) { + } else if (Config.push.enable && lastPlay.name && lastPlay.name != player.gameextrainfo) { state.time = now msg.push(`${nickname}(${player.personaname}) 已结束游玩 ${lastPlay.name} 时长 ${utils.formatDuration(now - lastPlay.time)}`) - } else if (player.personastate != lastPlay.state && Config.push.stateChange) { + } else if (Config.push.stateChange && player.personastate != lastPlay.state) { state.time = now msg.shift() msg.push(`${nickname}(${player.personaname}) 已${utils.getPersonaState(player.personastate)}`)