为用户提供每日天气推送服务,核心关注温度与昨天的对比变化,帮助用户快速决定今天穿什么、带什么出门。
数据来源:Open-Meteo(完全免费、无需API Key、全球覆盖、数据准确)。
检测用户是否已配置(通过 longterm-memory MCP 搜索 daily-weather-config)。
未配置时,按照 setup-guide.md 引导用户完成:
ask_followup_question 工具弹出选项,让用户点击选择城市、出行方式、推送时间(禁止让用户手动输入文字)python3 scripts/fetch_weather.py --auto-locate --travel-mode {模式}python3 scripts/fetch_weather.py --city "{城市}" --travel-mode {模式}~/.weather_email_config.json):```bash
python3 scripts/send_email.py --content "{天气报告内容}"
```
用户随时可以问"今天天气怎么样",直接运行脚本获取并展示。
使用 cron 工具 创建定时推送任务:
cron工具参数:
- action: "add"
- jobName: "每日天气出行指南"
- jobKind: "cron"
- cronExpression: "30 8 * * *" (默认8:30,根据用户设置调整)
- jobMessage: 内容见下方模板
jobMessage 模板:
请执行每日天气推送任务:
1. 使用 longterm-memory MCP 读取 daily-weather-config 获取用户配置
2. 根据配置中的 location_mode 决定定位方式:
- auto模式:运行 python3 /data/workspace/.agent/skills/daily-weather-guide/scripts/fetch_weather.py --auto-locate --travel-mode "{travel_mode}"
- fixed模式:运行 python3 /data/workspace/.agent/skills/daily-weather-guide/scripts/fetch_weather.py --city "{fixed_city}" --travel-mode "{travel_mode}"
3. 将脚本输出的天气报告通过 notify 工具推送给用户
You must use the notify tool to proactively inform me of the results, whether they are successful or an exception.
报告包含以下核心模块(按重要性排序):
# 自动IP定位获取天气
python3 scripts/fetch_weather.py --auto-locate --travel-mode "开车"
# 指定城市
python3 scripts/fetch_weather.py --city "深圳市南山区" --travel-mode "公共交通"
# 指定坐标
python3 scripts/fetch_weather.py --lat 22.54 --lon 113.93 --travel-mode "骑行"
# 仅获取IP定位
python3 scripts/fetch_weather.py --locate-only
# 仅地理编码
python3 scripts/fetch_weather.py --geocode "北京市海淀区"
# 输出原始JSON数据
python3 scripts/fetch_weather.py --city "上海" --json
用户随时可以说"修改天气推送设置"来重新配置:
共 1 个版本