auto-sync: 2026-04-05 17:32:06
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
import { SanguoMailbox } from '/Users/chufeng/.openclaw/sanguo_projects/sanguo_mail/dist/index.js';
|
||||
import { join } from 'path';
|
||||
|
||||
const CONFIG = {
|
||||
rootPath: '/Users/chufeng/.openclaw/sanguo_projects/sanguo_quant_live',
|
||||
teamName: 'sanguo-quant'
|
||||
};
|
||||
|
||||
async function checkMail() {
|
||||
const mailbox = new SanguoMailbox(CONFIG);
|
||||
await mailbox.initTeam();
|
||||
|
||||
const unreadMessages = await mailbox.listUnread('jiangwei');
|
||||
if (unreadMessages.length > 0) {
|
||||
console.log(`发现 ${unreadMessages.length} 条未读消息`);
|
||||
unreadMessages.forEach((msg, index) => {
|
||||
console.log(`[${index + 1}] 来自 ${msg.from} - ${msg.text.substring(0, 50)}${msg.text.length > 50 ? '...' : ''}`);
|
||||
});
|
||||
|
||||
await Promise.all(unreadMessages.map((msg, index) =>
|
||||
mailbox.markAsReadByIndex('jiangwei', index)
|
||||
));
|
||||
console.log('所有未读消息已标记为已读');
|
||||
}
|
||||
}
|
||||
|
||||
async function startAutoCheck(intervalSeconds) {
|
||||
console.log(`邮件检查服务已启动,检查间隔: ${intervalSeconds} 秒`);
|
||||
|
||||
checkMail();
|
||||
|
||||
setInterval(checkMail, intervalSeconds * 1000);
|
||||
}
|
||||
|
||||
startAutoCheck(parseInt(process.argv[2]) || 60);
|
||||
Reference in New Issue
Block a user