slashcommand

package
v0.0.0-...-004c645 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The response should be visible to everyone in the channel
	ResponseInChannel = "in_channel"
	// The response should only be visible to the user who typed the command
	ResponseEphemeral = "ephemeral"
)

Copied from https://github.com/signalsciences/slashcmd/blob/master/response.go

View Source
const (
	SlackRequestTimestampHeader = "X-Slack-Request-Timestamp"
	SlackSignatureHeader        = "X-Slack-Signature"
	SlackWebhookAllowedDelay    = time.Minute * 10
)

Variables

This section is empty.

Functions

func RespondWith

func RespondWith(w http.ResponseWriter, resp Response)

func Timestamp

func Timestamp(t time.Time) int64

Timestamp formats a time.Time into a unix epoch value suitable for Attachment.Timestamp

Timestamp: debatable if this should be included

func VerifyRequestSignature

func VerifyRequestSignature(secret string) func(next http.Handler) http.HandlerFunc

Types

type Attachment

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

Attachment is Slack attachment for slash Response

type DelayedSlashResponse

type DelayedSlashResponse struct {
	// A mesage to send the user while we're preparing a response to
	PendingResponse messaging.CommonPayload

	// Should the command be visible to all other users in the channel?
	// Doing this changes how we respond to the slash command webhook
	ShowSlashCommandInChannel bool

	Handler func(context.Context, SlashCommandRequest, MessageResponder)
}

func (DelayedSlashResponse) Run

type Field

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

Field is a field attachment

type MessageResponder

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

func (MessageResponder) EphemeralResponse

func (m MessageResponder) EphemeralResponse(resp messaging.CommonPayload)

func (MessageResponder) PublicResponse

func (m MessageResponder) PublicResponse(resp messaging.CommonPayload)

type Response

type Response struct {
	ResponseType string       `json:"response_type,omitempty"`
	Text         string       `json:"text"`
	Attachments  []Attachment `json:"attachments,omitempty"`
}

Response is the response to a slash command

type SlashCommandRequest

type SlashCommandRequest struct {
	// The command that was typed in to trigger this request. This value
	// can be useful if you want to use a single Request URL to service
	// multiple Slash Commands, as it lets you tell them apart.
	Command string

	// These IDs provide context about where the user was in Slack when
	// they triggered your app's command (eg. which workspace, Enterprise
	// Grid, or channel). You may need these IDs for your command response.
	TeamID         string
	TeamDomain     string
	EnterpriseID   string
	EnterpriseName string
	ChannelID      string
	ChannelName    string

	// The slack user that invoked this slash command
	UserID   string
	UserName string

	// This is the part of the Slash Command after the command itself, and
	// it can contain absolutely anything that the user might decide to
	// type. It is common to use this text parameter to provide extra
	// context for the command.
	Text string

	// A URL that you can use to respond to the command.
	ResponseURL string

	// If you need to respond to the command by opening a dialog, you'll
	// need this trigger ID to get it to work. You can use this ID with
	// dialog.open up to 3000ms after this data payload is sent.
	TriggerID string
}

SlashCommandRequest is a payload that slack sends your app when a user invokes a slash command

func ParseSlashCommandRequest

func ParseSlashCommandRequest(r *http.Request) (*SlashCommandRequest, error)

type SlashCommandResponder

type SlashCommandResponder interface {
	PublicResponse(Response)
}

Jump to

Keyboard shortcuts

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