slack

package
v0.0.0-...-7f90a9e Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultUser for sending notifications to slack
	DefaultUser = "Shoutrrr"
	// 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

Types

type Config

type Config struct {
	standard.QuerylessConfig
	standard.EnumlessConfig
	BotName string
	Token   Token
}

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(serviceURL *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"`
}

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 *log.Logger) 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 struct {
	A string
	B string
	C 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