二维码消息当日仅发一条: 只在当天首次登录检查时发群(qr-sent标记持久化), 后续登录失效/被顶号异常只私聊简告+照常进扫码监听, 需重发需明确说明
This commit is contained in:
+32
-3
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user