v0.5.0

Architecture

Last updated


go-bot keeps each chat platform in its own package under core/; the only thing they share is the reply convention.

System overview


flowchart LR
  App[Your application] -->|New / Reply / Start| TG[core/telegram]
  App -->|New / Reply / Start| DC[core/discord]
  App -->|New / Reply / Start| LN[core/line]
  TG -->|long polling, outbound| TGA[Telegram Bot API]
  DC -->|WebSocket gateway + REST, outbound| DGA[Discord API]
  LNA[LINE Messaging API] -->|HTTPS webhook, inbound| LN
  LN -->|reply / push| LNA
  1. flowchart LR
  2. App[Your application] -->|New / Reply / Start| TG[core/telegram]
  3. App -->|New / Reply / Start| DC[core/discord]
  4. App -->|New / Reply / Start| LN[core/line]
  5. TG -->|long polling, outbound| TGA[Telegram Bot API]
  6. DC -->|WebSocket gateway + REST, outbound| DGA[Discord API]
  7. LNA[LINE Messaging API] -->|HTTPS webhook, inbound| LN
  8. LN -->|reply / push| LNA

Layers


LayerPackagesResponsibility
Applicationyour codeRegisters one ReplyHandler per bot, calls Send* methods
Platform adaptercore/telegram, core/discord, core/lineTransport lifecycle, event dispatch into Input, sending, media download, interactive state
Platform SDKgo-telegram/bot v1.20.0, bwmarrin/discordgo v0.29.0, line-bot-sdk-go/v8/linebot v8.18.0Wire protocol; still reachable through Input.Raw
Shared utilitygithub.com/pardnchiu/go-pkg/utilsUUIDs for saved filenames and Discord component IDs

Single-platform Go libraries such as go-telegram-bot-api/telegram-bot-api and tucnak/telebot (Telegram), bwmarrin/discordgo (Discord), and line/line-bot-sdk-go (LINE) each cover one platform's API. go-bot builds on go-telegram/bot, discordgo, and line-bot-sdk-go, and runs a Telegram bot, a Discord bot, and a LINE bot under the same New / Reply / Start / Close lifecycle; the raw SDK event of each incoming message stays available in Input.Raw.

Cross-cutting rules


RuleEffect
No shared internal packageEach package declares its own Input, ReplyHandler, Status; identifiers differ (int64 chat IDs on Telegram, string snowflakes on Discord, source IDs on LINE)
One handler, synchronousReply(handler) replaces any previous handler; a non-empty return is sent back automatically
context.Context on every network callEvery Send*, Delete, Save, and status call accepts ctx
Close instead of StopMatches io.Closer; safe to call more than once
Platform-native interactionsTelegram uses inline keyboards and ForceReply, Discord uses components and modals, LINE has none


中文