slackmod

package
v0.0.0-...-ca8531b Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostFile

func PostFile(token string, channel string, fileName string) error

PostFile - Post a file of any type to slack channel

func PostSnippet

func PostSnippet(token string, fileType string, fileContent string, channel string, title string, comment string) error

PostSnippet - Post a snippet of any type to slack channel

func Send

func Send(webhookURL string, proxy string, payload Payload) []error

Send - send message

func Wrangler

func Wrangler(webhookURL string, message string, myChannel string, emojiName string, botName string, attachments Attachment)

Wrangler - wrangle slack calls

func WranglerDM

func WranglerDM(opts Slackopts, payload BotDMPayload) error

WranglerDM - Send chat.Post API DM messages "as the bot"

Types

type Attachment

type Attachment struct {
	Fallback   string   `json:"fallback,omitempty"`
	Color      string   `json:"color,omitempty"`
	PreText    string   `json:"pretext,omitempty"`
	AuthorName string   `json:"author_name,omitempty"`
	AuthorLink string   `json:"author_link,omitempty"`
	AuthorIcon string   `json:"author_icon,omitempty"`
	Title      string   `json:"title,omitempty"`
	TitleLink  string   `json:"title_link,omitempty"`
	Text       string   `json:"text,omitempty"`
	ImageURL   string   `json:"image_url,omitempty"`
	Fields     []*Field `json:"fields,omitempty"`
	Footer     string   `json:"footer,omitempty"`
	FooterIcon string   `json:"footer_icon,omitempty"`
	Timestamp  int64    `json:"ts,omitempty"`
	MarkdownIn []string `json:"mrkdwn_in,omitempty"`
}

Attachment - struct

func (*Attachment) AddField

func (attachment *Attachment) AddField(field Field) *Attachment

AddField - add fields

type BasicSlackPayload

type BasicSlackPayload struct {
	Ok    bool   `json:"ok"`
	Error string `json:"error"`
}

BasicSlackPayload - returns most basic slack response payload

type BotDMPayload

type BotDMPayload struct {
	Token          string       `json:"token,omitempty"`
	Channel        string       `json:"channel,omitempty"`
	Text           string       `json:"text,omitempty"`
	AsUser         bool         `json:"as_user,omitempty"`
	Attachments    []Attachment `json:"attachments,omitempty"`
	IconEmoji      string       `json:"icon_emoji,omitempty"`
	IconURL        string       `json:"icon_url,omitempty"`
	LinkNames      bool         `json:"link_names,omitempty"`
	Mkrdwn         bool         `json:"mrkdwn,omitempty"`
	Parse          string       `json:"parse,omitempty"`
	ReplyBroadcast bool         `json:"reply_broadcast,omitempty"`
	ThreadTS       string       `json:"thread_ts,omitempty"`
	UnfurlLinks    bool         `json:"unfurl_links,omitempty"`
	UnfurlMedia    bool         `json:"unfurl_media,omitempty"`
	Username       string       `json:"username,omitempty"`
}

BotDMPayload - struct for bot DMs

type Field

type Field struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short"`
}

Field - struct

type Payload

type Payload struct {
	Parse       string       `json:"parse,omitempty"`
	Username    string       `json:"username,omitempty"`
	IconURL     string       `json:"icon_url,omitempty"`
	IconEmoji   string       `json:"icon_emoji,omitempty"`
	Channel     string       `json:"channel,omitempty"`
	Text        string       `json:"text,omitempty"`
	LinkNames   string       `json:"link_names,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
	UnfurlLinks bool         `json:"unfurl_links,omitempty"`
	UnfurlMedia bool         `json:"unfurl_media,omitempty"`
}

Payload - struct

type Slackopts

type Slackopts struct {
	Version             string
	Config              string
	SlackHook           string
	SlackToken          string
	SlackDefaultName    string
	SlackDefaultChannel string
	SlackDefaultEmoji   string
	Snippet             bool
	BotDM               bool
}

Slackopts - slackCLI Options

func LoadConfig

func LoadConfig(path string) (opts Slackopts, fail string)

LoadConfig - Load Main Configuration JSON

Jump to

Keyboard shortcuts

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