summaryrefslogtreecommitdiffstats
path: root/bridge/discord
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-04-15 19:00:15 +0200
committerWim <wim@42.be>2017-04-15 19:00:15 +0200
commitd1dd6c34405c210f8bc44c78c425113e60ea221e (patch)
treea44687d4876a88554c8da9dc0096ec4cab245f38 /bridge/discord
parent02612c006112f9bfd14b9a0d9c5376dca2a7c4e1 (diff)
downloadmatterbridge-msglm-d1dd6c34405c210f8bc44c78c425113e60ea221e.tar.gz
matterbridge-msglm-d1dd6c34405c210f8bc44c78c425113e60ea221e.tar.bz2
matterbridge-msglm-d1dd6c34405c210f8bc44c78c425113e60ea221e.zip
Add support for edited messages (discord)
Diffstat (limited to 'bridge/discord')
-rw-r--r--bridge/discord/discord.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index f1ab4a76..2a91adf9 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -52,6 +52,7 @@ func (b *bdiscord) Connect() error {
flog.Info("Connection succeeded")
b.c.AddHandler(b.messageCreate)
b.c.AddHandler(b.memberUpdate)
+ b.c.AddHandler(b.messageUpdate)
err = b.c.Open()
if err != nil {
flog.Debugf("%#v", err)
@@ -104,6 +105,18 @@ func (b *bdiscord) Send(msg config.Message) error {
return nil
}
+func (b *bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) {
+ if b.Config.EditDisable {
+ return
+ }
+ // only when message is actually edited
+ if m.Message.EditedTimestamp != "" {
+ flog.Debugf("Sending edit message")
+ m.Content = m.Content + b.Config.EditSuffix
+ b.messageCreate(s, (*discordgo.MessageCreate)(m))
+ }
+}
+
func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
// not relay our own messages
if m.Author.Username == b.Nick {