Documentation
¶
Overview ¶
Package botbooter holds the platform-agnostic shared types for building chat bots that behave the same way across Slack, Discord, Telegram, WhatsApp, Microsoft Teams and a local CLI.
This package is SDK-free: it imports no platform SDK and only re-exports the shared types from internal/core. Construct a bot from one of the per-platform packages — botbooter/slack, botbooter/discord, botbooter/telegram, botbooter/whatsapp, botbooter/teams or botbooter/cli — each of which pulls in only its own platform SDK (WhatsApp and Teams speak REST APIs over plain HTTP and need none), then drive it through the shared types re-exported here. A bot that uses one platform never compiles the other platforms' SDKs into its binary.
Example ¶
package main
import (
"context"
"os"
"strings"
"github.com/lao/botbooter"
"github.com/lao/botbooter/cli"
)
func main() {
bot := cli.New(strings.NewReader("echo hello\n"), os.Stdout)
_ = bot.HandleFunc("^echo ", func(ctx context.Context, b *botbooter.Bot, m *botbooter.Message) {
_ = b.SendMessageContext(ctx, m.ChannelID, strings.TrimPrefix(m.Content, "echo "))
})
// Run returns when the input reaches EOF.
_ = bot.Run(context.Background())
}
Output: hello
Index ¶
Examples ¶
Constants ¶
const ( SlackBotType = core.SlackBotType DiscordBotType = core.DiscordBotType CLIBotType = core.CLIBotType TelegramBotType = core.TelegramBotType WhatsAppBotType = core.WhatsAppBotType TeamsBotType = core.TeamsBotType )
Supported bot types.
Variables ¶
var ( ErrUnknownBotType = core.ErrUnknownBotType ErrAlreadyConnected = core.ErrAlreadyConnected ErrNilMessage = core.ErrNilMessage )
Errors returned by Bot methods.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment = core.Attachment
Attachment is a platform-agnostic file attachment. See core.Attachment.
type CLIMessage ¶
type CLIMessage = core.CLIMessage
CLIMessage is the raw payload of a CLI message. See core.CLIMessage.
type Command ¶
Command pairs a regexp pattern with a handler. See core.Command.
type CommandHandler ¶
type CommandHandler = core.CommandHandler
CommandHandler handles a matched message. See core.CommandHandler.
type Message ¶
Message is an incoming message handed to handlers. See core.Message.
type Middleware ¶
type Middleware = core.Middleware
Middleware wraps message dispatch. See core.Middleware.
type SendOption ¶ added in v0.3.0
type SendOption = core.SendOption
SendOption modifies a send. See core.SendOption.
func InReplyTo ¶ added in v0.3.0
func InReplyTo(m *Message) SendOption
InReplyTo anchors a send on m so the adapter posts into m's thread or reply-chain, deriving the correct per-platform anchor. See core.InReplyTo.
func WithThreadID ¶ added in v0.3.0
func WithThreadID(id string) SendOption
WithThreadID anchors a send on a raw native id the adapter uses verbatim; it takes precedence over InReplyTo. See core.WithThreadID.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli exposes the local-CLI constructor and raw-message accessor for botbooter.
|
Package cli exposes the local-CLI constructor and raw-message accessor for botbooter. |
|
Package discord exposes the Discord (Gateway) constructor and the raw-event and session accessors for botbooter.
|
Package discord exposes the Discord (Gateway) constructor and the raw-event and session accessors for botbooter. |
|
internal
|
|
|
asserts
Package asserts holds tiny test assertion helpers shared across botbooter.
|
Package asserts holds tiny test assertion helpers shared across botbooter. |
|
cli
Package cli is the local CLI adapter for botbooter.
|
Package cli is the local CLI adapter for botbooter. |
|
core
Package core holds botbooter's platform-agnostic engine: the Bot type, its command/middleware dispatch, and the connection lifecycle.
|
Package core holds botbooter's platform-agnostic engine: the Bot type, its command/middleware dispatch, and the connection lifecycle. |
|
discord
Package discord is the Discord adapter for botbooter.
|
Package discord is the Discord adapter for botbooter. |
|
slack
Package slack is the Slack adapter for botbooter, connecting via Socket Mode.
|
Package slack is the Slack adapter for botbooter, connecting via Socket Mode. |
|
teams
Package teams is the Microsoft Teams adapter for botbooter.
|
Package teams is the Microsoft Teams adapter for botbooter. |
|
telegram
Package telegram is the Telegram adapter for botbooter: it connects via the Bot API getUpdates long-poll loop and implements core.Adapter.
|
Package telegram is the Telegram adapter for botbooter: it connects via the Bot API getUpdates long-poll loop and implements core.Adapter. |
|
whatsapp
Package whatsapp is the WhatsApp adapter for botbooter.
|
Package whatsapp is the WhatsApp adapter for botbooter. |
|
Package slack exposes the Slack (Socket Mode) constructor and the raw-event and client accessors for botbooter.
|
Package slack exposes the Slack (Socket Mode) constructor and the raw-event and client accessors for botbooter. |
|
Package teams exposes the Microsoft Teams (Azure Bot Framework) constructor, the raw-message accessor, and the Config/Message types for botbooter.
|
Package teams exposes the Microsoft Teams (Azure Bot Framework) constructor, the raw-message accessor, and the Config/Message types for botbooter. |
|
Package telegram exposes the Telegram (Bot API) constructor and the raw-update and client accessors for botbooter.
|
Package telegram exposes the Telegram (Bot API) constructor and the raw-update and client accessors for botbooter. |
|
Package whatsapp exposes the WhatsApp (Meta Cloud API) constructor, the raw-message accessor, and the Config/Message/Media types for botbooter.
|
Package whatsapp exposes the WhatsApp (Meta Cloud API) constructor, the raw-message accessor, and the Config/Message/Media types for botbooter. |