Files
TaiYangGongGong/README.md
T
2026-04-11 22:02:38 +08:00

87 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 太阳公公监控
监控局域网设备上线,配合 AI 生成个性化早安邮件。
## 功能
- **Ping 监控**:监控指定局域网 IP 是否在线
- **首次上线通知**:目标设备首次上线时,发送"太阳公公出来了"邮件,包含具体上线时间
- **未到提醒**:每天 8:15 前目标仍未上线,发送"太阳公公还在睡觉"邮件
- **AI 早安文案**:三段式早安邮件
- 第一段:太阳公公状态(AI 单独生成)
- 第二段:今日天气(AI 生成,自然衔接)
- 第三段:今日热搜(AI 找关联,像说相声一样串联成自然段落)
- **每日重置**:状态文件每日自动重置,避免重复发送
## 运行时间
每天凌晨 2:00 至晚上 22:00 自动监控
## 文件结构
```
TaiYangGongGong/
├── ping_monitor.py # 主脚本(常驻运行)
├── test_ping.py # 测试脚本(单次测试)
├── config.py # 敏感配置(API密钥、邮件账号等)- 不上传
└── .ping_state/ # 状态文件目录 - 不上传
├── state.json
├── weather_cache.json
└── news_cache.json
```
## 首次使用
1. 复制配置模板并填入你的信息:
```bash
cp config.py config.py.bak
# 然后编辑 config.py,填入你的 API 密钥和邮件配置
```
2. 配置 `config.py`
```python
# DeepSeek API
DEEPSEEK_API_KEY = "your_api_key"
# 邮件配置
SMTP_SERVER = "smtp.qq.com"
SMTP_PORT = 587
SMTP_USER = "your_email@qq.com"
SMTP_PASSWORD = "your授权码"
FROM_NAME = "月亮姐姐"
TO_EMAILS = ["target_email@example.com"]
```
3. 设置系统时区(邮件时间戳用系统时间):
```bash
sudo timedatectl set-timezone Asia/Shanghai
sudo ntpdate ntp.aliyun.com # 同步网络时间
```
4. 安装依赖并运行:
```bash
pip install requests
python test_ping.py # 测试
python ping_monitor.py # 正式运行
```
## 部署
```bash
# 添加到 crontab,每天凌晨2点自动启动
crontab -e
# 添加:
0 2 * * * cd /home/lhr/storage/TaiYangGongGong && python ping_monitor.py >> ping.log 2>&1 &
```
## 依赖
```bash
pip install requests
```