slack_webhook

package
v0.0.0-...-e679d17 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const SlackAPIEndpoint = "https://slack.com/api"

Variables

This section is empty.

Functions

func FindFileType

func FindFileType(FileName string) string

Types

type Attachment

type Attachment struct {
	Color    string `json:"color,omitempty"`
	Fallback string `json:"fallback,omitempty"`

	CallbackID string `json:"callback_id,omitempty"`
	ID         int    `json:"id,omitempty"`

	AuthorID      string `json:"author_id,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"`
	Text      string `json:"text,omitempty"`

	ImageURL string `json:"image_url,omitempty"`
	ThumbURL string `json:"thumb_url,omitempty"`

	ServiceName string `json:"service_name,omitempty"`
	ServiceIcon string `json:"service_icon,omitempty"`
	FromURL     string `json:"from_url,omitempty"`
	OriginalURL string `json:"original_url,omitempty"`

	Fields     []slack.AttachmentField  `json:"fields,omitempty"`
	Actions    []slack.AttachmentAction `json:"actions,omitempty"`
	MarkdownIn []string                 `json:"mrkdwn_in,omitempty"`

	Footer     string `json:"footer,omitempty"`
	FooterIcon string `json:"footer_icon,omitempty"`

	Ts json.Number `json:"ts,omitempty"`
}

Attachment contains all the information for an attachment

type BasicIdentity

type BasicIdentity struct {
	WorkspaceURI string `json:"url"`
	Team         string `json:"team"`
	User         string `json:"user"`
	UserID       string `json:"user_id"`
	TeamID       string `json:"team_id"`
}

type BlockBase

type BlockBase struct {
	Type       string         `json:"type"`
	Text       BlockElement   `json:"text,omitempty"`
	Elements   []BlockElement `json:"elements,omitempty"`
	ImageURL   string         `json:"image_url"`
	AltText    string         `json:"alt_text"`
	Title      BlockTitle     `json:"title"`
	ExternalID string         `json:"external_id"`
	Source     string         `json:"source"`
}

func ContextBlock

func ContextBlock(elements ...BlockElement) BlockBase

func DividerBlock

func DividerBlock() BlockBase

func FileBlock

func FileBlock(ExternalID string) BlockBase

func ImageBlock

func ImageBlock(imageURL, altText string) BlockBase

func SectionBlock

func SectionBlock() BlockBase

func (BlockBase) MarshalJSON

func (b BlockBase) MarshalJSON() ([]byte, error)

type BlockElement

type BlockElement struct {
	Type     string `json:"type,omitempty"`
	ImageURL string `json:"image_url,omitempty"`
	AltText  string `json:"alt_text,omitempty"`
	Text     string `json:"text,omitempty"`
	Verbatim bool   `json:"verbatim,omitempty"`
}

func ImageElement

func ImageElement(imageURL, altText string) BlockElement

func MrkdwnElement

func MrkdwnElement(text string, verbatim bool) BlockElement

type BlockTitle

type BlockTitle struct {
	Type  string `json:"type,omitempty"`
	Text  string `json:"text,omitempty"`
	Emoji bool   `json:"emoji,omitempty"`
}

func ImageTitle

func ImageTitle(title string, emoji bool) BlockTitle

type File

type File struct {
	FileName        string
	Reader          io.Reader
	FileType        string
	InitialComment  string
	ThreadTimestamp string
}

type FilesRemoteAddParameters

type FilesRemoteAddParameters struct {
	Title                 string
	FileType              string
	ExternalID            string
	ExternalURL           string
	IndexableFileContents io.Reader
	PreviewImage          io.Reader
	File                  io.Reader
}

type GetConversationHistoryParameters

type GetConversationHistoryParameters struct {
	ChannelID string `json:"channel"`
	Cursor    string `json:"cursor,omitempty"`
	Inclusive bool   `json:"inclusive,omitempty"`
	Latest    string `json:"latest,omitempty"`
	Limit     int    `json:"limit,omitempty"`
	Oldest    string `json:"oldest,omitempty"`
}

type Handler

type Handler struct {
	Identity BasicIdentity
	// contains filtered or unexported fields
}

func New

func New(token string) *Handler

func (Handler) AuthTest

func (s Handler) AuthTest() (*BasicIdentity, error)

func (*Handler) ChatUnfURL

func (s *Handler) ChatUnfURL(parameters UnfURLsParameters) error

func (*Handler) FilesRemoteAdd

func (s *Handler) FilesRemoteAdd(file FilesRemoteAddParameters) (*slack.File, error)

func (*Handler) FilesRemoteInfo

func (s *Handler) FilesRemoteInfo(externalID, fileID string) (*slack.File, error)

func (*Handler) FilesRemoteRemove

func (s *Handler) FilesRemoteRemove(externalID, fileID string) error

func (*Handler) FilesUpload

func (s *Handler) FilesUpload(file File, channels ...string) (*slack.File, error)

func (*Handler) GetMessage

func (s *Handler) GetMessage(channelID, timestamp string) (*Message, error)

func (*Handler) GetMessages

func (s *Handler) GetMessages(channelID, timestamp string, limit int) ([]Message, error)

func (Handler) GetUserIdentity

func (s Handler) GetUserIdentity() (identity *UserIdentity, err error)

func (Handler) GetUserProfile

func (s Handler) GetUserProfile(user string, includeLabels bool) (profile *UserProfile, err error)

func (Handler) Remove

func (s Handler) Remove(channel, ts string) (string, error)

func (*Handler) Send

func (s *Handler) Send(message Message) (string, error)

Send json形式で指定したURLにPOSTする。

func (Handler) SetUserProfile

func (s Handler) SetUserProfile(user string, name string, value string) (profile *UserProfile, err error)

func (*Handler) Update

func (s *Handler) Update(message Message) (string, error)

type Message

type Message struct {
	TS      string `json:"ts,omitempty"`
	Channel string `json:"channel"`

	Type string `json:"type,omitempty"`

	Text        string       `json:"text,omitempty"`
	Blocks      []BlockBase  `json:"blocks,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`

	LinkNames bool   `json:"link_names,omitempty"`
	Username  string `json:"username,omitempty"`
	User      string `json:"user,omitempty"`
	AsUser    bool   `json:"as_user,omitempty"`

	Parse           string `json:"parse,omitempty"`
	ThreadTimestamp string `json:"thread_ts,omitempty"`
	ReplyBroadcast  bool   `json:"reply_broadcast,omitempty"`

	UnfurlLinks bool `json:"unfurl_links"`
	UnfurlMedia bool `json:"unfurl_media"`

	IconURL   string `json:"icon_url,omitempty"`
	IconEmoji string `json:"icon_emoji,omitempty"`
}

HookMessage SlackにIncommingWebhook経由のMessage送信形式

type ProfileLabel

type ProfileLabel struct {
	Value   string `json:"value"`
	AltText string `json:"alt"`
	Label   string `json:"label"`
}

type UnfURL

type UnfURL struct {
	HideColor bool        `json:"hide_color"`
	Blocks    []BlockBase `json:"blocks"`
}

type UnfURLs

type UnfURLs map[string]UnfURL

type UnfURLsParameters

type UnfURLsParameters struct {
	Channel          string      `json:"channel"`
	TimeStamp        string      `json:"ts"`
	UnfURLs          UnfURLs     `json:"unfurls"`
	Source           string      `json:"source,omitempty"`
	UnfUrlID         string      `json:"unfurl_id,omitempty"`
	UserAuthBlocks   []BlockBase `json:"user_auth_blocks,omitempty"`
	UserAuthRequired bool        `json:"user_auth_required,omitempty"`
}

type UserIdentity

type UserIdentity struct {
	User string `json:"user"`
	ID   string `json:"id"`
}

type UserProfile

type UserProfile struct {
	FirstName             string `json:"first_name"`
	LastName              string `json:"last_name"`
	RealName              string `json:"real_name"`
	RealNameNormalized    string `json:"real_name_normalized"`
	DisplayName           string `json:"display_name"`
	DisplayNameNormalized string `json:"display_name_normalized"`
	Email                 string `json:"email,omitempty"`
	Skype                 string `json:"skype,omitempty"`
	Phone                 string `json:"phone,omitempty"`
	Image24               string `json:"image_24"`
	Image32               string `json:"image_32"`
	Image48               string `json:"image_48"`
	Image72               string `json:"image_72"`
	Image192              string `json:"image_192"`
	Image512              string `json:"image_512"`
	ImageOriginal         string `json:"image_original"`
	StatusText            string `json:"status_text,omitempty"`
	StatusEmoji           string `json:"status_emoji,omitempty"`
	StatusExpiration      int    `json:"status_expiration"`
	Team                  string `json:"team"`

	Fields map[string]ProfileLabel `json:"fields"`
}

UserProfile contains all the information details of a given user

func (UserProfile) GetUserImageURI

func (u UserProfile) GetUserImageURI() string

Jump to

Keyboard shortcuts

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