flow

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialogGoto added in v0.0.25

func DialogGoto(toName Name) func(*Flow, map[string]interface{}) (Name, State, map[string]string, error)

func Goto added in v0.0.25

func Goto(toName Name) func(*Flow) (Name, State, error)

Types

type Button added in v0.0.25

type Button struct {
	Name     string
	Disabled bool
	Color    Color

	// OnClick is called when the button is clicked. It returns the next step's
	// name and the state updates to apply.
	//
	// If Dialog is also specified, OnClick is executed first.
	OnClick func(f *Flow) (Name, State, error)

	// Dialog is the interactive dialog to display if the button is clicked
	// (OnClick is executed first). OnDialogSubmit must be provided.
	Dialog *model.Dialog

	// Function that is called when the dialog box is submitted. It can return a
	// general error, or field-specific errors. On success it returns the name
	// of the next step, and the state updates to apply.
	OnDialogSubmit func(f *Flow, submitted map[string]interface{}) (Name, State, map[string]string, error)
}

type Color added in v0.0.25

type Color string
const (
	ColorDefault Color = "default"
	ColorPrimary Color = "primary"
	ColorSuccess Color = "success"
	ColorGood    Color = "good"
	ColorWarning Color = "warning"
	ColorDanger  Color = "danger"
)

type Flow

type Flow struct {
	UserID string
	// contains filtered or unexported fields
}

func NewFlow

func NewFlow(name Name, api *pluginapi.Client, pluginURL, botUserID string) *Flow

NewFlow creates a new flow using direct messages with the user.

name must be a unique identifier for the flow within the plugin.

func (*Flow) Finish added in v0.0.25

func (f *Flow) Finish() error

func (*Flow) ForUser added in v0.0.25

func (f *Flow) ForUser(userID string) *Flow

ForUser creates a new flow using direct messages with the user.

func (*Flow) GetCurrentStep added in v0.0.25

func (f *Flow) GetCurrentStep() (Name, error)

func (*Flow) GetState added in v0.0.25

func (f *Flow) GetState() State

func (*Flow) Go added in v0.0.25

func (f *Flow) Go(toName Name) error

func (*Flow) InitHTTP added in v0.0.25

func (f *Flow) InitHTTP(r *mux.Router) *Flow

func (*Flow) OnDone added in v0.0.25

func (f *Flow) OnDone(done func(string, State) error) *Flow

func (*Flow) Start added in v0.0.25

func (f *Flow) Start(appState State) error

func (*Flow) WithDebugLog added in v0.0.25

func (f *Flow) WithDebugLog() *Flow

func (*Flow) WithSteps added in v0.0.25

func (f *Flow) WithSteps(orderedSteps ...Step) *Flow

type Name added in v0.0.25

type Name string

type State added in v0.0.25

type State map[string]interface{}

State is the "app"'s state

func (State) GetBool added in v0.0.25

func (s State) GetBool(key string) bool

GetBool return the value to a given key as a bool. If the key is not found or isn't a bool, false is returned.

func (State) GetInt added in v0.0.25

func (s State) GetInt(key string) int

GetInt return the value to a given key as a int. If the key is not found or isn't an int, zero is returned.

func (State) GetString added in v0.0.25

func (s State) GetString(key string) string

GetString return the value to a given key as a string. If the key is not found or isn't a string, an empty string is returned.

func (State) MergeWith added in v0.0.25

func (s State) MergeWith(update State) State

type Step added in v0.0.25

type Step struct {
	// contains filtered or unexported fields
}

func NewStep added in v0.0.25

func NewStep(name Name) Step

func (Step) Next added in v0.0.25

func (s Step) Next(name Name) Step

func (Step) OnRender added in v0.0.25

func (s Step) OnRender(f func(*Flow)) Step

func (Step) Terminal added in v0.0.25

func (s Step) Terminal() Step

func (Step) WithButton added in v0.0.25

func (s Step) WithButton(buttons ...Button) Step

func (Step) WithColor added in v0.0.25

func (s Step) WithColor(color Color) Step

func (Step) WithField added in v0.0.25

func (s Step) WithField(title, value string) Step

func (Step) WithImage added in v0.0.25

func (s Step) WithImage(imageURL string) Step

func (Step) WithPretext added in v0.0.25

func (s Step) WithPretext(text string) Step

func (Step) WithText added in v0.0.25

func (s Step) WithText(text string) Step

func (Step) WithTitle added in v0.0.25

func (s Step) WithTitle(text string) Step

Jump to

Keyboard shortcuts

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