summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--vendor/github.com/bwmarrin/discordgo/restapi.go71
-rw-r--r--vendor/github.com/bwmarrin/discordgo/structs.go2
-rw-r--r--vendor/modules.txt2
5 files changed, 74 insertions, 7 deletions
diff --git a/go.mod b/go.mod
index d44b4087..c380835c 100644
--- a/go.mod
+++ b/go.mod
@@ -68,3 +68,5 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)
+
+replace github.com/bwmarrin/discordgo v0.19.0 => github.com/matterbridge/discordgo v0.0.0-20190818085008-57c6e0fc2f40
diff --git a/go.sum b/go.sum
index 1edfcbe0..7668b495 100644
--- a/go.sum
+++ b/go.sum
@@ -24,8 +24,6 @@ github.com/alexcesaro/log v0.0.0-20150915221235-61e686294e58/go.mod h1:YNfsMyWSs
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
-github.com/bwmarrin/discordgo v0.19.0 h1:kMED/DB0NR1QhRcalb85w0Cu3Ep2OrGAqZH1R5awQiY=
-github.com/bwmarrin/discordgo v0.19.0/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
@@ -122,6 +120,8 @@ github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDe
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20190210153444-cc9d05784d5d h1:F+Sr+C0ojSlYQ37BLylQtSFmyQULe3jbAygcyXQ9mVs=
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20190210153444-cc9d05784d5d/go.mod h1:c6MxwqHD+0HvtAJjsHMIdPCiAwGiQwPRPTp69ACMg8A=
+github.com/matterbridge/discordgo v0.0.0-20190818085008-57c6e0fc2f40 h1:OJmjOa1ry5IZzFowLhAZ8b3bFPWFFNUbqGxs9pNqgEU=
+github.com/matterbridge/discordgo v0.0.0-20190818085008-57c6e0fc2f40/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q=
github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91 h1:KzDEcy8eDbTx881giW8a6llsAck3e2bJvMyKvh1IK+k=
github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q=
github.com/matterbridge/gomatrix v0.0.0-20190102230110-6f9631ca6dea h1:kaADGqpK4gGO2BpzEyJrBxq2Jc57Rsar4i2EUxcACUc=
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"`
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 1416f316..80871d8c 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -23,7 +23,7 @@ github.com/Rhymen/go-whatsapp/crypto/cbc
github.com/Rhymen/go-whatsapp/crypto/curve25519
github.com/Rhymen/go-whatsapp/crypto/hkdf
github.com/Rhymen/go-whatsapp/binary/token
-# github.com/bwmarrin/discordgo v0.19.0
+# github.com/bwmarrin/discordgo v0.19.0 => github.com/matterbridge/discordgo v0.0.0-20190818085008-57c6e0fc2f40
github.com/bwmarrin/discordgo
# github.com/d5/tengo v1.24.1
github.com/d5/tengo/script