fix mention user

This commit is contained in:
zhaoYangguang 2021-11-16 18:03:03 +08:00
parent ec4dbf1e07
commit a84094b601
1 changed files with 3 additions and 3 deletions

View File

@ -2067,12 +2067,12 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
// mention user message
r := regexp.MustCompile(`(?m)<a[^>]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.ServerName + `/#/@([^"]+):(.*?)">(.*?)</a>`)
matches := r.FindAllStringSubmatch(matchStr, -1)
fmt.Println("matches: ", matches)
portal.log.Debugln("matches: ", matches)
if len(matches) > 0 {
for _, match := range matches {
if len(match) > 2 {
skyId := patch.ParseLocalPart(html.UnescapeString(match[2]), false)
skyId = strings.ReplaceAll(skyId, "skype&", "")
skyId = strings.ReplaceAll(skyId, patch.AsUserPrefix, "")
skyId = strings.ReplaceAll(skyId, "-", ":")
// Adapt to the message format sent by the matrix front end
matchStr = strings.ReplaceAll(matchStr, match[0]+":", fmt.Sprintf(`<at id="%s">%s</at>`, skyId, match[4]))