日报v1.5: 模板定稿(命中列清洗证书前缀); 按账号分开发送--account参数+收队逐账号各发一条, 不再合并合集; 无数据账号自动跳过
This commit is contained in:
@@ -99,18 +99,31 @@ const sentFlag = path.join(STATE_DIR, `report-sent-${today()}`);
|
||||
if (s.date === today()) env[skey] = map[s.status] || '✅ 在线';
|
||||
} catch { }
|
||||
}
|
||||
const md = execSync(`node ${SCRIPTS}/daily-report.js`, { cwd: SCRIPTS, encoding: 'utf8', timeout: 60000, env });
|
||||
// v1.2(2026-09-02 用户定稿):两个账号都没开工 → 日报输出为空 → 不发送
|
||||
if (!md.trim()) {
|
||||
// v1.3(2026-09-15 用户定稿):按账号分开发送,每个开工账号一条消息(不再合并合集)
|
||||
const { execSync: es } = require('child_process');
|
||||
// 先探一次全量渲染拿开工账号列表(输出空=都没开工)
|
||||
const probe = es(`node ${SCRIPTS}/daily-report.js`, { cwd: SCRIPTS, encoding: 'utf8', timeout: 60000, env });
|
||||
if (!probe.trim()) {
|
||||
log('双账号今日均无数据,日报不发送(不发空消息)');
|
||||
fs.writeFileSync(sentFlag, new Date().toISOString());
|
||||
reportSent = 'skipped_empty';
|
||||
} else {
|
||||
fs.writeFileSync(`/tmp/daily-report-enforce-${today()}.md`, md);
|
||||
execSync(`${HERMES} send -t "feishu:${GROUP}" -f /tmp/daily-report-enforce-${today()}.md`, { stdio: ['pipe', 'pipe', 'pipe'], timeout: 60000 });
|
||||
// 判断开工账号:有数据的才发
|
||||
for (const [acct, envKeys] of [['hr1', { left: 'CHAT_LEFT_HR1', st: 'HR1_STATUS' }], ['hr2', { left: 'CHAT_LEFT_HR2', st: 'HR2_STATUS' }]]) {
|
||||
const envA = { ...env };
|
||||
try {
|
||||
const s = JSON.parse(fs.readFileSync(path.join(STATE_DIR, `state-${acct}.json`), 'utf8'));
|
||||
if (s.chatLeft != null) envA[envKeys.left] = String(s.chatLeft);
|
||||
if (s.date === today()) envA[envKeys.st] = s.status === 'time_cutoff' ? '✅' : (s.status === 'running' ? '✅' : '⚠️' + s.status);
|
||||
} catch { }
|
||||
const mdA = es(`node ${SCRIPTS}/daily-report.js --account ${acct}`, { cwd: SCRIPTS, encoding: 'utf8', timeout: 60000, env: envA });
|
||||
if (!mdA.trim()) continue; // 该账号无数据,跳过不发
|
||||
fs.writeFileSync(`/tmp/daily-report-${acct}-${today()}.md`, mdA);
|
||||
es(`${HERMES} send -t "feishu:${GROUP}" -f /tmp/daily-report-${acct}-${today()}.md`, { stdio: ['pipe', 'pipe', 'pipe'], timeout: 60000 });
|
||||
log(`${acct} 日报已单独发送到群 ✅`);
|
||||
}
|
||||
fs.writeFileSync(sentFlag, new Date().toISOString());
|
||||
reportSent = true;
|
||||
log('日报已发送到群 ✅');
|
||||
}
|
||||
} catch (e) { findings.push(`日报发送失败: ${String(e.message).slice(0, 150)}`); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user