summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/chat.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-05-24 00:06:21 +0200
committerGitHub <noreply@github.com>2020-05-24 00:06:21 +0200
commit393f9e998b1b40aa59d3fb8794c3a73da38c3fb7 (patch)
tree2bc9b6e6abdbdc6d811b155997597bdae62bc7db /vendor/github.com/slack-go/slack/chat.go
parentba0bfe70a8f07164e1341f4b094841acdad5c3a2 (diff)
downloadmatterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.tar.gz
matterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.tar.bz2
matterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.zip
Update dependencies / vendor (#1146)
Diffstat (limited to 'vendor/github.com/slack-go/slack/chat.go')
-rw-r--r--vendor/github.com/slack-go/slack/chat.go74
1 files changed, 51 insertions, 23 deletions
diff --git a/vendor/github.com/slack-go/slack/chat.go b/vendor/github.com/slack-go/slack/chat.go
index 1281b15a..c5b524c1 100644
--- a/vendor/github.com/slack-go/slack/chat.go
+++ b/vendor/github.com/slack-go/slack/chat.go
@@ -261,14 +261,16 @@ const (
)
type sendConfig struct {
- apiurl string
- options []MsgOption
- mode sendMode
- endpoint string
- values url.Values
- attachments []Attachment
- blocks Blocks
- responseType string
+ apiurl string
+ options []MsgOption
+ mode sendMode
+ endpoint string
+ values url.Values
+ attachments []Attachment
+ blocks Blocks
+ responseType string
+ replaceOriginal bool
+ deleteOriginal bool
}
func (t sendConfig) BuildRequest(token, channelID string) (req *http.Request, _ func(*chatResponseFull) responseParser, err error) {
@@ -279,11 +281,13 @@ func (t sendConfig) BuildRequest(token, channelID string) (req *http.Request, _
switch t.mode {
case chatResponse:
return responseURLSender{
- endpoint: t.endpoint,
- values: t.values,
- attachments: t.attachments,
- blocks: t.blocks,
- responseType: t.responseType,
+ endpoint: t.endpoint,
+ values: t.values,
+ attachments: t.attachments,
+ blocks: t.blocks,
+ responseType: t.responseType,
+ replaceOriginal: t.replaceOriginal,
+ deleteOriginal: t.deleteOriginal,
}.BuildRequest()
default:
return formSender{endpoint: t.endpoint, values: t.values}.BuildRequest()
@@ -303,20 +307,24 @@ func (t formSender) BuildRequest() (*http.Request, func(*chatResponseFull) respo
}
type responseURLSender struct {
- endpoint string
- values url.Values
- attachments []Attachment
- blocks Blocks
- responseType string
+ endpoint string
+ values url.Values
+ attachments []Attachment
+ blocks Blocks
+ responseType string
+ replaceOriginal bool
+ deleteOriginal bool
}
func (t responseURLSender) BuildRequest() (*http.Request, func(*chatResponseFull) responseParser, error) {
req, err := jsonReq(t.endpoint, Msg{
- Text: t.values.Get("text"),
- Timestamp: t.values.Get("ts"),
- Attachments: t.attachments,
- Blocks: t.blocks,
- ResponseType: t.responseType,
+ Text: t.values.Get("text"),
+ Timestamp: t.values.Get("ts"),
+ Attachments: t.attachments,
+ Blocks: t.blocks,
+ ResponseType: t.responseType,
+ ReplaceOriginal: t.replaceOriginal,
+ DeleteOriginal: t.deleteOriginal,
})
return req, func(resp *chatResponseFull) responseParser {
return newContentTypeParser(resp)
@@ -405,6 +413,26 @@ func MsgOptionResponseURL(url string, responseType string) MsgOption {
}
}
+// MsgOptionReplaceOriginal replaces original message with response url
+func MsgOptionReplaceOriginal(responseURL string) MsgOption {
+ return func(config *sendConfig) error {
+ config.mode = chatResponse
+ config.endpoint = responseURL
+ config.replaceOriginal = true
+ return nil
+ }
+}
+
+// MsgOptionDeleteOriginal deletes original message with response url
+func MsgOptionDeleteOriginal(responseURL string) MsgOption {
+ return func(config *sendConfig) error {
+ config.mode = chatResponse
+ config.endpoint = responseURL
+ config.deleteOriginal = true
+ return nil
+ }
+}
+
// MsgOptionAsUser whether or not to send the message as the user.
func MsgOptionAsUser(b bool) MsgOption {
return func(config *sendConfig) error {