diff options
author | Wim <wim@42.be> | 2018-03-02 22:30:44 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-03-02 22:32:27 +0100 |
commit | e24f1c7c879beb0703fdd91bf640283685f377d0 (patch) | |
tree | 03f0d6ef8540384e0d956b0cfb2a22439a7dd193 | |
parent | dbf8a326d5bfc1c338bb217ce633fe23599e61b9 (diff) | |
download | matterbridge-msglm-e24f1c7c879beb0703fdd91bf640283685f377d0.tar.gz matterbridge-msglm-e24f1c7c879beb0703fdd91bf640283685f377d0.tar.bz2 matterbridge-msglm-e24f1c7c879beb0703fdd91bf640283685f377d0.zip |
Use replaceVariable for usergroups (slack) #379
-rw-r--r-- | bridge/slack/slack.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index e89954e2..9572548f 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -345,9 +345,6 @@ func (b *Bslack) replaceMention(text string) string { for _, r := range results { text = strings.Replace(text, "<@"+r[1]+">", "@"+b.userName(r[1]), -1) } - for _, r := range results { - text = strings.Replace(text, "<@"+r[1]+">", "@"+b.userGroupName(r[1]), -1) - } return text } @@ -362,9 +359,13 @@ func (b *Bslack) replaceChannel(text string) string { // @see https://api.slack.com/docs/message-formatting#variables func (b *Bslack) replaceVariable(text string) string { - results := regexp.MustCompile(`<!([a-zA-Z0-9]+)(\|.+?)?>`).FindAllStringSubmatch(text, -1) + results := regexp.MustCompile(`<!((?:subteam\^)?[a-zA-Z0-9]+)(?:\|(.+?))?>`).FindAllStringSubmatch(text, -1) for _, r := range results { - text = strings.Replace(text, r[0], "@"+r[1], -1) + if r[2] != "" { + text = strings.Replace(text, r[0], "@"+r[2], -1) + } else { + text = strings.Replace(text, r[0], "@"+r[1], -1) + } } return text } |