Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertDependenciesFromAPI[T PluginDependencyURLsSetter[P], P any](in map[string]Dependency) map[string]T
- func ConvertDependenciesToAPI[T PluginDependencyURLsGetter](resp map[string]T) map[string]Dependency
- type Base
- type Body
- type BotNameOption
- type BotNameOptions
- type BulletList
- type BulletLists
- type Button
- type ButtonBuilder
- func (b *ButtonBuilder) DescriptionURL(name, cmd string, url string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommand(name, cmd, desc string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommandWithBoldDesc(name, desc, cmd string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommandWithDescCmd(name, cmd string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommandWithItalicDesc(name, desc, cmd string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommandWithoutDesc(name, cmd string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForURL(name, url string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForURLWithBoldDesc(name, desc, url string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForURLWithTextDesc(name, desc, url string, style ...ButtonStyle) Button
- type ButtonDescriptionStyle
- type ButtonStyle
- type Buttons
- type ContextItem
- type ContextItems
- type Dependency
- type DispatchedInputAction
- type DividerStyle
- type ExternalRequestMetadata
- type ExternalRequestPayload
- type JSONSchema
- type LabelInput
- type LabelInputs
- type Message
- type MessageType
- type MetadataOutput
- type MultiSelect
- type OptionGroup
- type OptionItem
- type PluginDependencyURLsGetter
- type PluginDependencyURLsSetter
- type Section
- type SectionStyle
- type Select
- type SelectType
- type Selects
- type TextField
- type TextFields
- type URLs
Constants ¶
const (
// MessageBotNamePlaceholder is a cross-platform placeholder for bot name.
MessageBotNamePlaceholder = "{{BotName}}"
)
Variables ¶
var HandshakeConfig = plugin.HandshakeConfig{
MagicCookieKey: "BOTKUBE",
MagicCookieValue: "52ca7b74-28eb-4fac-ae79-31a9cbda2454",
}
HandshakeConfig is common handshake config between Botkube and its plugins.
Functions ¶
func ConvertDependenciesFromAPI ¶ added in v0.18.0
func ConvertDependenciesFromAPI[T PluginDependencyURLsSetter[P], P any](in map[string]Dependency) map[string]T
ConvertDependenciesFromAPI converts API dependencies to source/executor plugin dependencies.
func ConvertDependenciesToAPI ¶ added in v0.18.0
func ConvertDependenciesToAPI[T PluginDependencyURLsGetter](resp map[string]T) map[string]Dependency
ConvertDependenciesToAPI converts source/executor plugin dependencies to API dependencies.
Types ¶
type Base ¶ added in v1.0.0
type Base struct { Header string `json:"header,omitempty" yaml:"header"` Description string `json:"description,omitempty" yaml:"description"` Body Body `json:"body,omitempty" yaml:"body"` }
Base holds generic message fields.
func ReplaceBotNameInBase ¶ added in v1.0.0
ReplaceBotNameInBase replaces bot name placeholder with a given name.
type Body ¶ added in v1.0.0
type Body struct { CodeBlock string `json:"codeBlock,omitempty" yaml:"codeBlock"` Plaintext string `json:"plaintext,omitempty" yaml:"plaintext"` }
Body holds message body fields.
func ReplaceBotNameInBody ¶ added in v1.0.0
ReplaceBotNameInBody replaces bot name placeholder with a given name.
type BotNameOption ¶ added in v1.1.0
type BotNameOption func(opts *BotNameOptions)
BotNameOption allows modifying ReplaceBotNamePlaceholder related options.
func BotNameWithClusterName ¶ added in v1.1.0
func BotNameWithClusterName(clusterName string) BotNameOption
BotNameWithClusterName sets the cluster name for places where MessageBotNamePlaceholder was also specified.
type BotNameOptions ¶ added in v1.1.0
type BotNameOptions struct {
ClusterName string
}
BotNameOptions holds options used in ReplaceBotNamePlaceholder func
type BulletList ¶ added in v1.0.0
type BulletList struct { Title string `json:"title,omitempty" yaml:"title"` Items []string `json:"items,omitempty" yaml:"items"` }
BulletList defines a bullet list primitive.
type BulletLists ¶ added in v1.0.0
type BulletLists []BulletList
BulletLists holds the bullet lists.
func (BulletLists) AreItemsDefined ¶ added in v1.0.0
func (l BulletLists) AreItemsDefined() bool
AreItemsDefined returns true if at least one list has items defined.
type Button ¶ added in v1.0.0
type Button struct { Description string `json:"description,omitempty" yaml:"description"` // DescriptionStyle defines the style of the button description. If not provided, the default style (ButtonDescriptionStyleCode) is used. DescriptionStyle ButtonDescriptionStyle `json:"descriptionStyle" yaml:"descriptionStyle"` Name string `json:"name,omitempty" yaml:"name"` Command string `json:"command,omitempty" yaml:"command"` URL string `json:"url,omitempty" yaml:"url"` Style ButtonStyle `json:"style,omitempty" yaml:"style"` }
Button holds definition of action button.
type ButtonBuilder ¶ added in v1.0.0
type ButtonBuilder struct{}
ButtonBuilder provides a simplified way to construct a Button model.
func NewMessageButtonBuilder ¶ added in v1.0.0
func NewMessageButtonBuilder() *ButtonBuilder
func (*ButtonBuilder) DescriptionURL ¶ added in v1.0.0
func (b *ButtonBuilder) DescriptionURL(name, cmd string, url string, style ...ButtonStyle) Button
DescriptionURL returns link button with description.
func (*ButtonBuilder) ForCommand ¶ added in v1.0.0
func (b *ButtonBuilder) ForCommand(name, cmd, desc string, style ...ButtonStyle) Button
ForCommand returns button command with description in adaptive code block.
For displaying description in bold, use ForCommandWithBoldDesc.
func (*ButtonBuilder) ForCommandWithBoldDesc ¶ added in v1.2.0
func (b *ButtonBuilder) ForCommandWithBoldDesc(name, desc, cmd string, style ...ButtonStyle) Button
ForCommandWithBoldDesc returns button command where description and command are different.
func (*ButtonBuilder) ForCommandWithDescCmd ¶ added in v1.0.0
func (b *ButtonBuilder) ForCommandWithDescCmd(name, cmd string, style ...ButtonStyle) Button
ForCommandWithDescCmd returns button command where description and command are the same.
func (*ButtonBuilder) ForCommandWithItalicDesc ¶ added in v1.12.0
func (b *ButtonBuilder) ForCommandWithItalicDesc(name, desc, cmd string, style ...ButtonStyle) Button
ForCommandWithItalicDesc returns button command where description and command are different and the description is italic.
func (*ButtonBuilder) ForCommandWithoutDesc ¶ added in v1.0.0
func (b *ButtonBuilder) ForCommandWithoutDesc(name, cmd string, style ...ButtonStyle) Button
ForCommandWithoutDesc returns button command without description.
func (*ButtonBuilder) ForURL ¶ added in v1.0.0
func (b *ButtonBuilder) ForURL(name, url string, style ...ButtonStyle) Button
ForURL returns link button.
func (*ButtonBuilder) ForURLWithBoldDesc ¶ added in v1.2.0
func (b *ButtonBuilder) ForURLWithBoldDesc(name, desc, url string, style ...ButtonStyle) Button
ForURLWithBoldDesc returns link button with description.
func (*ButtonBuilder) ForURLWithTextDesc ¶ added in v1.10.0
func (b *ButtonBuilder) ForURLWithTextDesc(name, desc, url string, style ...ButtonStyle) Button
ForURLWithBoldDesc returns link button with description.
type ButtonDescriptionStyle ¶ added in v1.2.0
type ButtonDescriptionStyle string
ButtonDescriptionStyle defines the style of the button description.
const ( // ButtonDescriptionStyleBold defines the bold style for the button description. ButtonDescriptionStyleBold ButtonDescriptionStyle = "bold" // ButtonDescriptionStyleItalic defines the bold style for the button description. ButtonDescriptionStyleItalic ButtonDescriptionStyle = "italic" // ButtonDescriptionStyleText defines the plaintext style for the button description. ButtonDescriptionStyleText ButtonDescriptionStyle = "text" // ButtonDescriptionStyleCode defines the code style for the button description. ButtonDescriptionStyleCode ButtonDescriptionStyle = "code" )
type ButtonStyle ¶ added in v1.0.0
type ButtonStyle string
ButtonStyle is a style of Button element.
const ( ButtonStyleDefault ButtonStyle = "" ButtonStylePrimary ButtonStyle = "primary" ButtonStyleDanger ButtonStyle = "danger" )
Represents a general button styles.
type Buttons ¶ added in v1.0.0
type Buttons []Button
Buttons holds definition of interactive buttons.
func ReplaceBotNameInButtons ¶ added in v1.0.0
func ReplaceBotNameInButtons(btns Buttons, name string, opts BotNameOptions) Buttons
ReplaceBotNameInButtons replaces bot name placeholder with a given name.
func (*Buttons) GetButtonsWithDescription ¶ added in v1.10.0
GetButtonsWithDescription returns all buttons with description.
func (*Buttons) GetButtonsWithoutDescription ¶ added in v1.10.0
GetButtonsWithoutDescription returns all buttons without description.
type ContextItem ¶ added in v1.0.0
type ContextItem struct {
Text string `json:"text,omitempty" yaml:"text"`
}
ContextItem holds context item.
type ContextItems ¶ added in v1.0.0
type ContextItems []ContextItem
ContextItems holds context items.
func ReplaceBotNameInContextItems ¶ added in v1.0.0
func ReplaceBotNameInContextItems(items ContextItems, name string) ContextItems
ReplaceBotNameInContextItems replaces bot name placeholder with a given name.
func (ContextItems) IsDefined ¶ added in v1.0.0
func (c ContextItems) IsDefined() bool
IsDefined returns true if there are any context items defined.
type Dependency ¶ added in v0.18.0
type Dependency struct { // URLs holds the URLs for a given dependency depending on the platform and architecture. URLs URLs `yaml:"urls"` }
Dependency holds the dependency information.
type DispatchedInputAction ¶ added in v1.0.0
type DispatchedInputAction string
DispatchedInputAction defines when the action should be sent to our backend.
const ( NoDispatchInputAction DispatchedInputAction = "" DispatchInputActionOnEnter DispatchedInputAction = "on_enter_pressed" DispatchInputActionOnCharacter DispatchedInputAction = "on_character_entered" )
Defines the possible options to dispatch the input action.
type DividerStyle ¶ added in v1.11.0
type DividerStyle string
DividerStyle is a style of Divider element between section blocks.
const ( // DividerStyleDefault put a block divider, like an <hr>, to split up different sections inside of a single message. // It is the default style for backwards compatibility. DividerStyleDefault DividerStyle = "" // DividerStyleTopNone DividerStyleTopNone DividerStyle = "none" )
Represents a divider styles.
type ExternalRequestMetadata ¶ added in v1.4.0
type ExternalRequestMetadata struct { // Payload contains the external requests payload information. Payload ExternalRequestPayload }
ExternalRequestMetadata contains the metadata for external requests.
type ExternalRequestPayload ¶ added in v1.4.0
type ExternalRequestPayload struct { // JSONSchema is a JSON schema for a given incoming webhook payload. JSONSchema JSONSchema }
ExternalRequestPayload contains the incoming webhook payload information.
type JSONSchema ¶ added in v0.18.0
type JSONSchema struct { // Value is the JSON schema string. Value string // RefURL is the remote reference of the schema. RefURL string }
JSONSchema contains the JSON schema or a remote reference where the schema can be found. Value and RefURL are mutually exclusive
type LabelInput ¶ added in v1.0.0
type LabelInput struct { Command string `json:"command,omitempty" yaml:"command"` Text string `json:"text,omitempty" yaml:"text"` Placeholder string `json:"placeholder,omitempty" yaml:"placeholder"` DispatchedAction DispatchedInputAction `json:"dispatchedAction,omitempty" yaml:"dispatchedAction"` }
LabelInput is used to create input elements to use in messages.
type LabelInputs ¶ added in v1.0.0
type LabelInputs []LabelInput
LabelInputs holds the plain text input items.
func ReplaceBotNameInLabels ¶ added in v1.0.0
func ReplaceBotNameInLabels(labels LabelInputs, name string, opts BotNameOptions) LabelInputs
ReplaceBotNameInLabels replaces bot name placeholder with a given name.
type Message ¶ added in v1.0.0
type Message struct { Type MessageType `json:"type,omitempty" yaml:"type"` BaseBody Body `json:"baseBody,omitempty" yaml:"baseBody"` Timestamp time.Time `json:"timestamp,omitempty" yaml:"timestamp"` Sections []Section `json:"sections,omitempty" yaml:"sections"` PlaintextInputs LabelInputs `json:"plaintextInputs,omitempty" yaml:"plaintextInputs"` OnlyVisibleForYou bool `json:"onlyVisibleForYou,omitempty" yaml:"onlyVisibleForYou"` ReplaceOriginal bool `json:"replaceOriginal,omitempty" yaml:"replaceOriginal"` UserHandle string `json:"userHandle,omitempty" yaml:"userHandle"` // ParentActivityID represents the originating message that started a thread. If set, message will be sent in that thread instead of the default one. ParentActivityID string `json:"parentActivityId,omitempty" yaml:"parentActivityId,omitempty"` }
Message represents a generic message with interactive buttons.
func NewCodeBlockMessage ¶ added in v1.0.0
NewCodeBlockMessage returns message in a Markdown code block format.
func NewPlaintextMessage ¶ added in v1.0.0
NewPlaintextMessage returns message in a plaintext format.
func (*Message) HasBaseBody ¶ added in v1.11.0
HasBaseBody returns true if message has base body defined.
func (*Message) HasInputs ¶ added in v1.0.0
HasInputs returns true if message has interactive inputs.
func (*Message) HasSections ¶ added in v1.0.0
HasSections returns true if message has interactive sections.
func (*Message) ReplaceBotNamePlaceholder ¶ added in v1.0.0
func (msg *Message) ReplaceBotNamePlaceholder(new string, opts ...BotNameOption)
ReplaceBotNamePlaceholder replaces bot name placeholder with a given name.
type MessageType ¶ added in v1.0.0
type MessageType string
MessageType defines the message type.
const ( // DefaultMessage defines a message that should be displayed in default mode supported by communicator. DefaultMessage MessageType = "" // BasicCardWithButtonsInSeparateMessage defines a message that should be displayed in plaintext mode supported by the communicator, // with the buttons sent in a separate interactive message. // This feature is currently available only for the Teams platform. BasicCardWithButtonsInSeparateMsg = "basicCardWithButtonsInSeparateMessage" // BaseBodyWithFilterMessage defines a message that should be displayed in plaintext mode supported by communicator. // In this form the built-in filter is supported. // NOTE: only BaseBody is preserved. All other properties are ignored even if set. BaseBodyWithFilterMessage MessageType = "baseBodyWithFilter" // NonInteractiveSingleSection it is an indicator for non-interactive platforms, that they can render this event // even though they have limited capability. As a result, a given message has the following restriction: // - the whole message should have exactly one section // - section interactive elements such as buttons, select, multiselect, and inputs are ignored. // - the base body of the message is ignored // - Timestamp field is optional NonInteractiveSingleSection MessageType = "nonInteractiveEventSingleSection" // PopupMessage defines a message that should be displayed to the user as popup (if possible). PopupMessage MessageType = "form" // ThreadMessage defines a message that should be sent in a thread. ThreadMessage MessageType = "threadMessage" // SkipMessage defines a message that should not be sent to the end user. // If not used and message is empty, a special indicator will be sent as the response. SkipMessage MessageType = "skipMessage" )
type MetadataOutput ¶
type MetadataOutput struct { // Version is a version of a given plugin. It should follow the SemVer syntax. Version string // Descriptions is a description of a given plugin. Description string // URL to plugin documentation. DocumentationURL string // JSONSchema is a JSON schema for a given plugin configuration. JSONSchema JSONSchema // ExternalRequest holds the metadata for external requests. ExternalRequest ExternalRequestMetadata // Dependencies holds the dependencies for a given platform binary. Dependencies map[string]Dependency // Recommended plugin recommended Recommended bool }
MetadataOutput contains the metadata of a given plugin.
func (MetadataOutput) Validate ¶
func (m MetadataOutput) Validate() error
Validate validate the metadata fields and returns detected issues.
type MultiSelect ¶ added in v1.0.0
type MultiSelect struct { Name string `json:"name,omitempty" yaml:"name"` Description Body `json:"description,omitempty" yaml:"description"` Command string `json:"command,omitempty" yaml:"command"` // Options holds all available options Options []OptionItem `json:"options,omitempty" yaml:"options"` // InitialOptions hold already pre-selected options. MUST be a sub-set of Options. InitialOptions []OptionItem `json:"initialOptions,omitempty" yaml:"initialOptions"` }
MultiSelect holds multi select related fields.
func ReplaceBotNameInMultiSelect ¶ added in v1.0.0
func ReplaceBotNameInMultiSelect(ms MultiSelect, name string, opts BotNameOptions) MultiSelect
ReplaceBotNameInMultiSelect replaces bot name placeholder with a given name.
func (*MultiSelect) AreOptionsDefined ¶ added in v1.0.0
func (m *MultiSelect) AreOptionsDefined() bool
AreOptionsDefined returns true if some options are available.
type OptionGroup ¶ added in v1.0.0
type OptionGroup struct { Name string `json:"name,omitempty" yaml:"name"` Options []OptionItem `json:"options,omitempty" yaml:"options"` }
OptionGroup holds information about options in the same group.
func ReplaceBotNameInOptionGroups ¶ added in v1.0.0
func ReplaceBotNameInOptionGroups(groups []OptionGroup, name string) []OptionGroup
ReplaceBotNameInOptionGroups replaces bot name placeholder with a given name.
type OptionItem ¶ added in v1.0.0
type OptionItem struct { Name string `json:"name,omitempty" yaml:"name"` Value string `json:"value,omitempty" yaml:"value"` }
OptionItem defines an option model.
func ReplaceBotNameInOptionItem ¶ added in v1.0.0
func ReplaceBotNameInOptionItem(item *OptionItem, name string) *OptionItem
ReplaceBotNameInOptionItem replaces bot name placeholder with a given name.
func ReplaceBotNameInOptions ¶ added in v1.0.0
func ReplaceBotNameInOptions(items []OptionItem, name string) []OptionItem
ReplaceBotNameInOptions replaces bot name placeholder with a given name.
type PluginDependencyURLsGetter ¶ added in v0.18.0
PluginDependencyURLsGetter is an interface for getting plugin dependency URLs.
type PluginDependencyURLsSetter ¶ added in v0.18.0
type PluginDependencyURLsSetter[T any] interface { SetUrls(in map[string]string) *T // This is needed to ensure we can create an instance of the concrete type as a part of the ConvertDependenciesFromAPI function. }
PluginDependencyURLsSetter is an interface for setting plugin dependency URLs.
type Section ¶ added in v1.0.0
type Section struct { Style SectionStyle `json:"style,omitempty" yaml:"style"` Base `json:",inline" yaml:"base"` Buttons Buttons `json:"buttons,omitempty" yaml:"buttons"` MultiSelect MultiSelect `json:"multiSelect,omitempty" yaml:"multiSelect"` Selects Selects `json:"selects,omitempty" yaml:"selects"` PlaintextInputs LabelInputs `json:"plaintextInputs,omitempty" yaml:"plaintextInputs"` TextFields TextFields `json:"textFields,omitempty" yaml:"textFields"` BulletLists BulletLists `json:"bulletLists,omitempty" yaml:"bulletLists"` Context ContextItems `json:"context,omitempty" yaml:"context"` }
Section holds section related fields.
type SectionStyle ¶ added in v1.11.0
type SectionStyle struct {
Divider DividerStyle `json:"divider,omitempty" yaml:"dividerStyle"`
}
SectionStyle holds section style.
type Select ¶ added in v1.0.0
type Select struct { Type SelectType `json:"type,omitempty" yaml:"type"` Name string `json:"name,omitempty" yaml:"name"` Command string `json:"command,omitempty" yaml:"command"` // OptionGroups provides a way to group options in a select menu. OptionGroups []OptionGroup `json:"optionGroups,omitempty" yaml:"optionGroups"` // InitialOption holds already pre-selected options. MUST be a sub-set of OptionGroups. InitialOption *OptionItem `json:"initialOption,omitempty" yaml:"initialOption"` }
Select holds data related to the select drop-down.
type SelectType ¶ added in v1.0.0
type SelectType string
SelectType is a type of Button element.
const ( StaticSelect SelectType = "static" ExternalSelect SelectType = "external" )
Represents a select dropdown types.
type Selects ¶ added in v1.0.0
type Selects struct { // ID allows to identify a given block when we do the updated. ID string `json:"id,omitempty" yaml:"id"` Items []Select `json:"items,omitempty" yaml:"items"` }
Selects holds multiple Select objects.
func ReplaceBotNameInSelects ¶ added in v1.0.0
func ReplaceBotNameInSelects(selects Selects, name string, opts BotNameOptions) Selects
ReplaceBotNameInSelects replaces bot name placeholder with a given name.
func (*Selects) AreOptionsDefined ¶ added in v1.0.0
AreOptionsDefined returns true if some options are available.
type TextField ¶ added in v1.0.0
type TextField struct { Key string `json:"key,omitempty" yaml:"key"` Value string `json:"value,omitempty" yaml:"value"` }
TextField holds a text field data.
type TextFields ¶ added in v1.0.0
type TextFields []TextField
TextFields holds text field items.
func ReplaceBotNameInTextFields ¶ added in v1.0.0
func ReplaceBotNameInTextFields(fields TextFields, name string) TextFields
ReplaceBotNameInTextFields replaces bot name placeholder with a given name.