v0.5.0

LINE API

最後更新


github.com/pardnchiu/go-bot/core/line 的全部 exported 符號,底層為 github.com/line/line-bot-sdk-go/v8 v8.18.0 的 linebot 套件。

型別


符號定義說明
Botstruct(欄位未匯出)以 New 建立;方法可並行呼叫
Statusstruct { Running bool; UserID, BasicID, DisplayName string }Status() 的回傳值;身分欄位取自 GetBotInfo
Inputstruct欄位:SourceType、UserID、Username、GroupID、RoomID、ReplyToken、MessageID、MessageType、Text、FileName(皆為 string)、Raw *linebot.Event。見 LINE 設定
ReplyHandlerfunc(ctx context.Context, input Input) string
Optionfunc(*options)New 的選項

建構子與選項


函式效果
New(secret, token, port string, opts ...Option) (*Bot, error)任一參數為空或被 SDK 拒絕時回 error
WithPath(path string) OptionWebhook path;預設 /linebot/webhook;空值沿用預設

方法


方法回傳錯誤與限制
Start(ctx context.Context)errorGetBotInfo 失敗、net.Listen 失敗
Close()errorhttp.Server.Shutdown 失敗(5 秒 timeout)
Status()Status
Reply(handler ReplyHandler)—取代先前的 handler
Send(ctx, to, text string)(*linebot.BasicResponse, error)to 為空、API 錯誤
Save(ctx, messageID, dir string)(string, error)空參數、超過 50 MiB、API 錯誤、檔案系統錯誤

相關頁面


LINE 設定 · LINE 訊息 · 媒體落地
EN