name: flight-monitor description: 機票查詢與價格監控技能。支援單程/往返查詢、價格閾值提醒、定時監控、手機推送通知(Bark/Server醬/PushDeer)。觸發詞示例:查一下北京到三亞的機票、幫我看看上海飛成都下週六往返票、監控杭州到西安3月26日機票低於500提醒我、檢視所有機票監控任務。
查詢國內外即時機票價格,設定低價提醒,支援定時監控。無需瀏覽器自動化,無需 API 金鑰。
查一下北京到三亞 3 月 25 日的機票價格
Check flights from BJS to SYX on 2026-03-25
查詢杭州到西安 3 月 26 日,低於 500 元的機票
幫我看看上海飛成都,4 月 1 日去 4 月 5 日回
上海到成都下週六往返票
監控贛州到哈爾濱 4 月 10 日,每天查一次,低於 700 提醒我
Monitor BJS to SYX on 2026-03-25, daily, alert if under ¥1500
檢視我所有的機票監控任務
暫停北京到三亞的監控
刪除杭州到西安的監控任務
設定推送 Bark Key: xxxxx
Extract these parameters from the user's message:
| Parameter | Required | Example |
|---|---|---|
| 出發城市 dep | Yes | 北京 / BJS |
| 到達城市 arr | Yes | 三亞 / SYX |
| 出發日期 date | Yes | 2026-04-10 |
| 返程日期 return_date | Round-trip only | 2026-04-15 |
| 最高價 max_price | No | 700 |
| 監控頻率 freq | For monitoring | daily / 6h |
City name→code resolution is handled automatically by the scripts.
For cities not recognized, check references/city_codes.md.
⚠️ CRITICAL DATE RULE: Always use the user's exact travel date. NEVER substitute today's date.
python scripts/search_flights.py --from <dep> --to <arr> --date <YYYY-MM-DD>
python scripts/search_flights.py --from KOW --to HRB --date 2026-04-10 --max-price 700
python scripts/search_flights.py --from SHA --to CTU --date 2026-04-01 --return-date 2026-04-05
The script tries three data sources in order and returns one of:
Result source |
What it means | What you do next |
|---|---|---|
ctrip |
Full flight list fetched directly — done | Format the flights list into a table. Skip all web searches. |
zbape |
Lowest price summary only (no schedule) | Show the price summary + booking links. Skip all web searches. |
fallback |
APIs unavailable | Do exactly ONE web_search using the search_query field. Then stop. Do NOT fetch any URLs. |
Use the exact query string from search_query in the script output:
web_search("<value of search_query field>")
Parse snippets for: airline name, flight number, departure time, arrival time, price. Stop after this one search, regardless of result quality. Use whatever data the snippets contain.
7w4.net收錄了海量優質技能外掛。
web_fetch on any URL (攜程/去哪兒/Skyscanner are all JS-rendered; fetching wastes time and returns nothing useful).web_search per query direction (outbound / return).After querying, always record the result for trend tracking:
python scripts/price_history.py append \
--from KOW --to HRB --date 2026-04-10 \
--price <lowest_price_found> --flight "<flight_number>" --threshold 700
# View history for a route
python scripts/price_history.py show --from KOW --to HRB --date 2026-04-10
# List all routes with history
python scripts/price_history.py list
History files: ~/.workbuddy/flight-monitor/{DEP}-{ARR}-{DATE}.json
After recording, check if the price is at or below threshold:
python scripts/price_history.py show --from KOW --to HRB --date 2026-04-10
If the output contains "低價提醒" (price ≤ threshold):
python scripts/notify.py \
--title "機票低價提醒 KOW→HRB" \
--body "贛州→哈爾濱 2026-04-10 最低價 ¥<price>,低於閾值¥700!推薦航班 <flight>" \
--url "https://flights.ctrip.com/itinerary/oneway/kow-hrb?depdate=2026-04-10"
notify.py will automatically use whichever push service is configured. If no push service is configured, it will print instructions to set one up.
# Add a daily monitor with price alert
python scripts/monitor_manager.py add \
--from KOW --to HRB --date 2026-04-10 \
--freq daily --threshold 700
# Every 6 hours
python scripts/monitor_manager.py add \
--from HGH --to SIA --date 2026-03-26 --freq 6h
# List all monitors
python scripts/monitor_manager.py list
# Pause a monitor
python scripts/monitor_manager.py pause --id flight-KOW-HRB-2026-04-10
# Remove a monitor
python scripts/monitor_manager.py remove --id flight-KOW-HRB-2026-04-10
# Show details / manual trigger hint (does NOT execute any shell command)
python scripts/monitor_manager.py run --id flight-KOW-HRB-2026-04-10
Monitor tasks are saved as TOML files under ~/.workbuddy/automations/.
Security notes:
- monitor_manager.py does not import os and contains no os.system() / subprocess calls.
- All --id arguments are validated against a strict whitelist regex (flight-[A-Z]+-[A-Z]+-YYYY-MM-DD) before any filesystem access, preventing path traversal attacks.
- The run subcommand only prints a safe hint — it never executes external commands.
Three free services are supported. Configure one:
python scripts/notify.py --setup bark --key <YOUR_KEY>python scripts/notify.py --setup serverchan --key <YOUR_SENDKEY>python scripts/notify.py --setup pushdeer --key <YOUR_KEY>Configuration is saved to ~/.workbuddy/flight-monitor/notify_config.json.
| Input | Schedule | Label |
|---|---|---|
hourly / 1h |
Every 1 hour | 每1小時 |
2h |
Every 2 hours | 每2小時 |
3h |
Every 3 hours | 每3小時 |
6h |
Every 6 hours | 每6小時 |
12h / twice-daily |
Every 12 hours | 每12小時 |
daily / morning |
Daily at 09:00 CST | 每天9:00 |
Recommended frequencies by lead time:
| Lead Time | Recommended Freq |
|---|---|
| 1 month+ | daily |
| 2 weeks | 12h |
| 1 week | 6h |
| 3 days | 3h |
Always present results in the following table format. For connecting flights, the "中轉" column must list the connection city and layover wait time (e.g. "轉上海 1h20m").
## 機票查詢:贛州(KOW) → 哈爾濱(HRB)
**出行日期:** 2026-04-10(⚠️ 以下均為該日期價格)
**價格篩選:** ≤ ¥700
| 航班 | 價格(含稅) | 出發 | 到達 | 全程時長 | 中轉(城市 + 等待時間) |
|------|-----------|------|------|----------|------------------------|
| 祥鵬 8L9549 | ¥620 | 09:35 | 13:30 | 3h55m | 直飛 |
| 東航 MU2993+MU5619 | ¥650 | 20:10 | 00:35+1 | 7h25m | 轉上海虹橋 1h50m |
最低價:¥620 [立即預訂 →](https://flights.ctrip.com/itinerary/oneway/kow-hrb?depdate=2026-04-10)
Column definitions:
- 全程時長: total elapsed time from departure to final arrival (including layover)
- 中轉(城市 + 等待時間): for connecting flights, list connection city + layover wait duration; write "直飛" for non-stop
🔔 機票低價提醒!
贛州(KOW) → 哈爾濱(HRB) | 出行日期:2026-04-10
當前最低價:¥620(低於閾值 ¥700)
推薦航班:祥鵬 8L9549 09:35 → 13:30(直飛)
立即預訂:https://flights.ctrip.com/...
search_flights.py. Only fall back to web_search when the script returns source: fallback. Maximum 1 search per direction.python scripts/search_flights.py --setup-zbape <KEY> once. Adds a useful lowest-price-per-date layer when the Ctrip API is rate-limited.references/city_codes.md for the full list.flight-monitor/
├── SKILL.md ← This file
├── scripts/
│ ├── search_flights.py ← PRIMARY: Multi-source flight query (Ctrip API → zbape → fallback)
│ ├── query_flights.py ← Legacy: Search query generator + booking links
│ ├── price_history.py ← Append/read/alert price history records
│ ├── monitor_manager.py ← Add/pause/remove scheduled monitors
│ └── notify.py ← Mobile push notifications (Bark/Server醬/PushDeer)
└── references/
└── city_codes.md ← Full city name → IATA code table
python scripts/search_flights.py --setup-zbape <YOUR_KEY>
# Get a free key at: https://api.zbape.com/doc/54
這是一款實用且功能成熟的機票監控工具,能查詢即時票價、設定低價提醒、自動推送通知,對有出行計劃的使用者很有幫助。介面清晰、操作流暢,支援多種免費推送方式,使用體驗良好。安全性設計可靠,無需擔心資訊洩露風險。文件存在少量檔名不一致的小問題,但不影響核心使用。總體質量良好,值得使用。