Documentation
¶
Index ¶
Constants ¶
const ( BoxPrefixInfo = "⬜️ " BoxPrefixWarn = "🟧 " BoxPrefixError = "🟥 " BoxPrefixSuccess = "🟩 " )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Token is the token you get from the OAuth&Permissions tab in your slack // application's features. Token string // Channel is the channel ID you get after pressing the 'Get channel // details' button (channel title) in any channel, the Channel ID is at the // bottom of the pop-up box. Channel string // URL is optional and only needs to be set when testing with a local mock // slack server. URL string // ErrorLogger is an optional place that any failures to send slack messages // are written to; to prevent issues our SendMessage() never returns an // error because it runs in a goroutine and returns immediately. ErrorLogger io.Writer }
Config provides configuration for a Slack.
type HighestNumDebouncer ¶ added in v1.6.0
HighestNumDebouncer holds values for debouncing slack messages based on the highest number in a given period.
func NewHighestNumDebouncer ¶ added in v1.6.0
func NewHighestNumDebouncer(slacker Slacker, debounceTimeout time.Duration, msg string) *HighestNumDebouncer
NewHighestNumDebouncer initialises a new HighestNumDebouncer instance.
- slacker: a slacker.
- debounceTimeout: the minimum interval between sending messages.
- msg: a message suffix that will be appended to the highest number in the debounce period.
func (*HighestNumDebouncer) SendDebounceMsg ¶ added in v1.6.0
func (hnd *HighestNumDebouncer) SendDebounceMsg(num int)
SendDebounceMsg sends a Slack message if conditions are met, ensuring only one unique message is sent within the specified debounce interval.
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
func NewMock ¶
func NewMock(logger *gas.StringLogger) *Mock
func (*Mock) SendMessage ¶
type Slack ¶
type Slack struct {
// contains filtered or unexported fields
}
Slack is something that lets you send messages to Slack.
func New ¶
New creates a new Slack using the Token, Channel and URL (if provided) from the Config.
To get the token you must first create a Slack application, which needs to be a bot with these scopes added: chat:write, chat:write.customize, chat:write.public, groups:read and incoming-webhook, and then add this bot to your workspace.
func (*Slack) SendMessage ¶
SendMessage sends the given message to our configured channel, prefixing it with a colour corresponding to its level.
NB: this returns immediately, sending in a goroutine. To see errors, configer the slacker with an ErrorLogger.