Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit bc10ef935c3f1a1e7b4fec6969cdebb9dd949aa5 Author: Qais Patankar <qaisjp@gmail.com> Date: Fri Jan 04 19:32:58 2019 +0000 Fix #668 strip lang in code fences sent to Slack (#673) diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go index fb7a25d..4e6e565 100644 --- a/bridge/slack/helpers.go +++ b/bridge/slack/helpers.go @@ -2916 +2917 @@ 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)(?:: (.*))?`)  )   @@ -3536 +35410 @@ 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 { diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index d8dfc62..b943027 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -1886 +1888 @@ func (b *Bslack) Send(msg config.Message) (string, error) {   b.Log.Debugf("=> Receiving %#v", msg)   }   + msg.Text = b.replaceCodeFence(msg.Text) +   // Make a action /me of the message   if msg.Event == config.EventUserAction {   msg.Text = "_" + msg.Text + "_"