diff --git a/gateway/gateway.go b/gateway/gateway.go
index d7f0aa32..830a734e 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -10,6 +10,7 @@ import (
"context"
"html"
strip "github.com/grokify/html-strip-tags-go"
+ "github.com/urakozz/go-emoji"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/api"
@@ -291,16 +292,30 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
text := msg.Text
+ // @usernames
results := regexp.MustCompile(`(@[a-zA-Z0-9-]+)`).FindAllStringSubmatch(text, -1)
for _, r := range results {
text = strings.Replace(text, r[1], ""+r[1]+"", -1)
}
+ // #channels
results = regexp.MustCompile(`(#[a-zA-Z0-9-]+)`).FindAllStringSubmatch(text, -1)
for _, r := range results {
text = strings.Replace(text, r[1], ""+r[1]+"", -1)
}
+ // :emoji:
+ results = regexp.MustCompile(`(:[a-z0-9-_]+?:)`).FindAllStringSubmatch(text, -1)
+ for _, r := range results {
+ text = strings.Replace(text, r[1], ""+r[1]+"", -1)
+ }
+
+ // :emoji: codepoints, ie. 💎
+ results = emoji.NewEmojiParser().FindAllStringSubmatch(text, -1)
+ for _, r := range results {
+ text = strings.Replace(text, r[0], " "+r[0]+" ", -1)
+ }
+
resp, _ := client.Translate(ctx, []string{text}, lang, &translate.Options{
Format: "html",
})