Fix parseMentions

Fixes #63
This commit is contained in:
erroneousboat 2017-12-01 13:24:02 +01:00
parent c2eee9955e
commit 2874a75228

View File

@ -403,13 +403,14 @@ func parseMessage(s *SlackService, msg string) string {
// <@U12345> // <@U12345>
func parseMentions(s *SlackService, msg string) string { func parseMentions(s *SlackService, msg string) string {
r := regexp.MustCompile(`\<@(\w+\|*\w+)\>`) r := regexp.MustCompile(`\<@(\w+\|*\w+)\>`)
rs := r.FindStringSubmatch(msg)
if len(rs) < 1 {
return msg
}
return r.ReplaceAllStringFunc( return r.ReplaceAllStringFunc(
msg, func(str string) string { msg, func(str string) string {
rs := r.FindStringSubmatch(str)
if len(rs) < 1 {
return str
}
var userID string var userID string
split := strings.Split(rs[1], "|") split := strings.Split(rs[1], "|")
if len(split) > 0 { if len(split) > 0 {