Don't show translation when result is identical string.

This commit is contained in:
Patrick Connolly
2018-10-25 21:16:31 +08:00
parent 8971502f31
commit e62b9b4f65

View File

@@ -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 {