summaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-08-26 23:47:50 +0200
committerGitHub <noreply@github.com>2019-08-26 23:47:50 +0200
commit1552dcb143edbc82c1ef49169f20fd1b5441b688 (patch)
treec8e553821626d391582c7a7dfc5553d40d7fef0d /vendor/github.com
parentd525f1c9e4ac39b74575052b61c4de72de794b4e (diff)
downloadmatterbridge-msglm-1552dcb143edbc82c1ef49169f20fd1b5441b688.tar.gz
matterbridge-msglm-1552dcb143edbc82c1ef49169f20fd1b5441b688.tar.bz2
matterbridge-msglm-1552dcb143edbc82c1ef49169f20fd1b5441b688.zip
Replace bwmarrin/discordgo with matterbridge/discordgo (#878)
Needed for #872
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/bwmarrin/discordgo/restapi.go71
-rw-r--r--vendor/github.com/bwmarrin/discordgo/structs.go2
2 files changed, 69 insertions, 4 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/restapi.go b/vendor/github.com/bwmarrin/discordgo/restapi.go
index 84a2a31e..ebeea876 100644
--- a/vendor/github.com/bwmarrin/discordgo/restapi.go
+++ b/vendor/github.com/bwmarrin/discordgo/restapi.go
@@ -675,7 +675,7 @@ func (s *Session) GuildLeave(guildID string) (err error) {
return
}
-// GuildBans returns an array of User structures for all bans of a
+// GuildBans returns an array of GuildBan structures for all bans of a
// given guild.
// guildID : The ID of a Guild.
func (s *Session) GuildBans(guildID string) (st []*GuildBan, err error) {
@@ -2067,15 +2067,80 @@ func (s *Session) WebhookDeleteWithToken(webhookID, token string) (st *Webhook,
// WebhookExecute executes a webhook.
// webhookID: The ID of a webhook.
// token : The auth token for the webhook
-func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *WebhookParams) (err error) {
+// wait : Wait for server to confirm the message arrival
+//
+// If `wait` is `false`, the returned *Message is always empty, because server
+// does not provide the response data.
+func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *WebhookParams) (st *Message, err error) {
uri := EndpointWebhookToken(webhookID, token)
if wait {
uri += "?wait=true"
}
- _, err = s.RequestWithBucketID("POST", uri, data, EndpointWebhookToken("", ""))
+ var response []byte
+ if data.File != nil {
+ body := &bytes.Buffer{}
+ bodywriter := multipart.NewWriter(body)
+ var payload []byte
+ payload, err = json.Marshal(data)
+ if err != nil {
+ return
+ }
+
+ var p io.Writer
+
+ h := make(textproto.MIMEHeader)
+ h.Set("Content-Disposition", `form-data; name="payload_json"`)
+ h.Set("Content-Type", "application/json")
+
+ p, err = bodywriter.CreatePart(h)
+ if err != nil {
+ return
+ }
+
+ if _, err = p.Write(payload); err != nil {
+ return
+ }
+
+ {
+ file := data.File
+ h := make(textproto.MIMEHeader)
+ h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, quoteEscaper.Replace(file.Name)))
+ contentType := file.ContentType
+ if contentType == "" {
+ contentType = "application/octet-stream"
+ }
+ h.Set("Content-Type", contentType)
+
+ p, err = bodywriter.CreatePart(h)
+ if err != nil {
+ return
+ }
+
+ if _, err = io.Copy(p, file.Reader); err != nil {
+ return
+ }
+ }
+
+ err = bodywriter.Close()
+ if err != nil {
+ return
+ }
+
+ response, err = s.request("POST", uri, bodywriter.FormDataContentType(), body.Bytes(), EndpointWebhookToken("", ""), 0)
+ } else {
+ response, err = s.RequestWithBucketID("POST", uri, data, EndpointWebhookToken("", ""))
+ }
+ if err != nil {
+ return
+ }
+ if !wait {
+ return
+ }
+
+ err = unmarshal(response, &st)
return
}
diff --git a/vendor/github.com/bwmarrin/discordgo/structs.go b/vendor/github.com/bwmarrin/discordgo/structs.go
index 4465ec52..29468a71 100644
--- a/vendor/github.com/bwmarrin/discordgo/structs.go
+++ b/vendor/github.com/bwmarrin/discordgo/structs.go
@@ -832,7 +832,7 @@ type WebhookParams struct {
Username string `json:"username,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
TTS bool `json:"tts,omitempty"`
- File string `json:"file,omitempty"`
+ File *File `json:"-"`
Embeds []*MessageEmbed `json:"embeds,omitempty"`
}