Skip to content

Commit

Permalink
fix: 会推送undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Nov 27, 2024
1 parent 4a1b649 commit aa0907c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions models/task/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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})`,
Expand All @@ -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}`)
// 看看上次有没有在玩别的游戏
Expand All @@ -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)}`)
Expand Down

0 comments on commit aa0907c

Please sign in to comment.