interactive

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MdHeaderFormatter

func MdHeaderFormatter(msg string) string

MdHeaderFormatter adds Markdown header formatting.

func MessageToPlaintext

func MessageToPlaintext(msg Message, newlineFormatter func(in string) string) string

MessageToPlaintext returns interactive message as a plaintext.

func NewlineFormatter

func NewlineFormatter(msg string) string

NewlineFormatter adds new line formatting.

func NoFormatting

func NoFormatting(msg string) string

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 Base

type Base struct {
	Header      string
	Description string
	Body        Body
}

Base holds generic message fields.

type Body

type Body struct {
	CodeBlock string
	Plaintext string
}

Body holds message body fields.

type Button

type Button struct {
	Description string
	Name        string
	Command     string
	URL         string
	Style       ButtonStyle
}

Button holds definition of action 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

func (s *Buttons) AtLeastOneButtonHasDescription() bool

AtLeastOneButtonHasDescription returns true if there is at least one button with description associated with it.

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
	OnlyVisibleForYou bool
}

Message represents a generic message with interactive buttons.

func Feedback

func Feedback() Message

Feedback generates Message structure.

func Help

func Help(platform config.CommPlatformIntegration, clusterName, botName string) Message

Help represent a help message with interactive sections.

func (*Message) HasSections

func (msg *Message) HasSections() bool

HasSections returns true if message has interactive sections.

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.

type OptionItem

type OptionItem struct {
	Name  string
	Value string
}

OptionItem defines an option model.

type Section

type Section struct {
	Base
	Buttons     Buttons
	MultiSelect MultiSelect
}

Section holds section related fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL