Documentation
¶
Index ¶
- Constants
- Variables
- type API
- type ApiAction
- type ApiArg
- type ApiConfig
- type ApiHandler
- type ApiSendMesageAction
- type AssetsConfig
- type Bot
- type CallbackReply
- type CallbackTrigger
- type Config
- type Context
- type DBConfig
- type Edit
- type EditMessage
- type Handler
- type ImageReply
- type InlineButton
- type MessageReply
- type MessageTrigger
- type ParseMode
- type PersistenceConfig
- type PersistenceType
- type Reply
- type ReplyMarkup
- type Spec
- type State
- type Trigger
- type Webhook
Constants ¶
View Source
const ( ModeMarkdown = ParseMode("Markdown") ModeMarkdownV2 = ParseMode("MarkdownV2") ModeHTML = ParseMode("HTML") )
Variables ¶
View Source
var ( ErrInvalidSpec = errors.New("invalid configuration") ErrNoHandlersConfig = errors.New("no handlers configured") )
View Source
var DefaultConfig = &Config{ Persistence: &PersistenceConfig{ Type: MemoryPersistence, }, Assets: &AssetsConfig{ Provider: "fs", }, }
View Source
var ErrNoTriggerConfig = errors.New("no trigger configuration")
View Source
var ErrWebhookInvalidURL = errors.New("invalid URL")
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
Handlers []*ApiHandler `yaml:"handlers"`
}
type ApiAction ¶
type ApiAction struct {
SendMessage *ApiSendMesageAction `yaml:"send-message"`
}
type ApiHandler ¶
type ApiSendMesageAction ¶
type ApiSendMesageAction struct {
Text *ApiArg `yaml:"text"`
}
type AssetsConfig ¶ added in v1.1.0
type Bot ¶
type Bot struct {
Token string `yaml:"token" env:"BOT_TOKEN"`
Config *Config `yaml:"config"`
State map[string]string `yaml:"state"`
Debug bool `yaml:"debug"`
Handlers []*Handler `yaml:"handlers"`
Api *API `yaml:"api"`
}
Bot spec includes bot configuration and handlers.
type CallbackReply ¶
type CallbackTrigger ¶
type CallbackTrigger struct {
Data string
}
func (*CallbackTrigger) UnmarshalYAML ¶
func (ct *CallbackTrigger) UnmarshalYAML(node *yaml.Node) error
type Config ¶
type Config struct {
Api *ApiConfig `yaml:"api"`
Persistence *PersistenceConfig `yaml:"persistence"`
Assets *AssetsConfig `yaml:"assets"`
}
type Edit ¶ added in v1.1.0
type Edit struct {
Message *EditMessage `yaml:"message"`
}
type EditMessage ¶ added in v1.1.0
type EditMessage struct {
Caption string `yaml:"caption"`
Text string `yaml:"text"`
InlineKeyboard [][]InlineButton `yaml:"inlineKeyboard"`
}
type Handler ¶
type Handler struct {
Trigger *Trigger `yaml:"on"`
Replies []*Reply `yaml:"reply"`
Webhook *Webhook `yaml:"webhook"`
State *State `yaml:"state"`
Context *Context `yaml:"context"`
}
Handler specification declares bot handlers.
type ImageReply ¶ added in v1.1.0
type InlineButton ¶
type MessageReply ¶
type MessageReply struct {
Text string `yaml:"text"`
ParseMode ParseMode `yaml:"parseMode"`
Markup *ReplyMarkup `yaml:"markup"`
}
type MessageTrigger ¶
func (*MessageTrigger) UnmarshalYAML ¶
func (t *MessageTrigger) UnmarshalYAML(node *yaml.Node) error
type PersistenceConfig ¶
type PersistenceConfig struct {
Type PersistenceType `yaml:"type"`
DBConfig *DBConfig `yaml:"db_config"`
}
type PersistenceType ¶
type PersistenceType string
const ( MemoryPersistence PersistenceType = "memory" DatabasePersistence PersistenceType = "database" )
type Reply ¶
type Reply struct {
Message *MessageReply `yaml:"message"`
Callback *CallbackReply `yaml:"callback"`
Edit *Edit `yaml:"edit"`
Delete bool `yaml:"delete"`
Image *ImageReply `yaml:"image"`
}
type ReplyMarkup ¶
type ReplyMarkup struct {
Keyboard [][]string `yaml:"keyboard"`
InlineKeyboard [][]InlineButton `yaml:"inlineKeyboard"`
}
type Spec ¶
type Spec struct {
Bot *Bot `yaml:"bot"`
}
Spec is a base struct for a bot specification file.
type Trigger ¶
type Trigger struct {
Message *MessageTrigger `yaml:"message"`
Callback *CallbackTrigger `yaml:"callback"`
Context string `yaml:"context"`
}
Click to show internal directories.
Click to hide internal directories.