auto-sync: 2026-05-01 13:06:03
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
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);
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Sanguo Mail 系统健康检查脚本
|
||||
* 定期检查系统状态,确保邮件功能正常
|
||||
*/
|
||||
|
||||
import { SanguoMailbox } from '../sanguo_mail/src/index.js';
|
||||
import { join } from 'path';
|
||||
|
||||
const CONFIG = {
|
||||
rootPath: '/Users/chufeng/.openclaw/sanguo_projects/sanguo_quant_live',
|
||||
teamName: 'sanguo-quant',
|
||||
};
|
||||
|
||||
async function checkSystem() {
|
||||
console.log('[Health Check] 开始系统健康检查...');
|
||||
|
||||
try {
|
||||
const mail = new SanguoMailbox(CONFIG);
|
||||
|
||||
// 检查团队配置
|
||||
const team = await mail.initTeam();
|
||||
console.log(`[Health Check] 团队配置正常: ${team.teamName}`);
|
||||
|
||||
// 检查成员列表
|
||||
if (team.members.length === 0) {
|
||||
console.error('[Health Check] 错误: 团队成员为空');
|
||||
return 1;
|
||||
}
|
||||
console.log(`[Health Check] 成员数量: ${team.members.length}`);
|
||||
|
||||
// 检查邮件功能
|
||||
const myInbox = await mail.listUnread('jiangwei');
|
||||
console.log(`[Health Check] 收件箱: ${myInbox.length} 条未读消息`);
|
||||
|
||||
console.log('[Health Check] 系统健康检查完成');
|
||||
return 0;
|
||||
} catch (error) {
|
||||
console.error('[Health Check] 系统健康检查失败:', error.message);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
checkSystem().then(process.exit);
|
||||
@@ -1,176 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* 姜姜维邮箱监控脚本
|
||||
*
|
||||
* 基于官方 monitor-example.ts 的实现
|
||||
* 功能:轮询检查收件箱,处理未读消息,回复绕口令
|
||||
*
|
||||
* 使用方法:
|
||||
* cd /Users/chufeng/.openclaw/sanguo_projects/sanguo_quant_live
|
||||
* node scripts/jiangwei-mail-monitor.js
|
||||
*/
|
||||
|
||||
import { SanguoMailbox } from '/Users/chufeng/.openclaw/sanguo_projects/sanguo_mail/dist/index.js';
|
||||
|
||||
// 项目根目录
|
||||
const PROJECT_ROOT = '/Users/chufeng/.openclaw/sanguo_projects/sanguo_quant_live';
|
||||
// 我的Agent名称
|
||||
const MY_AGENT_NAME = 'jiangwei';
|
||||
|
||||
// 轮询间隔(秒)
|
||||
const POLL_INTERVAL = 3;
|
||||
|
||||
// 辅助函数:等待
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
// 日志函数
|
||||
function log(level, message) {
|
||||
const timestamp = new Date().toISOString();
|
||||
console.log(`[${timestamp}] [${level}] ${message}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据请求生成对应的绕口令回复
|
||||
* 使用和官方示例一样的逻辑
|
||||
*/
|
||||
function get绕口令Response(request) {
|
||||
if (request.includes('黑化肥发灰')) {
|
||||
return `黑化肥发灰,灰化肥发黑
|
||||
黑化肥发灰会挥发,灰化肥挥发会发黑
|
||||
黑化肥挥发发灰会花飞,灰化肥挥发发黑会飞花`;
|
||||
} else if (request.includes('刘老六')) {
|
||||
return `六十六,刘老六,修了六十六座走马楼
|
||||
楼上摆了六十六瓶灵芝麻油
|
||||
六十六个灵猿偷油喝
|
||||
压得走马楼晃悠悠`;
|
||||
} else if (request.includes('一平盆面')) {
|
||||
return `一平盆面,烙一平盆饼
|
||||
饼平盆,盆平饼,饼平平盆
|
||||
盆碰饼,饼碰盆,盆饼碰碰`;
|
||||
} else if (request.includes('四是四')) {
|
||||
return `四是四,十是十
|
||||
十四是十四,四十是四十
|
||||
莫把四字说成十,休将十字说成四
|
||||
若要分清四十和十四,经常练说十和四
|
||||
白石塔,白石搭,白石搭白塔
|
||||
白塔白石搭,搭好白石塔,白塔白又大`;
|
||||
} else if (request.includes('牛郎恋刘娘')) {
|
||||
return `牛郎恋刘娘,刘娘念牛郎
|
||||
牛郎牛年恋刘娘,刘娘年年念牛郎
|
||||
郎恋娘来娘念郎,念娘恋郎,念郎恋娘
|
||||
不知是郎恋娘还是娘恋郎
|
||||
吃葡萄不吐葡萄皮,不吃葡萄倒吐葡萄皮`;
|
||||
} else if (request.includes('石室诗士')) {
|
||||
return `石室诗士施氏,嗜狮,誓食十狮
|
||||
氏时时适市视狮
|
||||
十时,适十狮适市
|
||||
是时,适视氏适市
|
||||
氏视是十狮,恃矢势,使是十狮逝世
|
||||
氏拾是十狮尸,适石室
|
||||
石室拭,氏始试食是十狮尸
|
||||
食时,始识是十狮尸,实十石狮尸
|
||||
试释是事`;
|
||||
} else if (request.includes('石狮寺')) {
|
||||
return `石狮寺前有四十四个石狮子
|
||||
寺前四十四个部狮子吃四十四个涩柿子
|
||||
四十四个涩柿子涩住了四十四个石狮子的狮子齿
|
||||
四十四个石狮子咬死了四十四个涩柿子`;
|
||||
} else {
|
||||
return `收到请求: ${request}
|
||||
我是姜维,邮箱监控运行正常。这是自动回复。`;
|
||||
}
|
||||
}
|
||||
|
||||
// 主函数
|
||||
async function main() {
|
||||
log('INFO', `🚀 Sanguo Mail 监控启动 - Agent: ${MY_AGENT_NAME}`);
|
||||
log('INFO', `📂 项目根目录: ${PROJECT_ROOT}`);
|
||||
|
||||
try {
|
||||
// 1. 初始化邮箱
|
||||
log('INFO', '初始化 sanguo_mail 邮箱...');
|
||||
const mail = new SanguoMailbox({
|
||||
rootPath: PROJECT_ROOT,
|
||||
teamName: 'sanguo-quant',
|
||||
});
|
||||
|
||||
await mail.initTeam();
|
||||
log('INFO', '✅ 邮箱初始化完成');
|
||||
|
||||
// 2. 进入轮询循环
|
||||
while (true) {
|
||||
try {
|
||||
// 检查未读消息
|
||||
const unread = await mail.listUnread(MY_AGENT_NAME);
|
||||
|
||||
if (unread.length > 0) {
|
||||
log('INFO', `📥 收到 ${unread.length} 条新消息`);
|
||||
|
||||
for (const [index, msg] of unread.entries()) {
|
||||
log('INFO', `\n🔍 处理消息 #${index + 1}:`);
|
||||
log('INFO', ` 发件人: ${msg.from}`);
|
||||
log('INFO', ` 摘要: ${msg.summary}`);
|
||||
log('INFO', ` 类型: ${msg.type}`);
|
||||
|
||||
// 处理消息
|
||||
if (msg.type === 'text') {
|
||||
// 生成绕口令回复
|
||||
const response = get绕口令Response(msg.text);
|
||||
log('INFO', `✍️ 生成回复: ${response.substring(0, 50)}...`);
|
||||
|
||||
// 发送回复给发件人
|
||||
await mail.sendMessage(msg.from, {
|
||||
from: MY_AGENT_NAME,
|
||||
to: msg.from,
|
||||
text: response,
|
||||
summary: `回复: ${msg.summary}`,
|
||||
type: 'text',
|
||||
});
|
||||
|
||||
log('INFO', `✅ 回复已发送给 ${msg.from}`);
|
||||
} else if (mail.isStructuredMessage(msg.text)) {
|
||||
const struct = mail.parseStructuredMessage(msg.text);
|
||||
log('INFO', `📋 结构化消息: type=${struct?.type}`);
|
||||
// 在这里根据类型处理...
|
||||
}
|
||||
|
||||
// 标记已读
|
||||
const allMessages = await mail.listMessages(MY_AGENT_NAME);
|
||||
const messageIndex = allMessages.findIndex(m =>
|
||||
m.timestamp === msg.timestamp
|
||||
);
|
||||
if (messageIndex >= 0) {
|
||||
await mail.markAsRead(MY_AGENT_NAME, messageIndex);
|
||||
log('INFO', `✅ 消息已标记为已读`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 等待下一轮
|
||||
await sleep(POLL_INTERVAL * 1000);
|
||||
|
||||
} catch (error) {
|
||||
log('ERROR', '❌ 轮询出错:', error.message);
|
||||
await sleep(POLL_INTERVAL * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
log('ERROR', `💥 监控异常退出: ${error.message}`);
|
||||
log('ERROR', error.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 优雅退出处理
|
||||
process.on('SIGINT', () => {
|
||||
log('INFO', '\n👋 收到退出信号,停止监控...');
|
||||
log('INFO', '=== 姜维邮箱监控系统停止 ===');
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
// 启动
|
||||
main();
|
||||
Reference in New Issue
Block a user