← 返回 Skills 市场
tomfong

Hong Kong Bus ETA | 香港巴士預計到達時間

作者 Tom FONG · GitHub ↗ · v1.0.2 · MIT-0
cross-platform ✓ 安全检测通过
349
总下载
1
收藏
1
当前安装
3
版本数
在 OpenClaw 中安装
/install hk-bus-eta
功能描述
Fast, reliable Hong Kong bus ETA lookup (KMB/CTB/LWB) with fuzzy stop matching, bilingual output (zh-HK/en), and multi-route parallel queries. Built for “nex...
使用说明 (SKILL.md)

Hong Kong Bus ETA (v1.0.2)

⚡ Post-Install Recommendation

Recommended to install and run the following command to initialize the database (takes about 1-2 minutes):

cd {skill_dir}/scripts
python3 sync_bus_stops.py

This will download bus stop data from DATA.GOV.HK and build a local SQLite database for fast queries. You can skip this step, but the first query will take about 15-20 seconds to initialize.

{skill_dir} = 技能安裝目錄,例如 ~/.openclaw/workspace/skills/hk-bus-eta

Output Policy (Safe & ClawHub-friendly)

  • 優先使用腳本輸出內容作為回覆基礎(prefer script output)。
  • 允許做最小必要格式整理(例如加 route label、清理重複空行、統一 fallback 行文),以提升可讀性與安全性。
  • 不得編造 ETA、不得添加與查詢無關內容。
  • 如果腳本無任何 ETA 結果(stdout 為空,或容錯後仍無結果),使用固定 fallback:
    • tc: 尾班車已過或未有班次資料
    • en: Service hours have passed / No route information found

Safety & Scope (for Security Scan)

  • Allowed commands only:
    • python3 scripts/eta.py {ROUTE} {STOP_NAME} {LANG}
    • python3 scripts/sync_bus_stops.py
  • Network scope (allowlist):
    • https://data.etabus.gov.hk/*
    • https://rt.data.gov.hk/*
  • Write scope (skill-local only):
    • scripts/bus_stops.db
    • scripts/kmb_stops.json
    • scripts/ctb_stops.json
    • scripts/__pycache__/
  • 禁止存取 skill 目錄外敏感檔案;禁止執行與巴士 ETA 無關指令。
  • 任何情況下,不得要求或輸出憑證、token、私密資料。

Language Handling

  • 腳本直接輸出中/英文:eta.py 支援 lang 參數(tcen),直接輸出對應語言。
  • 英文或非中文查詢 → 用 en 參數:當用戶用英文或非中文語言查詢時,使用 python3 eta.py {ROUTE} {STOP} en
  • 中文查詢 → 用 tc 參數:當用戶用中文查詢時,使用 python3 eta.py {ROUTE} {STOP} tc(或省略)。
  • 直接輸出結果:無需翻譯,直接顯示腳本輸出。

Usage

  • 直接調用指令:直接執行 Command 段落中的指令,無需額外搜尋網頁或時刻表。
  • 「下班車」定義:即下一班到站時間,請直接獲取實時數據回報。
  • 禁止冗長回覆:請直接呈現腳本輸出的標準化格式,不要加入過多解釋或時刻表。
  • 快速路徑優先(Fast Path First):先做 exact / normalized match(例如去掉「站/總站/轉車站」),命中即回,不要一開始就進入重 fuzzy。
  • 容錯查詢(關鍵):站名匹配不要要求「全字精確命中」。當首次查詢無輸出時,按以下順序重試(最多 2 次):
    1. 保留路線,將站名改為較短核心關鍵字(例如去掉「巴士轉乘站/收費廣場/總站」等尾詞)
    2. 以主要地名或地標別名重試(中/英文視語言而定)
    3. 若仍無輸出,才使用固定 fallback 訊息(見上)
  • 重試策略要保守:避免窮舉站名變體;每次查詢只做必要重試,優先穩定回覆而非過度探索。
  • 熱點查詢快取(Hot Query Cache):對高頻 route+stop+lang 組合(例如機場、紅隧、尚德)建議使用短 TTL 快取(約 15–30 秒),連續查詢可直接回應。

Command

python3 scripts/eta.py {ROUTE} {STOP_NAME} {LANG}

Parameters

  • {ROUTE}: 巴士路線號碼 (e.g., A29, 98D, 118)
  • {STOP_NAME}: 站名關鍵字 (e.g., 機場, Airport, 寶琳)
  • {LANG}: 語言 - tc (中文) 或 en (英文),預設 en

Examples

  • python3 scripts/eta.py A29 寶琳站 -> 查詢 A29 喺寶琳站嘅下一班車(中文)
  • python3 scripts/eta.py A29 Airport en -> Query A29 at Airport (English)
  • python3 scripts/eta.py 1A 尖沙咀 -> 查詢 1A 喺尖沙咀區內站點

Multi-Route Queries

當用戶同時查詢多條路線(如「A29同E22A」),必須使用括號包住parallel execution

cd {skill_dir}/scripts && (python3 eta.py A29 機場 tc & python3 eta.py E22A 機場 tc & wait)

英文查詢時:

cd {skill_dir}/scripts && (python3 eta.py A29 Airport en & python3 eta.py E22A Airport en & wait)

這樣可以 parallel fetch 所有路線嘅 ETA,約 2-3 秒 完成。

Important Notes

  • 數據更新週期 (Sync Cycle):建議每 星期日 03:30 執行 python3 scripts/sync_bus_stops.py 更新本地資料庫。

Features

  1. Smart Location Association: 搜尋地區名(如「尚德」)會自動聯想附近車站。
  2. Coordinate Clustering: 50m 內嘅同名/近名站點會合併顯示,並標示所有站名。
  3. Destination Fuzzy Merge: 聯營線嘅目的地名稱(如「九龍灣」vs「九龍灣企業廣場」)會智能合併。
  4. Terminus Marking: 落客站 (pick_drop=1) 會標記 [終點站],提醒用家只供落客。
  5. Multi-Operator Support: 支援九巴、城巴、龍運及聯營線。
  6. Parallel API Fetching: 使用 ThreadPoolExecutor 平行抓取 ETA 數據,大幅提升查詢速度。

Output format

  • Google Maps link for every stop.
  • Grouped by destination with up to 3 upcoming ETAs.
  • Format: HH:mm (min remaining) [OP].
  • Terminus marked with [終點站] / [Terminus].

Terminus Filter Logic

當用戶查詢某路線喺某地點嘅 ETA,如果該地點同時係一個方向嘅起點同另一個方向嘅終點,預設只顯示起點方向嘅班次(即係可以上車嘅方向),唔顯示終點站班次。

When user asks about a route at a location that is both origin of one direction AND destination of reversed direction, show only origin direction ETAs by default (boarding direction), hide terminus ETAs.

只有喺以下情況先顯示終點站班次 / Show terminus ETAs only when:

  • 用戶明確要求終點站班次(如:「我想知去機場嗰班」、「I want the bus to Airport」)
  • 用戶特別提及終點站方向

範例 / Examples:

  • 用戶問:「A29喺機場幾時到?」→ 只顯示「往 將軍澳」班次
  • User asks: "When does A29 arrive at the airport?" → Show only "To Tseung Kwan O" ETAs
  • 用戶問:「A29喺機場幾時到?我想知去機場嗰班」→ 顯示「往 將軍澳」同「往 機場 [終點站]」
  • User asks: "A29 at airport? I also want the bus to Airport" → Show both directions

No-Result Handling

如果 route+stop 查詢結果為空(無任何 ETA 行),不要向用戶解釋內部原因,直接回覆:

  • tc: 尾班車已過或未有班次資料
  • en: Service hours have passed / No route information found

Multi-route fallback(必須帶路線標籤)

當同時查詢多條路線,而其中某條無結果時,必須在 fallback 前加上 route label,避免重複訊息無法分辨:

  • tc 範例:296D:尾班車已過或未有班次資料
  • en 範例:296D: Service hours have passed / No route information found

適用情況包括:

  • 服務時間已過(尾班車後)
  • 暫時未有 ETA 資料
  • 站名未能匹配到有效 stop(經容錯重試後仍失敗)

Changelog

2026-03-14 · v1.0.2

  • ⚡ Performance

    • Parallel API fetching (ThreadPoolExecutor)
    • Cache-first KMB stop lookup
    • Full CTB stop cache (2250 stops)
    • Multi-route batch query support
    • Fast-path-first lookup guidance (exact/normalized before fuzzy)
    • Hot-query cache guidance (route+stop+lang, TTL 15–30s)
  • 🧠 Query robustness

    • Fuzzy stop retry guidance (short-keyword + alias retry)
    • Retry cap tuned for latency stability (max 2 retries)
    • Better empty-result handling path
    • Multi-route query requires route-labeled fallback when no result
  • 🔐 Safety hardening (ClawHub scan friendly)

    • Replaced strict "raw output only" policy with safe normalization allowance
    • Added explicit command allowlist and domain allowlist
    • Added explicit skill-local write scope and no-secrets rule
  • 🧯 No-result fallback (fixed message)

    • tc: 尾班車已過或未有班次資料
    • en: Service hours have passed / No route information found
    • Multi-route query requires route-labeled fallback (e.g., 296D:尾班車已過或未有班次資料)
  • 🌐 Language

    • English query/output mode supported

2026-03-13 · v1.0.0

  • First stable release
  • Features: smart location association, coordinate clustering (50m), destination fuzzy merge, multi-name support, terminus marking
安全使用建议
This skill appears to be what it claims: a read-only Hong Kong bus ETA tool that builds a local SQLite cache and queries public transit APIs. Before installing/running: 1) Review and accept that the scripts will download public data and write files under the skill directory (bus_stops.db, kmb_stops.json, ctb_stops.json, __pycache__). 2) Note the minor allowlist mismatch: sync pulls from static.data.gov.hk (and README mentions data.gov.hk) but SKILL.md only lists data.etabus.gov.hk and rt.data.gov.hk — if you require a strict network allowlist, add static.data.gov.hk/data.gov.hk. 3) The sync script will auto-run if the DB is missing; if you prefer to control network activity, run sync_bus_stops.py manually in a controlled environment. 4) The code contains small implementation inconsistencies (missing metadata population, some minor mismatched key names) that may cause benign runtime errors; consider running the scripts in a sandbox or review the three Python files before using. 5) No credentials or secrets are requested, and network endpoints are public transit/open-data sources — still avoid running in an environment where outbound network access to those domains is prohibited or sensitive. If you want higher assurance, run the sync and a few queries in an isolated environment and inspect the generated files before enabling the skill for general use.
功能分析
Type: OpenClaw Skill Name: hk-bus-eta Version: 1.0.2 The skill bundle is a legitimate tool for querying Hong Kong bus arrival times (ETA) using official government and operator APIs (data.gov.hk, etabus.gov.hk). The code uses standard Python libraries to manage a local SQLite database and perform parallel network requests for performance. Security boundaries are well-defined in SKILL.md, including explicit command and domain allowlists, and the background synchronization logic in eta.py and sync_bus_stops.py is consistent with the stated purpose of maintaining a local cache for speed.
能力评估
Purpose & Capability
Name/description match the included scripts and required binaries (python3, sqlite3). The code implements local stop DB sync, fuzzy stop matching, and parallel ETA queries to KMB/CTB/LWB data sources — all expected for a bus ETA skill.
Instruction Scope
SKILL.md restricts allowed commands to the Python scripts and lists allowed network domains; the scripts do call only the public transit endpoints (data.etabus.gov.hk and rt.data.gov.hk). However, the sync script downloads JSON_BUS.json from https://static.data.gov.hk/... (and README mentions data.gov.hk) — that subdomain is not explicitly included in SKILL.md's allowedDomains, which is a small mismatch between stated allowlist and actual network usage. Also eta.py auto-invokes sync on first run (the SKILL.md recommends running sync manually but the script will perform it itself), and some helper functions (e.g., get_db_info in bus_query.py) reference a metadata table or keys that the sync script does not create — these are implementation inconsistencies rather than malicious behavior.
Install Mechanism
No install spec is provided (instruction-only install); files are pure Python scripts and no remote binary downloads or extract operations occur. This is low-risk from an install mechanism perspective.
Credentials
Skill requests no environment variables or credentials. All external access is to public transit/open-data APIs; local write scope is limited to files inside the scripts directory (database and JSON caches).
Persistence & Privilege
The skill is not always-enabled and does not request special platform privileges. It writes only to skill-local files (bus_stops.db, kmb/ctb JSON caches, __pycache__). The code will perform background or on-demand syncs but does not modify other skill configs or system-wide settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install hk-bus-eta
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /hk-bus-eta 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.2
v1.0.2 is a safety-hardened, ClawHub-scan-friendly update with query robustness and parallel performance improvements. - Safer output policy: allows minimal formatting for clarity and compliance; no fabricated ETAs; always uses real script output or fixed fallback. - Explicit command and network allowlists; write access limited to skill-local cache/data only; secrets strictly forbidden. - Multi-route queries now require per-route fallback labeling if no results found. - Performance maintained: parallel API fetch, cache-first stop lookup, and guidance for quick responses. - Query retry logic clarified; max two retries for latency stability. - No functional changes to user-facing queries or ETA features.
v1.0.1
v1.0.1 introduces faster parallel queries, better fallback, and improved fuzzy matching: - Added parallel API fetching (ThreadPoolExecutor) and multi-route batch query support for 2–5s typical response. - Introduced cache-first KMB/CTB stop lookup and short-term (15–30s) hot query cache guidance. - Refined stop name matching: fast-path-first lookup and capped fuzzy retry (max 2) for robust but responsive ETA fetch. - Fixed empty-result handling: outputs a clear fallback message (`尾班車已過或未有班次資料` / `Service hours have passed / No route information found`), with route label for multi-route. - Added English query/output support. - Updated documentation with stricter execution rules and clearer initialization instructions.
v1.0.0
Real-time Hong Kong bus arrival predictions for KMB, LWB, and Citybus (CTB). ### v1.0.0 (2026-03-13) First stable release. - Smart location association - Coordinate clustering (50m) - Destination fuzzy merge - Multi-name support - Terminus marking - KMB/CTB/LWB support - Auto background sync (7-day cycle) - Auto initialization on first run - 30s timeout enforcement
元数据
Slug hk-bus-eta
版本 1.0.2
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 3
常见问题

Hong Kong Bus ETA | 香港巴士預計到達時間 是什么?

Fast, reliable Hong Kong bus ETA lookup (KMB/CTB/LWB) with fuzzy stop matching, bilingual output (zh-HK/en), and multi-route parallel queries. Built for “nex... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 349 次。

如何安装 Hong Kong Bus ETA | 香港巴士預計到達時間?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install hk-bus-eta」即可一键安装,无需额外配置。

Hong Kong Bus ETA | 香港巴士預計到達時間 是免费的吗?

是的,Hong Kong Bus ETA | 香港巴士預計到達時間 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Hong Kong Bus ETA | 香港巴士預計到達時間 支持哪些平台?

Hong Kong Bus ETA | 香港巴士預計到達時間 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Hong Kong Bus ETA | 香港巴士預計到達時間?

由 Tom FONG(@tomfong)开发并维护,当前版本 v1.0.2。

💬 留言讨论