|
|
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
|
|
// 简化版桐哥运势推送脚本
|
|
|
|
|
|
// 直接使用 Tavily 搜索 + 黄历 API
|
|
|
|
|
|
|
|
|
|
|
|
const { exec } = require('child_process');
|
|
|
|
|
|
const fs = require('fs').promises;
|
|
|
|
|
|
|
|
|
|
|
|
async function getDailyFortune() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 获取明天日期
|
|
|
|
|
|
const tomorrow = new Date();
|
|
|
|
|
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
|
|
|
|
const dateStr = tomorrow.toISOString().split('T')[0];
|
|
|
|
|
|
|
|
|
|
|
|
// 构建搜索查询
|
|
|
|
|
|
const queries = [
|
|
|
|
|
|
`金牛座 ${dateStr} 星座运势`,
|
|
|
|
|
|
`农历 ${dateStr} 黄历宜忌`,
|
|
|
|
|
|
`1984年5月16日生辰八字 ${dateStr} 运势`
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
console.log(`[INFO] 开始获取 ${dateStr} 的运势信息...`);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行 Tavily 搜索(通过 OpenClaw CLI)
|
|
|
|
|
|
const results = [];
|
|
|
|
|
|
for (const query of queries) {
|
|
|
|
|
|
const result = await new Promise((resolve, reject) => {
|
|
|
|
|
|
exec(`openclaw --profile main web_search "${query}"`,
|
|
|
|
|
|
{ timeout: 30000 },
|
|
|
|
|
|
(error, stdout, stderr) => {
|
|
|
|
|
|
if (error) {
|
|
|
|
|
|
console.error(`[ERROR] 搜索失败: ${query}`, error);
|
|
|
|
|
|
resolve(`搜索 "${query}" 失败`);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
resolve(stdout.trim());
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
results.push(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 构建消息
|
|
|
|
|
|
const message = `
|
|
|
|
|
|
🌙 桐哥的每日运势提醒
|
|
|
|
|
|
|
|
|
|
|
|
📅 明日:${dateStr}
|
|
|
|
|
|
♈ 星座:金牛座
|
|
|
|
|
|
📆 农历:待查询
|
|
|
|
|
|
|
|
|
|
|
|
✨ 星座运势:
|
|
|
|
|
|
${results[0]}
|
|
|
|
|
|
|
|
|
|
|
|
🏮 黄历信息:
|
|
|
|
|
|
${results[1]}
|
|
|
|
|
|
|
|
|
|
|
|
🔮 八字分析:
|
|
|
|
|
|
${results[2]}
|
|
|
|
|
|
|
|
|
|
|
|
🎯 趋吉避凶建议:
|
|
|
|
|
|
- 根据今日运势调整计划
|
|
|
|
|
|
- 注意情绪管理
|
|
|
|
|
|
- 把握有利时机
|
|
|
|
|
|
|
|
|
|
|
|
祝您明日顺心如意!❤️
|
|
|
|
|
|
`.trim();
|
|
|
|
|
|
|
|
|
|
|
|
// 保存到文件
|
|
|
|
|
|
await fs.writeFile(`/tmp/tongge-fortune-${dateStr}.txt`, message);
|
|
|
|
|
|
console.log(`[INFO] 运势消息已生成: /tmp/tongge-fortune-${dateStr}.txt`);
|
|
|
|
|
|
|
|
|
|
|
|
// 发送消息(通过 OpenClaw CLI)
|
|
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
|
|
exec(`openclaw --profile tongge message send --message "$(cat /tmp/tongge-fortune-${dateStr}.txt)" --channel telegram --to "tg:5237946060"`,
|
|
|
|
|
|
{ shell: '/bin/bash' },
|
|
|
|
|
|
(error, stdout, stderr) => {
|
|
|
|
|
|
if (error) {
|
|
|
|
|
|
console.error('[ERROR] 消息发送失败:', error);
|
|
|
|
|
|
reject(error);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.log('[INFO] 消息发送成功');
|
|
|
|
|
|
resolve(stdout);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('[FATAL] 运势获取失败:', error);
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 执行主函数
|
|
|
|
|
|
if (require.main === module) {
|
|
|
|
|
|
getDailyFortune();
|
|
|
|
|
|
}
|