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, GitHub 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/cloud, botbooter/whatsapp/whatsmeow, botbooter/teams, botbooter/github or botbooter/cli — each of which pulls in only its own platform SDK (WhatsApp Cloud API and Teams speak REST APIs over plain HTTP and need none; GitHub pulls google/go-github plus bradleyfalzon/ghinstallation for GitHub App auth), 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.
WhatsApp comes in two flavors selected by import path: whatsapp/cloud (Meta Cloud API webhook, needs a Meta Business account and a public HTTPS URL) and whatsapp/whatsmeow (WhatsApp Web multidevice protocol via whatsmeow, QR-linked to a phone, no Meta account or webhook needed).
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 // WhatsMeowBotType is the WhatsApp Web (whatsmeow) flavor; WhatsAppBotType is // the Meta Cloud API flavor. WhatsMeowBotType = core.WhatsMeowBotType GitHubBotType = core.GitHubBotType )
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 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 Reaction ¶ added in v0.4.0
Reaction is an emoji reaction added to a message. See core.Reaction.
type ReactionHandler ¶ added in v0.4.0
type ReactionHandler = core.ReactionHandler
ReactionHandler handles a reaction. See core.ReactionHandler.
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. |
|
Package github exposes the GitHub constructor, the raw-event accessors, and the Config/Message types for botbooter.
|
Package github exposes the GitHub constructor, the raw-event accessors, and the Config/Message types 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. |
|
github
Package github is the GitHub adapter for botbooter.
|
Package github is the GitHub 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/cloud
Package cloud is the Meta Cloud API flavor of botbooter's WhatsApp adapter.
|
Package cloud is the Meta Cloud API flavor of botbooter's WhatsApp adapter. |
|
whatsapp/whatsmeow
Package whatsmeow is the WhatsApp Web flavor of botbooter's WhatsApp adapter, built on the whatsmeow library (go.mau.fi/whatsmeow).
|
Package whatsmeow is the WhatsApp Web flavor of botbooter's WhatsApp adapter, built on the whatsmeow library (go.mau.fi/whatsmeow). |
|
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. |
|
whatsapp
|
|
|
cloud
Package cloud is the Meta Cloud API flavor of botbooter's WhatsApp support: it exposes the webhook-based constructor, the raw-message accessor, and the Config/Message/Media types.
|
Package cloud is the Meta Cloud API flavor of botbooter's WhatsApp support: it exposes the webhook-based constructor, the raw-message accessor, and the Config/Message/Media types. |
|
whatsmeow
Package whatsmeow is the WhatsApp Web flavor of botbooter's WhatsApp support, built on the whatsmeow library (go.mau.fi/whatsmeow).
|
Package whatsmeow is the WhatsApp Web flavor of botbooter's WhatsApp support, built on the whatsmeow library (go.mau.fi/whatsmeow). |