slack

package
v0.0.0-...-8fc2537 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySetup        = "Setup"
	KeyConfig       = "Config"
	KeyListen       = "Listen"
	KeyPostStatusOf = "PostStatusOf"
)
View Source
const Key = Namespace("slack")

Key is a name of the plugin variable

Variables

This section is empty.

Functions

func Abort

func Abort(input string) bool

Abort parses stop cancel message

func Confirm

func Confirm(input string) bool

Confirm parses input looking for confirmation message

func Scope

func Scope() (force.Group, error)

Scope returns a new scope with all the functions and structs defined, this is the entrypoint into plugin as far as force is concerned

Types

type Chat

type Chat struct {
	// Command is a command that has matched
	Command Command
	// Values is a list of parsed values
	Values map[string]interface{}
	// RequestedHelp is set when user has requested help,
	// in this case Command contains the command the user has requested
	// help about
	RequestedHelp bool
}

Chat is a result of parsed chat command

type ChatEvent

type ChatEvent struct {
	Values interface{}
	// contains filtered or unexported fields
}

ChatEvent is event

func (*ChatEvent) AddMetadata

func (r *ChatEvent) AddMetadata(ctx force.ExecutionContext)

AddMetadata adds metadata to the logger and the context, such as commit id and PR number

func (*ChatEvent) Created

func (c *ChatEvent) Created() time.Time

Created returns a time when the event was originated

func (*ChatEvent) String

func (r *ChatEvent) String() string

type ChatParser

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

ChatParser parses chat based on the dialog

func NewParser

func NewParser(d Dialog) (*ChatParser, error)

NewParser returns new chat parser based on the dialog help commands are generated programmatically

func (*ChatParser) HelpMessage

func (p *ChatParser) HelpMessage(commandName string) string

HelpMessage generates and returns help message for individual command or generic message if commandName is empty

func (*ChatParser) Parse

func (p *ChatParser) Parse(input string) (*Chat, error)

Parse parses user input into structured chat

func (*ChatParser) SupportedCommands

func (p *ChatParser) SupportedCommands() []string

SupportedCommands returns a list of supported commands

type Command

type Command struct {
	// Name is a unique command name
	Name string
	// Fields are command fields
	Fields []Field
	// Help is a help message
	Help string
	// Confirm requests confirmation for command
	Confirm bool
}

Command is matched by regular expression

func (Command) CheckAndSetDefaults

func (c Command) CheckAndSetDefaults() error

CheckAndSetDefaults checks and sets defaults for command

func (Command) ConfirmationMessage

func (c Command) ConfirmationMessage(values map[string]interface{}) string

ConfirmationMessage returns confirmation message

func (Command) HelpMessage

func (c Command) HelpMessage() string

HelpMessage returns command help messsage

func (Command) Parse

func (c Command) Parse(input string) (map[string]interface{}, error)

Parse will return not found if could not parse, error otherwise

type Config

type Config struct {
	// Token is a slack token
	Token string
}

Config is a slack configuration

func (*Config) CheckAndSetDefaults

func (cfg *Config) CheckAndSetDefaults() error

type Dialog

type Dialog struct {
	Commands []Command
}

Dialog consists of a list of commands

type Field

type Field struct {
	// Name is a field name
	Name string
	// Required sets whether the field is required
	Required bool
	// Help sets the help
	Help string
	// Value is a field parser
	Value FieldParser
}

Field is a command field

func (*Field) HelpMessage

func (f *Field) HelpMessage() string

type FieldParser

type FieldParser interface {
	// Parse parses command
	Parse(words []string) (interface{}, error)
	// HelpMessage
	HelpMessage() string
	// DefaultValue returns default value
	DefaultValue() interface{}
}

FieldParser parses command

type Listener

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

Listener is chat listener

func (*Listener) Done

func (r *Listener) Done() <-chan struct{}

Done returns channel closed when repository watcher is closed

func (*Listener) Events

func (r *Listener) Events() <-chan force.Event

Events returns events stream with commands

func (*Listener) MarshalCode

func (r *Listener) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals things to code

func (*Listener) Start

func (r *Listener) Start(pctx context.Context) error

Start starts watch on a repo

func (*Listener) String

func (r *Listener) String() string

String returns user friendly representation of the watcher

type Namespace

type Namespace string

Namespace is a wrapper around string to namespace a variable in the context

type NewListen

type NewListen struct {
}

NewListen returns new listen

func (*NewListen) NewInstance

func (n *NewListen) NewInstance(group force.Group) (force.Group, interface{})

NewInstance returns a function creating new watchers

type NewPostStatusOf

type NewPostStatusOf struct {
}

NewPostStatusOf returns a function that wraps underlying action and tracks the result, posting the result back

func (*NewPostStatusOf) NewInstance

func (n *NewPostStatusOf) NewInstance(group force.Group) (force.Group, interface{})

NewInstance returns a function creating new post status actions

type Plugin

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

Plugin is a new plugin

type PostStatusOfAction

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

PostStatusOfAction executes an action and posts its status to slack

func (*PostStatusOfAction) Eval

func (p *PostStatusOfAction) Eval(ctx force.ExecutionContext) (interface{}, error)

func (*PostStatusOfAction) MarshalCode

func (p *PostStatusOfAction) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals the action into code representation

func (*PostStatusOfAction) Type

func (p *PostStatusOfAction) Type() interface{}

type Setup

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

Setup creates new plugin instances

func (*Setup) Eval

func (n *Setup) Eval(ctx force.ExecutionContext) (interface{}, error)

Run sets up git plugin for the process group

func (*Setup) MarshalCode

func (n *Setup) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals plugin code to representation

func (*Setup) NewInstance

func (n *Setup) NewInstance(group force.Group) (force.Group, interface{})

NewInstance returns function creating new client bound to the process group and registers plugin variable

func (*Setup) Type

func (n *Setup) Type() interface{}

type String

type String struct {
	Default string
}

func (String) DefaultValue

func (s String) DefaultValue() interface{}

Default returns default value

func (String) HelpMessage

func (s String) HelpMessage() string

func (String) Parse

func (s String) Parse(input []string) (interface{}, error)

type StringsEnum

type StringsEnum struct {
	Enum       []string
	Default    []string
	DefaultAll bool
}

StringsEnum enumerates strings

func (StringsEnum) DefaultValue

func (p StringsEnum) DefaultValue() interface{}

DefaultValue returns default value

func (StringsEnum) HelpMessage

func (p StringsEnum) HelpMessage() string

HelpMessage rr

func (StringsEnum) Parse

func (p StringsEnum) Parse(words []string) (interface{}, error)

Parse parses the command

func (StringsEnum) SupportedValues

func (p StringsEnum) SupportedValues() string

SupportedValues lists supported values

Jump to

Keyboard shortcuts

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