From d30dcd953c8939e95fc853d5b541322488cdefdf Mon Sep 17 00:00:00 2001 From: hermes Date: Fri, 28 Aug 2026 06:02:57 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=BD=93=E6=97=A5=E4=BB=85=E5=8F=91=E4=B8=80=E6=9D=A1:=20?= =?UTF-8?q?=E5=8F=AA=E5=9C=A8=E5=BD=93=E5=A4=A9=E9=A6=96=E6=AC=A1=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=A3=80=E6=9F=A5=E6=97=B6=E5=8F=91=E7=BE=A4(qr-sent?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E6=8C=81=E4=B9=85=E5=8C=96),=20=E5=90=8E?= =?UTF-8?q?=E7=BB=AD=E7=99=BB=E5=BD=95=E5=A4=B1=E6=95=88/=E8=A2=AB?= =?UTF-8?q?=E9=A1=B6=E5=8F=B7=E5=BC=82=E5=B8=B8=E5=8F=AA=E7=A7=81=E8=81=8A?= =?UTF-8?q?=E7=AE=80=E5=91=8A+=E7=85=A7=E5=B8=B8=E8=BF=9B=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E7=9B=91=E5=90=AC,=20=E9=9C=80=E9=87=8D=E5=8F=91?= =?UTF-8?q?=E9=9C=80=E6=98=8E=E7=A1=AE=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/daily-runner.js | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/scripts/daily-runner.js b/scripts/daily-runner.js index ee03a9b..174f533 100644 --- a/scripts/daily-runner.js +++ b/scripts/daily-runner.js @@ -54,30 +54,58 @@ function sendGroupImage(text, imgPath) { execSync(`${HERMES} send -t "feishu:${GROUP}" -f /tmp/runner-imgmsg-${ACCT}.txt`, { stdio: ['pipe', 'pipe', 'pipe'], timeout: 90000 }); log(`已发送图片消息 → 群(数字HR)(附二维码)`); - } catch (e) { log(`图片消息发送失败: ${String(e.message).slice(0, 100)}`); } + return true; + } catch (e) { log(`图片消息发送失败: ${String(e.message).slice(0, 100)}`); return false; } +} + +// 二维码当日只发一次(2026-08-28 用户定稿:仅当天首次登录检查时发,后续异常不再发群) +let qrSentToday = false; +function qrAlreadySent() { + if (qrSentToday) return true; + const f = path.join(STATE_DIR, `qr-sent-${ACCT}-${today()}`); + if (fs.existsSync(f)) { qrSentToday = true; return true; } + return false; +} +function markQrSent() { + qrSentToday = true; + try { fs.writeFileSync(path.join(STATE_DIR, `qr-sent-${ACCT}-${today()}`), new Date().toISOString()); } catch { } } // 登录失效时:刷新页面抓登录二维码,发群(文字+二维码+补充说明) +// 当日已发过二维码 → 不再发群(私聊简告),二维码消息每天最多一条(2026-08-28 用户定稿) function notifyLoginExpired() { const label = `${ACCT}(${ACCT === 'hr1' ? 'Chrome·合塑账号' : 'Edge·派卡账号'})`; const text = `🚨 当前${label}账号登录已失效,今日筛选中止。扫码可重新登录:\n如今天不需要协助筛选简历,可忽略该二维码`; + if (qrAlreadySent()) { + log('今日二维码已发过,本次异常不再发群(私聊简告)'); + send(DM, `🚨 ${label}再次登录失效(今日二维码已发过群,不再重复发)。账号进入扫码监听`); + return; + } const qrPath = `/tmp/zhaopin-login-qr-${ACCT}.png`; try { execSync(`node ${SCRIPTS}/login-qrcode.js ${PORT} ${qrPath}`, { cwd: SCRIPTS, timeout: 90000, stdio: ['pipe', 'pipe', 'pipe'] }); if (fs.existsSync(qrPath) && fs.statSync(qrPath).size > 1000) { - sendGroupImage(text, qrPath); + if (sendGroupImage(text, qrPath)) markQrSent(); return; } log('二维码截图异常(文件过小或不存在),降级为纯文字'); } catch (e) { log(`二维码获取失败: ${String(e.message).slice(0, 100)},降级为纯文字`); } send(GROUP, `🚨 当前${label}账号登录已失效,今日筛选中止,请在任务机重新登录智联`); + markQrSent(); } // 被顶号告警:先关闭被顶弹窗/刷新页面 → 导航到登录页抓二维码 → 发群(文字+二维码+说明) async function notifyKickedOut(chatLeft) { const label = `${ACCT}(${ACCT === 'hr1' ? 'Chrome·合塑账号' : 'Edge·派卡账号'})`; const text = `🚨 ${label}被其他人登录了(账号在其他设备/浏览器登录,当前已退出),任务停止。如非本人操作请注意账号安全。扫码可重新登录:\n如今天不需要协助筛选简历,可忽略该二维码`; + // 当日已发过二维码 → 不再发群(私聊简告),2026-08-28 用户定稿 + if (qrAlreadySent()) { + log('今日二维码已发过,被顶号不再发群(私聊简告)'); + send(DM, `🚨 ${label}被顶号(今日二维码已发过群,不再重复发)。账号进入扫码监听`); + writeState('kicked_out', chatLeft); + return; + } const qrPath = `/tmp/zhaopin-login-qr-${ACCT}.png`; try { // 前置:关闭可能还挂着的被顶弹窗并刷新,让页面回到登录态 @@ -98,13 +126,14 @@ async function notifyKickedOut(chatLeft) { execSync(`node ${SCRIPTS}/login-qrcode.js ${PORT} ${qrPath}`, { cwd: SCRIPTS, timeout: 90000, stdio: ['pipe', 'pipe', 'pipe'] }); if (fs.existsSync(qrPath) && fs.statSync(qrPath).size > 1000) { - sendGroupImage(text, qrPath); + if (sendGroupImage(text, qrPath)) markQrSent(); writeState('kicked_out', chatLeft); return; } log('二维码截图异常,降级为纯文字'); } catch (e) { log(`二维码获取失败: ${String(e).slice(0, 100)},降级为纯文字`); } send(GROUP, `🚨 ${label}被其他人登录了(账号在其他设备/浏览器登录,当前已退出),任务停止。如非本人操作请注意账号安全`); + markQrSent(); writeState('kicked_out', chatLeft); }