From e62b9b4f653bf90872f8da79c348c2e53a4dc79d Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Thu, 25 Oct 2018 21:16:31 +0800 Subject: [PATCH] Don't show translation when result is identical string. --- gateway/translation.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gateway/translation.go b/gateway/translation.go index f32ebe29..2c265229 100644 --- a/gateway/translation.go +++ b/gateway/translation.go @@ -195,6 +195,13 @@ func (gw *Gateway) handleTranslation(msg *config.Message, dest *bridge.Bridge, c text = html.UnescapeString(text) flog.Debugf("post-unescaped:"+text) + // Don't show translation if only whitespace/caps different. + // eg. messages with only emoji, links, or untranslatable gibberish + if strings.ToLower(strings.Replace(text, " ", "", -1)) == strings.ToLower(strings.Replace(msg.Text, " ", "", -1)) { + msg.IsTranslation = false + return + } + if dest.Protocol == "slack" { // Attribution will be in attachment for Slack } else {