Thumbnail

rani/matterbridge.git

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

commit 251070f5f6134cf1868f3edc7eb5106e046bae13 Author: Wim <wim@42.be> Date: Mon Jun 26 22:16:19 2017 +0000 Remove label from URLs (slack). Closes #205 If slack detects a text contains an url it changes it to <http://url|url>. Strip the |url so that http://url remains. diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index fd4b9e1..ad6a2b6 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -1856 +1857 @@ func (b *Bslack) handleSlack() {   }   texts := strings.Split(message.Text, "\n")   for _, text := range texts { + text = b.replaceURL(text)   flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account)   b.Remote <- config.Message{Text: text, Username: message.Username, Channel: message.Channel, Account: b.Account, Avatar: b.getAvatar(message.Username), UserID: message.UserID}   } @@ -2793 +28011 @@ func (b *Bslack) replaceMention(text string) string {   }   return text  } + +func (b *Bslack) replaceURL(text string) string { + results := regexp.MustCompile(`<(.*?)\|.*?>`).FindAllStringSubmatch(text, -1) + for _, r := range results { + text = strings.Replace(text, r[0], r[1], -1) + } + return text +}