slack

package
v0.75.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

Slack service

Usage

endly -r=test

test.yaml

init:
  channel: '#serverless'
defaults:
  credentials: slack
pipeline:
  listen:
    action: slack:listen
    description: listen for incoming slack messages
    channel: $channel
  post:
    action: slack:post
    channel: $channel
    messages:
      - text: test is 1st test message
      - text: test is 2nd test message
  validate:
    action: slack:pull
    expect:
      - text: test is 1st test message
      - text: test is 2nd test message

Endly service action integration

Run the following command for slack service operation details:

endly -s=slack 
endly -s=slack -a=post

Slack Service

Service Id Action Description Request Response
slack post post message to a slack channel PostRequest PostResponse
slack listen listen for slack events to place then on pending validation queue ListenRequest ListenResponse
slack pull pull/validate queued message PullRequest PullResponse

Credentials

Generate encrypted endly credentials

  • username: app/bot name
  • password: app token
endly -c=SECRET_NAME
ls -al ~/.secret/SECRET_NAME.json

where SECRET_NAME can be slack or any arbitrary credentials name

Documentation

Index

Constants

View Source
const PullDefaultTimeoutMs = 30000
View Source
const (
	//ServiceID represents a data store unit service id
	ServiceID = "slack"
)

Variables

This section is empty.

Functions

func New

func New() endly.Service

Types

type Asset

type Asset struct {
	Title         string
	Filename      string
	Type          string
	Content       string
	Data          interface{} //content data structure
	BinaryContent []byte
}

Asset represents a file asset

type ListenRequest

type ListenRequest struct {
	Credentials string
	Channels    []string
	// contains filtered or unexported fields
}

ListenRequest represents a listen request

func (*ListenRequest) Init

func (r *ListenRequest) Init() error

Init init a request

func (*ListenRequest) Validate

func (r *ListenRequest) Validate() error

Validate check if a request is valid

type ListenResponse

type ListenResponse struct{}

ListenResponse represents listen response

type Message

type Message struct {
	Channel  string
	Username string
	Text     string
	Asset    *Asset
}

Message represent a slack message

func NewMessageFromEvent

func NewMessageFromEvent(event *slack.MessageEvent, client *slack.Client) ([]*Message, error)

NewMessageFromEvent creates a new message form a message event

type Messages

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

Messages messages holder

func NewMessages

func NewMessages() *Messages

NewMessages creates a new messages

func (*Messages) Push

func (m *Messages) Push(message *Message)

Push append a message

func (*Messages) Shift

func (m *Messages) Shift() *Message

Shift removes a message

type PostRequest

type PostRequest struct {
	Credentials string
	Channel     string
	Messages    []*Message
}

PostRequest represents post request

func (*PostRequest) Init

func (r *PostRequest) Init() error

Init initializes request

func (*PostRequest) Validate

func (r *PostRequest) Validate() error

Validate check if a request is valid

type PostResponse

type PostResponse struct {
	Channel   string
	Timestamp string
}

PostResponse represnets a post response

type PullRequest

type PullRequest struct {
	Expect    []*Message
	TimeoutMs int
	Count     int
}

AssertRequest represents assert request

func (*PullRequest) Init

func (r *PullRequest) Init() error

Init initializes request

type PullResponse

type PullResponse struct {
	Messages []*Message
	Assert   *validator.AssertResponse
}

AssertResponse represents assert response

Jump to

Keyboard shortcuts

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