# API 參考

本頁為 go-bot 三個套件與其共通方法的索引；每個套件另有完整參考頁。

## 套件

| 套件 | Import path | 建構子 | 完整參考 |
|---|---|---|---|
| `telegram` | `github.com/pardnchiu/go-bot/core/telegram` | `New(token string, opts ...Option) (*Bot, error)` | [Telegram API](/zh/api-reference-telegram) |
| `discord` | `github.com/pardnchiu/go-bot/core/discord` | `New(token string) (*Bot, error)` | [Discord API](/zh/api-reference-discord) |
| `line` | `github.com/pardnchiu/go-bot/core/line` | `New(secret, token, port string, opts ...Option) (*Bot, error)` | [LINE API](/zh/api-reference-line) |

## 共通形狀

每個套件各自宣告下列型別與方法，並非 interface。

| 符號 | 用途 |
|---|---|
| `Bot` | 含生命週期、handler 與傳送方法的 client；可並行使用 |
| `Input` | 傳給 handler 的事件；欄位依平台而異 |
| `ReplyHandler` | `func(ctx context.Context, input Input) string` |
| `Status` | `Status()` 回傳的快照 |
| `(*Bot).Start(ctx) error` | 驗證憑證並開始接收；執行中再呼叫不做事 |
| `(*Bot).Close() error` | 停止接收並清除互動狀態；已停止時不做事 |
| `(*Bot).Status() Status` | 執行旗標與 bot 身分 |
| `(*Bot).Reply(handler)` | 註冊 handler |
| `(*Bot).Send(ctx, ...)` | 傳送文字 |
| `(*Bot).Save(ctx, ..., dir) (string, error)` | 下載收到的媒體；見[媒體落地](/zh/media-save) |

## 方法對照

| 功能 | Telegram | Discord | LINE |
|---|---|---|---|
| 文字 | `Send` | `Send` | `Send`（push） |
| 刪除 | `Delete` | `Delete` | — |
| 檔案 | `SendFile`、`SendPhoto` | `SendFiles` | — |
| 語音／音訊檔 | `SendVoice` | `SendVoice` | — |
| 自由文字輸入 | `SendInput` | `SendInput` | — |
| 單選 | `SendSelect` | `SendSelect` | — |
| 多選 | `SendMultiSelect` | `SendMultiSelect` | — |
| 狀態訊息 | `SendStatus`、`FinishStatus` | `SendStatus`、`FinishStatus` | — |
| 媒體下載 | `Save` | `Save` | `Save` |

已移除的符號與舊 import path 列於[已移除 API](/zh/removed-apis)。
