diff --git a/parsers/default/defaultparser.go b/parsers/default/defaultparser.go index 10fa327..4fd2cd5 100644 --- a/parsers/default/defaultparser.go +++ b/parsers/default/defaultparser.go @@ -40,8 +40,9 @@ func (dp DefaultParser) ParseMessage(message slackmessage.SlackMessage) map[stri } // Get all links from message. - r := regexp.MustCompile("((https??://[a-zA-Z0-9.#!*/ _-]+)\\|([a-zA-Z0-9.#!*/ _+-]+))") + r := regexp.MustCompile(`<{1}([\pL\pP\pN]+)\|{1}([\pL\pP\pN\pZs]+)>{1}`) foundLinks := r.FindAllStringSubmatch(msg, -1) + c.Log.Debugln("Found links:", foundLinks) // Replace them. /*for _, link := range foundLinks { diff --git a/pushers/matrix/matrixconnection.go b/pushers/matrix/matrixconnection.go index a1f7891..cd33785 100644 --- a/pushers/matrix/matrixconnection.go +++ b/pushers/matrix/matrixconnection.go @@ -185,7 +185,7 @@ func (mxc *MatrixConnection) Initialize(conn_name string, api_root string, user // If we're here - everything is okay and we already in room. Send // greeting message. - mxc.SendMessage("OpenSAPS is back in business for connection '" + mxc.conn_name + "'!") + //mxc.SendMessage("OpenSAPS is back in business for connection '" + mxc.conn_name + "'!") } // This function launches when new data was received thru Slack API. @@ -200,7 +200,7 @@ func (mxc *MatrixConnection) ProcessMessage(message slackmessage.SlackMessage) { if linksFound { links := linksRaw.([][]string) for _, link := range links { - messageToSend = strings.Replace(messageToSend, "<"+link[0]+">", ``+link[3]+``, -1) + messageToSend = strings.Replace(messageToSend, link[0], ``+link[2]+``, -1) } } diff --git a/pushers/telegram/telegramconnection.go b/pushers/telegram/telegramconnection.go index 8c975ad..749fc03 100644 --- a/pushers/telegram/telegramconnection.go +++ b/pushers/telegram/telegramconnection.go @@ -47,7 +47,7 @@ func (tc *TelegramConnection) ProcessMessage(message slackmessage.SlackMessage) if linksFound { links := linksRaw.([][]string) for _, link := range links { - messageToSend = strings.Replace(messageToSend, "<"+link[0]+">", ``+link[3]+``, -1) + messageToSend = strings.Replace(messageToSend, link[0], ``+link[2]+``, -1) } }