summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-04-15 16:23:34 +0200
committerWim <wim@42.be>2017-04-15 16:23:34 +0200
commit035c2b906a6f0258840b4a15abecae7364756497 (patch)
tree8445705c6878351952c71c3085d8935a3b4feec3 /bridge
parent6ea8be5749745a8b76a77a960cca6792b1743efe (diff)
downloadmatterbridge-msglm-035c2b906a6f0258840b4a15abecae7364756497.tar.gz
matterbridge-msglm-035c2b906a6f0258840b4a15abecae7364756497.tar.bz2
matterbridge-msglm-035c2b906a6f0258840b4a15abecae7364756497.zip
Strip custom emoji metadata (discord). Closes #148
Diffstat (limited to 'bridge')
-rw-r--r--bridge/discord/discord.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index 1cf81337..f1ab4a76 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -4,6 +4,7 @@ import (
"github.com/42wim/matterbridge/bridge/config"
log "github.com/Sirupsen/logrus"
"github.com/bwmarrin/discordgo"
+ "regexp"
"strings"
"sync"
)
@@ -125,6 +126,7 @@ func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
if len(m.MentionRoles) > 0 {
m.Message.Content = b.replaceRoleMentions(m.Message.Content)
}
+ m.Message.Content = b.stripCustomoji(m.Message.Content)
b.Remote <- config.Message{Username: username, Text: m.ContentWithMentionsReplaced(), Channel: channelName,
Account: b.Account, Avatar: "https://cdn.discordapp.com/avatars/" + m.Author.ID + "/" + m.Author.Avatar + ".jpg"}
}
@@ -195,3 +197,9 @@ func (b *bdiscord) replaceRoleMentions(text string) string {
}
return text
}
+
+func (b *bdiscord) stripCustomoji(text string) string {
+ // <:doge:302803592035958784>
+ re := regexp.MustCompile("<(:.*?:)[0-9]+>")
+ return re.ReplaceAllString(text, `$1`)
+}