slack

package
v0.0.0-...-df093e9 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ActionName the name of the action the stargate is responding to
	ActionName = "reaction"

	// ActionType the type of the action the stargate is responding to
	ActionType = "button"

	// SilenceSuccessReactionEmoji is applied to a message after it was successfully silenced
	SilenceSuccessReactionEmoji = "silent-bell"

	// AcknowledgeReactionEmoji is applied to a message after it was successfully acknowledged
	AcknowledgeReactionEmoji = "male-firefighter"

	// SilenceDefaultComment is the default comment used for a silence
	SilenceDefaultComment = "silenced by the stargate"
)
View Source
const (
	// SeverityRegionRemainderRegex finds the severity and region in the alert text
	SeverityRegionRemainderRegex = `.*\*\[(?P<severity>.+?)(\s-.*)?\]\*\s\*\[(?P<region>.+?)\]\*(?P<remainder>.+?)(\>\*)?\s\-.*`

	// AlertnameRemainderRegex finds the alertname from the remainder of the alert text
	AlertnameRemainderRegex = `(.+\/#\/alerts.+\||\s)?(?P<alertname>.+)(\>\*)?`

	//RegionRegex is the regions by which regions names are found
	RegionRegex = `\S{2}\-\S{2}\-\d|staging|admin`
)

Variables

View Source
var Action = struct {
	ShowAlerts string
}{
	"showAlerts",
}

Action struct for available actions that can be triggered

View Source
var Reaction = struct {
	Acknowledge,
	SilenceUntilMonday,
	Silence1Month,
	Silence1Day string
}{
	"acknowledge",
	"silenceUntilMonday",
	"silence1Month",
	"silence1Day",
}

Reaction must match the slack action.Value

Functions

func NewSlackRTM

func NewSlackRTM(config config.Config, opts config.Options) *slack.RTM

NewSlackRTM ...

Types

type Client

type Client struct {
	Client *slack.Client
	// contains filtered or unexported fields
}

Client ...

func NewClient

func NewClient(config config.Config, opts config.Options, logger log.Logger) *Client

NewClient returns a new slack client.

func (*Client) ActionFromSlackMessage

func (s *Client) ActionFromSlackMessage(messageAction slackevents.MessageAction) ([]string, error)

ActionFromSlackMessage retrieves the action from a slack message.

func (*Client) AddReactionToMessage

func (s *Client) AddReactionToMessage(channel, timestamp, reaction string)

AddReactionToMessage adds a reaction to a message.

func (*Client) AlertFromSlackMessage

func (s *Client) AlertFromSlackMessage(message slack.Message) (*client.ExtendedAlert, error)

AlertFromSlackMessage extracts an alert from a message.

func (*Client) GetAuthorizedSlackUserGroupMembers

func (s *Client) GetAuthorizedSlackUserGroupMembers() error

GetAuthorizedSlackUserGroupMembers sets the authorized slack users based on the membership in slack groups.

func (*Client) GetUserEmailByID

func (s *Client) GetUserEmailByID(userID string) (string, error)

GetUserEmailByID returns the users email address.

func (*Client) GetUserNameByID

func (s *Client) GetUserNameByID(userID string) (string, error)

GetUserNameByID converts the userID to a human readable name in the format 'userRealName (userName)'.

func (*Client) HandleRTMEvent

func (s *Client) HandleRTMEvent()

HandleRTMEvent handles slack RTM events

func (*Client) HandleSlackCommand

func (s *Client) HandleSlackCommand(r *http.Request)

HandleSlackCommand responds to slack commands

func (*Client) IsUserAuthorized

func (s *Client) IsUserAuthorized(userID string) bool

IsUserAuthorized checks whether a user is authorized.

func (*Client) MessageActionFromPayload

func (s *Client) MessageActionFromPayload(payload string) (slackevents.MessageAction, error)

MessageActionFromPayload retrieves the slack message action from a payload.

func (*Client) PostMessage

func (s *Client) PostMessage(channel, message, timestamp string)

PostMessage post a message to a channel. If 'timestamp' is given, the message is posted to a thread.

func (*Client) RunRTM

func (s *Client) RunRTM()

RunRTM starts the slack RTM client

Jump to

Keyboard shortcuts

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