Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
perf: ⚡️ 精简无用代码&增加运行调试模式
Browse files Browse the repository at this point in the history
  • Loading branch information
chentianyu committed Oct 9, 2023
1 parent a694054 commit e3d8bad
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docker Build and Push

on:
push:
branches:
- nightly

jobs:
build:
if: contains(github.event.head_commit.message, '[skip ci]') == false
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: dannicool
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and Push Docker Image
run: |
docker build . -t dannicool/docker-wechatbot-webhook:nightly
docker push dannicool/docker-wechatbot-webhook:nightly
1 change: 0 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const wechatBotInit = require('./src/wechaty/init')
const registerRoute = require('./src/route')
const app = express();
const bot = wechatBotInit()
const chalk = require('chalk')

app.use(express.json());

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"prestart": "node ./scripts/preStart",
"start": "node main"
"start": "node main",
"debug": "node --inspect main"
},
"author": {
"name": "danni-cool",
Expand Down
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 e3d8bad

Please sign in to comment.