From 79bd55b79cc8921dcb1bf53dd6711511ff05a8ab Mon Sep 17 00:00:00 2001
From: c0ncord <59654954+c0ncord@users.noreply.github.com>
Date: Wed, 8 Jan 2020 14:35:08 +0000
Subject: [PATCH 1/5] move stripCustomoji logic to default Tengo script
Removing the image ID from the message (without any possibility of recovering it later) is a loss of valuable data that prevents users from giving support to custom emoji via Tengo scripts.
---
bridge/discord/helpers.go | 5 -----
1 file changed, 5 deletions(-)
diff --git a/bridge/discord/helpers.go b/bridge/discord/helpers.go
index 734de3cd..c094e47a 100644
--- a/bridge/discord/helpers.go
+++ b/bridge/discord/helpers.go
@@ -129,7 +129,6 @@ func (b *Bdiscord) getCategoryChannelName(name, parentID string) string {
var (
// See https://discordapp.com/developers/docs/reference#message-formatting.
channelMentionRE = regexp.MustCompile("<#[0-9]+>")
- emojiRE = regexp.MustCompile("<(:.*?:)[0-9]+>")
userMentionRE = regexp.MustCompile("@[^@\n]{1,32}")
)
@@ -176,10 +175,6 @@ func (b *Bdiscord) replaceUserMentions(text string) string {
return userMentionRE.ReplaceAllStringFunc(text, replaceUserMentionFunc)
}
-func (b *Bdiscord) stripCustomoji(text string) string {
- return emojiRE.ReplaceAllString(text, `$1`)
-}
-
func (b *Bdiscord) replaceAction(text string) (string, bool) {
if strings.HasPrefix(text, "_") && strings.HasSuffix(text, "_") {
return text[1 : len(text)-1], true
From 0ba6b565303ace8b4651793c06a41f8adcae2725 Mon Sep 17 00:00:00 2001
From: c0ncord <59654954+c0ncord@users.noreply.github.com>
Date: Wed, 8 Jan 2020 14:41:25 +0000
Subject: [PATCH 2/5] move stripCustomoji logic to default Tengo script
Removing the image ID from the message (without any possibility of recovering it later) is a loss of valuable data that prevents users from giving support to custom emoji via Tengo scripts.
---
bridge/discord/handlers.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go
index 4ffbf5ab..c86a9e8d 100644
--- a/bridge/discord/handlers.go
+++ b/bridge/discord/handlers.go
@@ -88,7 +88,6 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
if m.Content != "" {
b.Log.Debugf("== Receiving event %#v", m.Message)
- m.Message.Content = b.stripCustomoji(m.Message.Content)
m.Message.Content = b.replaceChannelMentions(m.Message.Content)
rmsg.Text, err = m.ContentWithMoreMentionsReplaced(b.c)
if err != nil {
From 9c85b061720b442e6ad36fe89af96b2b8d02e581 Mon Sep 17 00:00:00 2001
From: c0ncord <59654954+c0ncord@users.noreply.github.com>
Date: Wed, 8 Jan 2020 15:56:05 +0000
Subject: [PATCH 3/5] bugfix - do send colors to other irc bridges
"if we're not sending to an irc bridge we strip the IRC colors"
---
internal/tengo/outmessage.tengo | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/internal/tengo/outmessage.tengo b/internal/tengo/outmessage.tengo
index d218088a..2cbb8a22 100644
--- a/internal/tengo/outmessage.tengo
+++ b/internal/tengo/outmessage.tengo
@@ -12,7 +12,7 @@ text := import("text")
// start - strip irc colors
// if we're not sending to an irc bridge we strip the IRC colors
-if inProtocol == "irc" {
+if inProtocol == "irc" && outProtocol != "irc" {
re := text.re_compile(`\x03(?:\d{1,2}(?:,\d{1,2})?)?|[[:cntrl:]]`)
msgText=re.replace(msgText,"")
}
From a1231001a72ee5bd61fd7368137fb0a5b4d19ce7 Mon Sep 17 00:00:00 2001
From: c0ncord <59654954+c0ncord@users.noreply.github.com>
Date: Wed, 8 Jan 2020 16:20:54 +0000
Subject: [PATCH 4/5] move stripCustomoji logic to default Tengo script
Removing the image ID from the message (without any possibility of recovering it later) is a loss of valuable data that prevents users from giving support to custom emoji via Tengo scripts.
---
internal/tengo/outmessage.tengo | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/internal/tengo/outmessage.tengo b/internal/tengo/outmessage.tengo
index 2cbb8a22..d678e056 100644
--- a/internal/tengo/outmessage.tengo
+++ b/internal/tengo/outmessage.tengo
@@ -17,3 +17,9 @@ if inProtocol == "irc" && outProtocol != "irc" {
msgText=re.replace(msgText,"")
}
// end - strip irc colors
+
+// strip custom emoji
+if inProtocol == "discord" {
+ re := text.re_compile(``)
+ msgText=re.replace(msgText,"$1")
+}
From 3fa277acb1a65f99c60c7f9493cb8faa206cc1ec Mon Sep 17 00:00:00 2001
From: c0ncord <59654954+c0ncord@users.noreply.github.com>
Date: Wed, 8 Jan 2020 17:28:42 +0000
Subject: [PATCH 5/5] indentation
---
internal/tengo/outmessage.tengo | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/internal/tengo/outmessage.tengo b/internal/tengo/outmessage.tengo
index d678e056..a68bb3dd 100644
--- a/internal/tengo/outmessage.tengo
+++ b/internal/tengo/outmessage.tengo
@@ -20,6 +20,6 @@ if inProtocol == "irc" && outProtocol != "irc" {
// strip custom emoji
if inProtocol == "discord" {
- re := text.re_compile(``)
+ re := text.re_compile(``)
msgText=re.replace(msgText,"$1")
}