Documentation
¶
Index ¶
- Constants
- Variables
- type API
- type ApiAction
- type ApiConfig
- type ApiHandler
- type AssetsConfig
- type Bot
- type CallbackReply
- type CallbackTrigger
- type Config
- type Context
- type DBConfig
- type Data
- type DataFetch
- type Edit
- type EditMessage
- type FileReply
- type Handler
- type InlineButton
- type Invoice
- type MessageReply
- type MessageTrigger
- type ParseMode
- type PaymentProvider
- type PersistenceConfig
- type PersistenceType
- type PostCheckoutTrigger
- type PreCheckoutAnswer
- type PreCheckoutTrigger
- type Price
- type Reply
- type ReplyMarkup
- type Spec
- type State
- type TemplateStyle
- type Trigger
- type Webhook
Constants ¶
View Source
const ( ModeMarkdown = ParseMode("Markdown") ModeMarkdownV2 = ParseMode("MarkdownV2") ModeHTML = ParseMode("HTML") )
View Source
const ( // TemplateDefault is default template style, uses interpolation of state variables. TemplateDefault = TemplateStyle("default") // TemplateGo uses go template engine. TemplateGo = TemplateStyle("go") // TemplateNo uses no template engine. TemplateNo = TemplateStyle("no") )
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 *MessageReply `yaml:"send-message"`
}
type ApiHandler ¶
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"`
PaymentProviders []PaymentProvider `yaml:"paymentProviders"`
}
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"`
Template TemplateStyle `yaml:"template"`
}
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"`
Data *Data `yaml:"data"`
}
Handler specification declares bot handlers.
type InlineButton ¶
type Invoice ¶ added in v1.2.0
type Invoice struct {
// Provider is a payment provider name.
Provider string `yaml:"provider"`
// Title of the product
Title string `yaml:"title"`
// Description of the product
Description string `yaml:"description"`
// Unique bot deep-linking parameter that can be used to generate this invoice
Payload string `yaml:"payload"`
// Three-letter ISO 4217 currency code
Currency string `yaml:"currency"`
// Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
Prices []Price `yaml:"prices"`
}
Invoice is a payment invoice.
type MessageReply ¶
type MessageReply struct {
Text string `yaml:"text"`
ParseMode ParseMode `yaml:"parseMode"`
Markup *ReplyMarkup `yaml:"markup"`
Template TemplateStyle `yaml:"template"`
}
type MessageTrigger ¶
func (*MessageTrigger) UnmarshalYAML ¶
func (t *MessageTrigger) UnmarshalYAML(node *yaml.Node) error
type PaymentProvider ¶ added in v1.2.0
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 PostCheckoutTrigger ¶ added in v1.2.0
type PostCheckoutTrigger struct {
InvoicePayload string `yaml:"invoicePayload"`
}
type PreCheckoutAnswer ¶ added in v1.2.0
type PreCheckoutTrigger ¶ added in v1.2.0
type PreCheckoutTrigger struct {
InvoicePayload string `yaml:"invoicePayload"`
}
type Price ¶ added in v1.2.0
type Price struct {
// Label of the price
Label string `yaml:"label"`
// Price in the smallest units of the currency (integer, not float/double).
Amount int `yaml:"amount"`
}
Price of the product
type Reply ¶
type Reply struct {
Message *MessageReply `yaml:"message"`
Callback *CallbackReply `yaml:"callback"`
Edit *Edit `yaml:"edit"`
Delete bool `yaml:"delete"`
Image *FileReply `yaml:"image"`
Document *FileReply `yaml:"document"`
Invoice *Invoice `yaml:"invoice"`
PreCheckout *PreCheckoutAnswer `yaml:"preCheckout"`
}
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"`
PreCheckout *PreCheckoutTrigger `yaml:"preCheckout"`
PostCheckout *PostCheckoutTrigger `yaml:"postCheckout"`
}
Click to show internal directories.
Click to hide internal directories.