Documentation
¶
Index ¶
- Constants
- func FunctionMap() template.FuncMap
- func Get(cmd data.BundleCommand, bundle data.Bundle, tt data.TemplateType) (string, error)
- func Transform(tmpl string, envelope data.CommandResponseEnvelope) (string, error)
- type Alt
- type Divider
- type Functions
- func (f *Functions) AltFunction(content string) *Alt
- func (f *Functions) DividerFunction() *Divider
- func (f *Functions) HeaderColorFunction(s string, t *Header) (*Header, error)
- func (f *Functions) HeaderFunction() *Header
- func (f *Functions) ImageFunction(url string) *Image
- func (f *Functions) ImageThumbnailunction(b bool, i *Image) *Image
- func (f *Functions) MultipleTitleFunction(s string, i interface{}) (interface{}, error)
- func (f *Functions) SectionEndFunction() *SectionEnd
- func (f *Functions) SectionFunction() *Section
- func (f *Functions) TextEmojiFunction(b bool, t *Text) *Text
- func (f *Functions) TextEndFunction() *TextEnd
- func (f *Functions) TextFunction() *Text
- func (f *Functions) TextInlineFunction(b bool, t *Text) *Text
- func (f *Functions) TextMarkdownFunction(b bool, t *Text) *Text
- func (f *Functions) TextMonospaceFunction(b bool, t *Text) *Text
- func (f *Functions) UnimplementedFunction() *Unimplemented
- type Header
- type Image
- type OutputElement
- type OutputElements
- type Section
- type SectionEnd
- type Tag
- type Text
- type TextEnd
- type Unimplemented
- type WithAlt
Constants ¶
const ( // DefaultCommand is a template used to format the outputs from successfully // executed commands. DefaultCommand = `{{ text | monospace true }}{{ .Response.Out }}{{ endtext }}` // DefaultCommandError is a template used to format the error messages // produced by commands that return with a non-zero status. DefaultCommandError = `` /* 351-byte string literal not displayed */ // DefaultMessage is a template used to format standard informative // (non-error) messages from the Gort system (not commands). DefaultMessage = `{{ text }}{{ .Response.Out }}{{ endtext }}` // DefaultMessageError is a template used to format error messages from the // Gort system (not commands). DefaultMessageError = `{{ header | color "#FF0000" | title .Response.Title }} {{ text }}{{ .Response.Out }}{{ endtext }}` )
Variables ¶
This section is empty.
Functions ¶
func FunctionMap ¶
func Get ¶
func Get(cmd data.BundleCommand, bundle data.Bundle, tt data.TemplateType) (string, error)
Get returns the first defined template found in the following sequence: 1. Command 2. Bundle 3. Config 4. Default
Types ¶
type Alt ¶
Alt provides alternative text to be shown if other elements in a message cannot be rendered. Only the first instance of Alt will be shown.
type Functions ¶
type Functions struct{}
func (*Functions) AltFunction ¶
func (*Functions) DividerFunction ¶
func (*Functions) HeaderColorFunction ¶
func (*Functions) HeaderFunction ¶
func (*Functions) ImageFunction ¶
func (*Functions) ImageThumbnailunction ¶
func (*Functions) MultipleTitleFunction ¶
func (*Functions) SectionEndFunction ¶
func (f *Functions) SectionEndFunction() *SectionEnd
func (*Functions) SectionFunction ¶
func (*Functions) TextEndFunction ¶
func (*Functions) TextFunction ¶
func (*Functions) TextInlineFunction ¶
func (*Functions) TextMarkdownFunction ¶
func (*Functions) TextMonospaceFunction ¶
func (*Functions) UnimplementedFunction ¶
func (f *Functions) UnimplementedFunction() *Unimplemented
type Header ¶
type Image ¶
type OutputElement ¶
type OutputElements ¶
type OutputElements struct { // Color is the representation of the RGB color hex code. If defined, it // MUST adhere to the format "#RRGGBB". Optional. Color string // Title is the title of the message, if set. Optional. Title string // Elements includes the various message construction elements. Elements []OutputElement }
func EncodeElements ¶
func EncodeElements(text string) (OutputElements, error)
Encodes intermediate text generated by Transform into an OutputElements value that can be passed to an adapter.
func TransformAndEncode ¶
func TransformAndEncode(tmpl string, envelope data.CommandResponseEnvelope) (OutputElements, error)
func (*OutputElements) Alt ¶
func (o *OutputElements) Alt() string
Alt returns simplified text for this output. It will either return a concatenation of the text form for each element, separated by newlines, or the first Alt element.
type Section ¶
type Section struct { Tag Text *Text `json:",omitempty"` Fields []OutputElement `json:",omitempty"` }
type SectionEnd ¶
type SectionEnd struct {
Tag
}
func (*SectionEnd) Alt ¶
func (o *SectionEnd) Alt() string
func (*SectionEnd) String ¶
func (o *SectionEnd) String() string
type Text ¶
type Unimplemented ¶
type Unimplemented struct {
Tag
}
Unimplemented is an OutputElement that should not be implemented by any chat adapters. It may be used when testing to force a fallback to alt text.
func (*Unimplemented) String ¶
func (o *Unimplemented) String() string