LINE
line package 是刻意最小化的 LINE Messaging API 封裝,提供 webhook reply、push 與媒體保存。
公開 HTTPS 要求
LINE 會將 inbound event 傳進應用程式。Start(ctx) 先呼叫 GetBotInfo,bind :<port>,並在預設 /linebot/webhook 啟動 HTTP server。endpoint 必須能由公開 HTTPS 存取;本機測試可用 ngrok 等反向代理。WithPath 可改 webhook path。
事件處理
webhook 透過 ParseRequest 驗證 LINE 簽章;無效簽章回 400;每個收到的 event 使用 30 秒 context。text、image、video、audio 與 file 會映射為 Input,其他 event 直接略過。sender display name 會透過對應 profile API best-effort 解析。
API
| Method | 行為 |
|---|---|
Reply(handler) |
handler 回傳非空字串時,用一次性 reply token 回覆 |
Send(ctx, to, text) |
對 user、group 或 room target 呼叫 PushMessage |
Save(ctx, messageID, dir) |
streaming 媒體至 UUID 檔名,50 MiB 上限 |
此 package 不提供 SendInput、select menu 或 status abstraction。