slack

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 20 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptySection = Section{}

EmptySection for not found

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

type App

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

App of package

func New

func New(config Config, command CommandHandler, interact InteractHandler) App

New creates new App from Config

func (App) Handler

func (a App) Handler() http.Handler

Handler for net/http

type Block

type Block any

Block response for slack

func NewActions

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

NewActions creates Actions

func NewSection

func NewSection(text Text, accessory *Accessory) Block

NewSection creates Section

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 {
	// contains filtered or unexported fields
}

Config of package

func Flags

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

Flags adds flags for configuring package

type Element

type Element any

Element response for slack

func NewButtonElement

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

NewButtonElement creates ButtonElement

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

type Section

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

Section response for slack

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