slack

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Scheme is the identifying part of this service's configuration URL
	Scheme = "slack"
)

Variables

This section is empty.

Functions

func CreateJSONPayload

func CreateJSONPayload(config *Config, message string) ([]byte, error)

CreateJSONPayload compatible with the slack webhook api

func ValidateToken

func ValidateToken(token Token) error

ValidateToken checks that the token is in the expected format

Types

type Config

type Config struct {
	standard.EnumlessConfig
	BotName string   `default:"" optional:""`
	Token   []string `description:"List of comma separated token parts"`
	Color   string   `key:"color" optional:""`
	Title   string   `key:"title" optional:""`
}

Config for the slack service

func CreateConfigFromURL

func CreateConfigFromURL(serviceURL *url.URL) (*Config, error)

CreateConfigFromURL to use within the slack service

func (*Config) GetURL

func (config *Config) GetURL() *url.URL

GetURL returns a URL representation of it's current field values

func (*Config) SetURL

func (config *Config) SetURL(url *url.URL) error

SetURL updates a ServiceConfig from a URL representation of it's field values

type ErrorMessage

type ErrorMessage string

ErrorMessage for error events within the slack service

const (
	// TokenAMissing from the service URL
	TokenAMissing ErrorMessage = "first part of the API token is missing"
	// TokenBMissing from the service URL
	TokenBMissing ErrorMessage = "second part of the API token is missing"
	// TokenCMissing from the service URL
	TokenCMissing ErrorMessage = "third part of the API token is missing."
	// TokenAMalformed inthe service URL
	TokenAMalformed ErrorMessage = "first part of the API token is malformed"
	// TokenBMalformed inthe service URL
	TokenBMalformed ErrorMessage = "second part of the API token is malformed"
	// TokenCMalformed inthe service URL
	TokenCMalformed ErrorMessage = "third part of the API token is malformed"
	// NotEnoughArguments provided in the service URL
	NotEnoughArguments ErrorMessage = "the apiURL does not include enough arguments"
)

type JSON

type JSON struct {
	Text        string       `json:"text"`
	BotName     string       `json:"username,omitempty"`
	Blocks      []block      `json:"blocks,omitempty"`
	Attachments []attachment `json:"attachments,omitempty"`
}

JSON used within the Slack service

type Service

type Service struct {
	standard.Standard
	// contains filtered or unexported fields
}

Service sends notifications to a pre-configured channel or user

func (*Service) Initialize

func (service *Service) Initialize(configURL *url.URL, logger types.StdLogger) error

Initialize loads ServiceConfig from configURL and sets logger for this Service

func (*Service) Send

func (service *Service) Send(message string, params *types.Params) error

Send a notification message to Slack

type Token

type Token []string

Token is a three part string split into A, B and C

func ParseToken

func ParseToken(s string) Token

ParseToken creates a Token from a sting representation

func (Token) String

func (t Token) String() string

Jump to

Keyboard shortcuts

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