Skip to content

Commit

Permalink
feat: 🎸 增加登录后可能登出的时间上报
Browse files Browse the repository at this point in the history
  • Loading branch information
chentianyu committed Oct 9, 2023
1 parent a0a5819 commit ef3539f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/route/loginCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { TextMsg } = require('../utils/msg')
// 登录
module.exports = function registerLoginCheck({ app, bot }) {
let message,
logOutWhenError = false,
success = false

bot
Expand All @@ -14,6 +15,7 @@ module.exports = function registerLoginCheck({ app, bot }) {
.on('login', user => {
message = user + 'is already login'
success = true
logOutWhenError = false
sendMsg2RecvdApi(new TextMsg({
text: JSON.stringify({ event: 'login', user }),
isSystemEvent: true
Expand All @@ -34,6 +36,17 @@ module.exports = function registerLoginCheck({ app, bot }) {
text: JSON.stringify({ event: 'error', error }),
isSystemEvent: true
}))

// 处理异常错误后的登出上报,每次登录成功后掉线只上报一次
if (!logOutWhenError && !bot.isLoggedIn) {
logOutWhenError = true
success = false
message = ''
sendMsg2RecvdApi(new TextMsg({
text: JSON.stringify({ event: 'logout', user }),
isSystemEvent: true
}))
}
})

// 处理 POST 请求
Expand Down

0 comments on commit ef3539f

Please sign in to comment.