slack

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessory

type Accessory struct {
	Type  string `json:"type"`
	Image string `json:"image_url"`
	Alt   string `json:"alt_text"`
}

Accessory Slack's model

func NewAccessory

func NewAccessory(image, alt string) *Accessory

NewAccessory creates Accessory

type Actions

type Actions struct {
	Type     string    `json:"type"`
	BlockID  string    `json:"block_id,omitempty"`
	Elements []Element `json:"elements"`
}

Actions response for slack

func NewActions

func NewActions(blockID string, elements ...Element) Actions

NewActions creates Actions

type Block

type Block any

Block response for slack

type ButtonElement

type ButtonElement struct {
	Type     string `json:"type"`
	Text     Text   `json:"text"`
	ActionID string `json:"action_id"`
	Value    string `json:"value,omitempty"`
	Style    string `json:"style,omitempty"`
}

ButtonElement response for slack

type CommandHandler

type CommandHandler func(context.Context, SlashPayload) Response

CommandHandler for handling when user send a slash command

type Config

type Config struct {
	ClientID      string
	ClientSecret  string
	SigningSecret string
}

func Flags

func Flags(fs *flag.FlagSet, prefix string, overrides ...flags.Override) *Config

type Context added in v0.0.10

type Context struct {
	Type     string    `json:"type"`
	Elements []Element `json:"elements"`
}

Context response for slack

func NewContext added in v0.0.10

func NewContext() Context

NewContext creates Context

func (Context) AddElement added in v0.0.10

func (c Context) AddElement(element Element) Context

AddElement add given element to context

type Element

type Element any

Element response for slack

func NewButtonElement

func NewButtonElement(text string, actionID, value, style string) Element

NewButtonElement creates ButtonElement

type Image added in v0.0.15

type Image struct {
	Type  string `json:"type"`
	Image string `json:"image_url"`
	Alt   string `json:"alt_text"`
	Title Text   `json:"title"`
}

Image Slack's model

func NewImage added in v0.0.15

func NewImage(image, alt, title string) Image

NewImage creates Image

type InteractHandler

type InteractHandler func(context.Context, InteractivePayload) Response

InteractHandler for handling when user interact with a button

type InteractiveAction

type InteractiveAction struct {
	Type     string `json:"type"`
	BlockID  string `json:"block_id,omitempty"`
	ActionID string `json:"action_id,omitempty"`
	Value    string `json:"value,omitempty"`
}

InteractiveAction response from slack

type InteractivePayload

type InteractivePayload struct {
	User struct {
		ID string `json:"id"`
	} `json:"user"`
	Container struct {
		ChannelID string `json:"channel_id"`
	} `json:"container"`
	Type        string              `json:"type"`
	ResponseURL string              `json:"response_url"`
	Actions     []InteractiveAction `json:"actions"`
}

InteractivePayload response from slack

type Response

type Response struct {
	ResponseType    string  `json:"response_type,omitempty"`
	Text            string  `json:"text,omitempty"`
	Blocks          []Block `json:"blocks,omitempty"`
	ReplaceOriginal bool    `json:"replace_original,omitempty"`
	DeleteOriginal  bool    `json:"delete_original,omitempty"`
}

Response response content

func NewEphemeralMessage

func NewEphemeralMessage(message string) Response

NewEphemeralMessage creates ephemeral text response

func NewError

func NewError(err error) Response

NewError creates ephemeral error response

func NewResponse added in v0.0.5

func NewResponse(message string) Response

NewResponse creates text response

func (Response) AddBlock added in v0.0.6

func (r Response) AddBlock(block Block) Response

AddBlock add given block to response

func (Response) Ephemeral added in v0.0.6

func (r Response) Ephemeral() Response

Ephemeral set type to ephemeral

func (Response) WithDeleteOriginal added in v0.0.6

func (r Response) WithDeleteOriginal() Response

WithDeleteOriginal set delete original to true

func (Response) WithReplaceOriginal added in v0.0.6

func (r Response) WithReplaceOriginal() Response

WithReplaceOriginal set replace original to true

type Section

type Section struct {
	Accessory *Accessory `json:"accessory,omitempty"`
	Text      Text       `json:"text"`
	Type      string     `json:"type"`
	Fields    []Text     `json:"fields,omitempty"`
}

Section response for slack

func NewSection

func NewSection(text Text) Section

NewSection creates Section

func (Section) AddField added in v0.0.5

func (s Section) AddField(field Text) Section

AddField add given field to section

func (Section) IsZero added in v0.0.5

func (s Section) IsZero() bool

IsZero check if instance is populated

func (Section) WithAccessory added in v0.0.5

func (s Section) WithAccessory(accessory *Accessory) Section

WithAccessory set accessory for section

type Service added in v0.3.2

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(config *Config, command CommandHandler, interact InteractHandler, tracerProvider trace.TracerProvider) Service

func (Service) Handler added in v0.3.2

func (s Service) Handler() http.Handler

type SlashPayload

type SlashPayload struct {
	ChannelID   string `json:"channel_id"`
	Command     string `json:"command"`
	ResponseURL string `json:"response_url"`
	Text        string `json:"text"`
	Token       string `json:"token"`
	UserID      string `json:"user_id"`
}

SlashPayload receives by a slash command

type Text

type Text struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

Text Slack's model

func NewPlainText

func NewPlainText(text string) Text

NewPlainText creates PlainText

func NewText

func NewText(text string) Text

NewText creates Text

Jump to

Keyboard shortcuts

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