Documentation ¶
Index ¶
- Constants
- func MdHeaderFormatter(msg string) string
- func MessageToPlaintext(msg Message, newlineFormatter func(in string) string) string
- func NewlineFormatter(msg string) string
- func NoFormatting(msg string) string
- func RenderMessage(mdFormatter MDFormatter, msg Message) string
- type Base
- type Body
- 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) ForCommandWithDescCmd(name, 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
- type ButtonStyle
- type Buttons
- type ContextItem
- type ContextItems
- type DispatchedInputAction
- type GenericMessage
- type HelpMessage
- type LabelInput
- type LabelInputs
- type MDFormatter
- type Message
- type MessageType
- type MultiSelect
- type OptionGroup
- type OptionItem
- type Section
- type Select
- type SelectType
- type Selects
- type TextField
- type TextFields
Constants ¶
const RunCommandName = "Run command"
RunCommandName defines the button name for the run commands.
Variables ¶
This section is empty.
Functions ¶
func MdHeaderFormatter ¶
MdHeaderFormatter adds Markdown header formatting.
func MessageToPlaintext ¶
MessageToPlaintext returns interactive message as a plaintext.
func NewlineFormatter ¶
NewlineFormatter adds new line formatting.
func NoFormatting ¶
NoFormatting does not apply any formatting.
func RenderMessage ¶
func RenderMessage(mdFormatter MDFormatter, msg Message) string
RenderMessage returns interactive message as a plaintext with Markdown syntax.
Types ¶
type Button ¶
type Button struct { Description string Name string Command string URL string Style ButtonStyle }
Button holds definition of action button.
type ButtonBuilder ¶ added in v0.15.0
type ButtonBuilder struct {
BotName string
}
ButtonBuilder provides a simplified way to construct a Button model.
func (*ButtonBuilder) DescriptionURL ¶ added in v0.15.0
func (b *ButtonBuilder) DescriptionURL(name, cmd string, url string, style ...ButtonStyle) Button
DescriptionURL returns link button with description.
func (*ButtonBuilder) ForCommand ¶ added in v0.15.0
func (b *ButtonBuilder) ForCommand(name, cmd, desc string, style ...ButtonStyle) Button
ForCommand returns button command.
func (*ButtonBuilder) ForCommandWithDescCmd ¶ added in v0.15.0
func (b *ButtonBuilder) ForCommandWithDescCmd(name, cmd string, style ...ButtonStyle) Button
ForCommandWithDescCmd returns button command where description and command are the same.
func (*ButtonBuilder) ForCommandWithoutDesc ¶ added in v0.15.0
func (b *ButtonBuilder) ForCommandWithoutDesc(name, cmd string, style ...ButtonStyle) Button
ForCommandWithoutDesc returns button command without description.
func (*ButtonBuilder) ForURL ¶ added in v0.15.0
func (b *ButtonBuilder) ForURL(name, url string, style ...ButtonStyle) Button
ForURL returns link button.
type ButtonStyle ¶
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 ¶
type Buttons []Button
Buttons holds definition of interactive buttons.
func (*Buttons) AtLeastOneButtonHasDescription ¶
AtLeastOneButtonHasDescription returns true if there is at least one button with description associated with it.
func (*Buttons) ReplaceBotNameInCommands ¶ added in v0.16.0
ReplaceBotNameInCommands replaces bot name in commands.
type ContextItem ¶ added in v0.15.0
type ContextItem struct {
Text string
}
ContextItem holds context item.
type ContextItems ¶ added in v0.15.0
type ContextItems []ContextItem
ContextItems holds context items.
func (ContextItems) IsDefined ¶ added in v0.15.0
func (c ContextItems) IsDefined() bool
IsDefined returns true if there are any context items defined.
type DispatchedInputAction ¶ added in v0.15.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 GenericMessage ¶ added in v0.16.0
GenericMessage returns a message which has customized content. For example, it returns a message with customized commands based on bot name.
type HelpMessage ¶ added in v0.15.0
type HelpMessage struct {
// contains filtered or unexported fields
}
HelpMessage provides an option to build the Help message depending on a given platform.
func NewHelpMessage ¶ added in v0.15.0
func NewHelpMessage(platform config.CommPlatformIntegration, clusterName, botName string) *HelpMessage
NewHelpMessage return a new instance of HelpMessage.
func (*HelpMessage) Build ¶ added in v0.15.0
func (h *HelpMessage) Build() Message
Build returns help message with interactive sections.
type LabelInput ¶ added in v0.15.0
type LabelInput struct { Command string Text string Placeholder string DispatchedAction DispatchedInputAction }
LabelInput is used to create input elements to use in slack messages.
type LabelInputs ¶ added in v0.15.0
type LabelInputs []LabelInput
LabelInputs holds the plain text input items.
func (*LabelInputs) ReplaceBotNameInCommands ¶ added in v0.16.0
func (l *LabelInputs) ReplaceBotNameInCommands(old, new string)
ReplaceBotNameInCommands replaces bot name in commands.
type MDFormatter ¶
type MDFormatter struct {
// contains filtered or unexported fields
}
MDFormatter represents the capability of Markdown Formatter
func DefaultMDFormatter ¶
func DefaultMDFormatter() MDFormatter
DefaultMDFormatter is for initializing built-in Markdown formatter
func NewMDFormatter ¶
func NewMDFormatter(newlineFormatter, headerFormatter func(msg string) string) MDFormatter
NewMDFormatter is for initializing custom Markdown formatter
type Message ¶
type Message struct { Type MessageType Base Sections []Section PlaintextInputs LabelInputs OnlyVisibleForYou bool ReplaceOriginal bool }
Message represents a generic message with interactive buttons.
func (*Message) HasInputs ¶ added in v0.15.0
HasInputs returns true if message has interactive inputs.
func (*Message) HasSections ¶
HasSections returns true if message has interactive sections.
func (*Message) ReplaceBotNameInCommands ¶ added in v0.16.0
ReplaceBotNameInCommands replaces bot name in commands.
type MessageType ¶
type MessageType string
MessageType defines the message type.
const ( // Default defines a message that should be displayed in default mode supported by communicator. Default MessageType = "" // Popup defines a message that should be displayed to the user as popup (if possible). Popup MessageType = "form" )
type MultiSelect ¶
type MultiSelect struct { Name string Description Body Command string // Options holds all available options Options []OptionItem // InitialOptions hold already pre-selected options. MUST be a sub-set of Options. InitialOptions []OptionItem }
MultiSelect holds multi select related fields.
func (*MultiSelect) AreOptionsDefined ¶
func (m *MultiSelect) AreOptionsDefined() bool
AreOptionsDefined returns true if some options are available.
func (*MultiSelect) ReplaceBotNameInCommands ¶ added in v0.16.0
func (m *MultiSelect) ReplaceBotNameInCommands(old, new string)
ReplaceBotNameInCommands replaces bot name in commands.
type OptionGroup ¶ added in v0.15.0
type OptionGroup struct { Name string Options []OptionItem }
OptionGroup holds information about options in the same group.
type OptionItem ¶
OptionItem defines an option model.
type Section ¶
type Section struct { Base Buttons Buttons MultiSelect MultiSelect Selects Selects PlaintextInputs LabelInputs TextFields TextFields Context ContextItems }
Section holds section related fields.
func EventCommandsSection ¶ added in v0.15.0
func EventCommandsSection(cmdPrefix string, optionItems []OptionItem) Section
EventCommandsSection defines a structure of commands for a given event.
type Select ¶ added in v0.15.0
type Select struct { Type SelectType Name string Command string // OptionGroups provides a way to group options in a select menu. OptionGroups []OptionGroup // InitialOption holds already pre-selected options. MUST be a sub-set of OptionGroups. InitialOption *OptionItem }
Select holds data related to the select drop-down.
type SelectType ¶ added in v0.15.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 v0.15.0
type Selects struct { // ID allows to identify a given block when we do the updated. ID string Items []Select }
Selects holds multiple Select objects.
func (*Selects) AreOptionsDefined ¶ added in v0.15.0
AreOptionsDefined returns true if some options are available.
func (*Selects) ReplaceBotNameInCommands ¶ added in v0.16.0
ReplaceBotNameInCommands replaces bot name in commands.