plugins

package
v0.0.0-...-5eac97b Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: GPL-3.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// TwilioPhone is the "to" phone number that's set through Slack (@slab twilio
	//	set)
	TwilioPhone string

	// TwilioFrom is the "from" phone number that's set through Slack (@slab twilio
	// configure)
	TwilioFrom string

	// TwilioEnabled holds whether the Twilio plugin is enabled or disabled.
	TwilioEnabled bool
)
View Source
var Commands map[string]func([]string) ([]slack.Attachment, string)

Commands is a map of all of the text commands needed to trigger individual plugins

View Source
var (

	// PagerDutyEnabled holds whether the PagerDuty plugin is enabled or disabled.
	PagerDutyEnabled bool
)
View Source
var Send map[string]func(*Plugins, string)

Send is a map of every function used to send plugin messages

Functions

func ParsePluginCommand

func ParsePluginCommand(text string, user *slack.User) (message string, attachments []slack.Attachment)

ParsePluginCommand is ran before the core Slab commands are parsed to determine if a given command is related to a plugin or not. If it is, it returns a message and attachment which is then sent in slack/commands.go

func SavePlugins

func SavePlugins(config Plugins) bool

SavePlugins takes a config and saves it to the local file, config.toml.

func TwilioConfigure

func TwilioConfigure(n string) (attachment slack.Attachment)

TwilioConfigure sets the "from" phone number to allow for international numbers to be set properly

func TwilioSet

func TwilioSet(n string) (attachment slack.Attachment)

TwilioSet changes the TwilioPhone to the value of the number passed to it.

func TwilioUnset

func TwilioUnset() (attachment slack.Attachment)

TwilioUnset sets the TwilioPhone to `none`

Types

type PagerDuty

type PagerDuty struct {
	APIKey    string
	ServiceID string
	Enabled   bool
}

PagerDuty contains the connection details for the PagerDuty API:

type Plugins

type Plugins struct {
	Twilio    Twilio
	PagerDuty PagerDuty
}

Plugins contains a list of all available plugins

func LoadPlugins

func LoadPlugins() (config Plugins)

LoadPlugins grabs the command line argument for where the configuration file is located and loads that into memory.

func (*Plugins) DemoPagerDuty

func (p *Plugins) DemoPagerDuty()

DemoPagerDuty grabs a demo list of incidents from PagerDuty

func (*Plugins) DisablePagerDuty

func (p *Plugins) DisablePagerDuty() (attachment slack.Attachment)

DisablePagerDuty changes the Enabled PagerDuty option to false.

func (*Plugins) DisableTwilio

func (p *Plugins) DisableTwilio() (attachment slack.Attachment)

DisableTwilio changes the Enabled Twilio option to false.

func (*Plugins) EnablePagerDuty

func (p *Plugins) EnablePagerDuty() (attachment slack.Attachment)

EnablePagerDuty changes the Enabled PagerDuty option to true.

func (*Plugins) EnableTwilio

func (p *Plugins) EnableTwilio() (attachment slack.Attachment)

EnableTwilio changes the Enabled Twilio option to true.

func (*Plugins) PagerDutyStatus

func (p *Plugins) PagerDutyStatus() (attachment slack.Attachment)

PagerDutyStatus returns the current setting

func (*Plugins) SendDispatcher

func (p *Plugins) SendDispatcher(message string)

SendDispatcher receives the message from the process loop and checks which plugins are enabled and sends the appropriate notifications through them.

func (*Plugins) SendPagerDuty

func (p *Plugins) SendPagerDuty(message string)

SendPagerDuty sends a message to PagerDuty and returns a list of incidents

func (*Plugins) SendTwilio

func (p *Plugins) SendTwilio(message string)

SendTwilio sends a message to the phone number currently set as TwilioPhone using the connection data found in the config

func (*Plugins) TwilioStatus

func (p *Plugins) TwilioStatus() (attachment slack.Attachment)

TwilioStatus returns the current setting

type Twilio

type Twilio struct {
	AccountID string
	Auth      string
	Enabled   bool
}

Twilio contains the connection details for the Twilio API: https://www.twilio.com/docs/api

Jump to

Keyboard shortcuts

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