summaryrefslogtreecommitdiffstats
path: root/bridge/slack/helpers.go
diff options
context:
space:
mode:
authorQais Patankar <qaisjp@gmail.com>2019-01-04 19:32:58 +0000
committerWim <wim@42.be>2019-01-04 20:32:58 +0100
commit8522d8f29cf1625a0d31dab15428600133fe0dba (patch)
treee49ce56c7942a946c7dbec92a61e77eb2edb1cce /bridge/slack/helpers.go
parentbab385c342d62c8116653a7d091b88a99a9cb381 (diff)
downloadmatterbridge-msglm-8522d8f29cf1625a0d31dab15428600133fe0dba.tar.gz
matterbridge-msglm-8522d8f29cf1625a0d31dab15428600133fe0dba.tar.bz2
matterbridge-msglm-8522d8f29cf1625a0d31dab15428600133fe0dba.zip
Fix #668 strip lang in code fences sent to Slack (#673)
Diffstat (limited to 'bridge/slack/helpers.go')
-rw-r--r--bridge/slack/helpers.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go
index fb7a25d5..4e6e5652 100644
--- a/bridge/slack/helpers.go
+++ b/bridge/slack/helpers.go
@@ -291,6 +291,7 @@ var (
channelRE = regexp.MustCompile(`<#[a-zA-Z0-9]+\|(.+?)>`)
variableRE = regexp.MustCompile(`<!((?:subteam\^)?[a-zA-Z0-9]+)(?:\|@?(.+?))?>`)
urlRE = regexp.MustCompile(`<(.*?)(\|.*?)?>`)
+ codeFenceRE = regexp.MustCompile(`(?m)^` + "```" + `\w+$`)
topicOrPurposeRE = regexp.MustCompile(`(?s)(@.+) (cleared|set)(?: the)? channel (topic|purpose)(?:: (.*))?`)
)
@@ -353,6 +354,10 @@ func (b *Bslack) replaceURL(text string) string {
return text
}
+func (b *Bslack) replaceCodeFence(text string) string {
+ return codeFenceRE.ReplaceAllString(text, "```")
+}
+
func (b *Bslack) handleRateLimit(err error) error {
rateLimit, ok := err.(*slack.RateLimitedError)
if !ok {