forked from lug/matterbridge
Update nlopes/slack vendor
This commit is contained in:
51
vendor/github.com/nlopes/slack/messages.go
generated
vendored
51
vendor/github.com/nlopes/slack/messages.go
generated
vendored
@@ -2,12 +2,13 @@ package slack
|
||||
|
||||
// OutgoingMessage is used for the realtime API, and seems incomplete.
|
||||
type OutgoingMessage struct {
|
||||
ID int `json:"id"`
|
||||
ID int `json:"id"`
|
||||
// channel ID
|
||||
Channel string `json:"channel,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
ThreadTimestamp string `json:"thread_ts,omitempty"`
|
||||
ThreadBroadcast bool `json:"reply_broadcast,omitempty"`
|
||||
}
|
||||
|
||||
// Message is an auxiliary type to allow us to have a message containing sub messages
|
||||
@@ -26,9 +27,12 @@ type Msg struct {
|
||||
Timestamp string `json:"ts,omitempty"`
|
||||
ThreadTimestamp string `json:"thread_ts,omitempty"`
|
||||
IsStarred bool `json:"is_starred,omitempty"`
|
||||
PinnedTo []string `json:"pinned_to, omitempty"`
|
||||
PinnedTo []string `json:"pinned_to,omitempty"`
|
||||
Attachments []Attachment `json:"attachments,omitempty"`
|
||||
Edited *Edited `json:"edited,omitempty"`
|
||||
LastRead string `json:"last_read,omitempty"`
|
||||
Subscribed bool `json:"subscribed,omitempty"`
|
||||
UnreadCount int `json:"unread_count,omitempty"`
|
||||
|
||||
// Message Subtypes
|
||||
SubType string `json:"subtype,omitempty"`
|
||||
@@ -65,7 +69,7 @@ type Msg struct {
|
||||
ParentUserId string `json:"parent_user_id,omitempty"`
|
||||
|
||||
// file_share, file_comment, file_mention
|
||||
File *File `json:"file,omitempty"`
|
||||
Files []File `json:"files,omitempty"`
|
||||
|
||||
// file_share
|
||||
Upload bool `json:"upload,omitempty"`
|
||||
@@ -82,6 +86,11 @@ type Msg struct {
|
||||
|
||||
// reactions
|
||||
Reactions []ItemReaction `json:"reactions,omitempty"`
|
||||
|
||||
// slash commands and interactive messages
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
ReplaceOriginal bool `json:"replace_original"`
|
||||
DeleteOriginal bool `json:"delete_original"`
|
||||
}
|
||||
|
||||
// Icon is used for bot messages
|
||||
@@ -109,27 +118,33 @@ type Event struct {
|
||||
|
||||
// Ping contains information about a Ping Event
|
||||
type Ping struct {
|
||||
ID int `json:"id"`
|
||||
Type string `json:"type"`
|
||||
ID int `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
// Pong contains information about a Pong Event
|
||||
type Pong struct {
|
||||
Type string `json:"type"`
|
||||
ReplyTo int `json:"reply_to"`
|
||||
Type string `json:"type"`
|
||||
ReplyTo int `json:"reply_to"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
// NewOutgoingMessage prepares an OutgoingMessage that the user can
|
||||
// use to send a message. Use this function to properly set the
|
||||
// messageID.
|
||||
func (rtm *RTM) NewOutgoingMessage(text string, channelID string) *OutgoingMessage {
|
||||
func (rtm *RTM) NewOutgoingMessage(text string, channelID string, options ...RTMsgOption) *OutgoingMessage {
|
||||
id := rtm.idGen.Next()
|
||||
return &OutgoingMessage{
|
||||
msg := OutgoingMessage{
|
||||
ID: id,
|
||||
Type: "message",
|
||||
Channel: channelID,
|
||||
Text: text,
|
||||
}
|
||||
for _, option := range options {
|
||||
option(&msg)
|
||||
}
|
||||
return &msg
|
||||
}
|
||||
|
||||
// NewTypingMessage prepares an OutgoingMessage that the user can
|
||||
@@ -143,3 +158,21 @@ func (rtm *RTM) NewTypingMessage(channelID string) *OutgoingMessage {
|
||||
Channel: channelID,
|
||||
}
|
||||
}
|
||||
|
||||
// RTMsgOption allows configuration of various options available for sending an RTM message
|
||||
type RTMsgOption func(*OutgoingMessage)
|
||||
|
||||
// RTMsgOptionTS sets thead timestamp of an outgoing message in order to respond to a thread
|
||||
func RTMsgOptionTS(threadTimestamp string) RTMsgOption {
|
||||
return func(msg *OutgoingMessage) {
|
||||
msg.ThreadTimestamp = threadTimestamp
|
||||
}
|
||||
}
|
||||
|
||||
// RTMsgOptionBroadcast sets broadcast reply to channel to "true"
|
||||
func RTMsgOptionBroadcast() RTMsgOption {
|
||||
return func(msg *OutgoingMessage) {
|
||||
msg.ThreadBroadcast = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user