Documentation ¶
Index ¶
- Constants
- Variables
- func NewSlackRTM(config config.Config, opts config.Options) *slack.RTM
- type Client
- func (s *Client) ActionFromSlackMessage(messageAction slackevents.MessageAction) ([]string, error)
- func (s *Client) AddReactionToMessage(channel, timestamp, reaction string)
- func (s *Client) AlertFromSlackMessage(message slack.Message) (*client.ExtendedAlert, error)
- func (s *Client) GetAuthorizedSlackUserGroupMembers() error
- func (s *Client) GetUserEmailByID(userID string) (string, error)
- func (s *Client) GetUserNameByID(userID string) (string, error)
- func (s *Client) HandleRTMEvent()
- func (s *Client) HandleSlackCommand(r *http.Request)
- func (s *Client) IsUserAuthorized(userID string) bool
- func (s *Client) MessageActionFromPayload(payload string) (slackevents.MessageAction, error)
- func (s *Client) PostMessage(channel, message, timestamp string)
- func (s *Client) RunRTM()
Constants ¶
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" )
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 ¶
var Action = struct { ShowAlerts string }{ "showAlerts", }
Action struct for available actions that can be triggered
var Reaction = struct { Acknowledge, SilenceUntilMonday, Silence1Month, Silence1Day string }{ "acknowledge", "silenceUntilMonday", "silence1Month", "silence1Day", }
Reaction must match the slack action.Value
Functions ¶
Types ¶
type Client ¶
Client ...
func (*Client) ActionFromSlackMessage ¶
func (s *Client) ActionFromSlackMessage(messageAction slackevents.MessageAction) ([]string, error)
ActionFromSlackMessage retrieves the action from a slack message.
func (*Client) AddReactionToMessage ¶
AddReactionToMessage adds a reaction to a message.
func (*Client) AlertFromSlackMessage ¶
AlertFromSlackMessage extracts an alert from a message.
func (*Client) GetAuthorizedSlackUserGroupMembers ¶
GetAuthorizedSlackUserGroupMembers sets the authorized slack users based on the membership in slack groups.
func (*Client) GetUserEmailByID ¶
GetUserEmailByID returns the users email address.
func (*Client) GetUserNameByID ¶
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 ¶
HandleSlackCommand responds to slack commands
func (*Client) IsUserAuthorized ¶
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 ¶
PostMessage post a message to a channel. If 'timestamp' is given, the message is posted to a thread.