muliti mention
This commit is contained in:
parent
43b937d645
commit
9ca4638475
30
portal.go
30
portal.go
|
@ -1901,11 +1901,10 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
|
||||||
//ctxInfo := &waProto.ContextInfo{}
|
//ctxInfo := &waProto.ContextInfo{}
|
||||||
replyToID := content.GetReplyTo()
|
replyToID := content.GetReplyTo()
|
||||||
var newContent string
|
var newContent string
|
||||||
|
backStr := ""
|
||||||
if len(replyToID) > 0 {
|
if len(replyToID) > 0 {
|
||||||
rQuote := regexp.MustCompile(`<mx-reply>(.*?)</mx-reply>(.*)`)
|
rQuote := regexp.MustCompile(`<mx-reply>(.*?)</mx-reply>(.*)`)
|
||||||
quoteMatches := rQuote.FindAllStringSubmatch(content.FormattedBody, -1)
|
quoteMatches := rQuote.FindAllStringSubmatch(content.FormattedBody, -1)
|
||||||
backStr := ""
|
|
||||||
if len(quoteMatches) > 0 {
|
if len(quoteMatches) > 0 {
|
||||||
if len(quoteMatches[0]) > 2 {
|
if len(quoteMatches[0]) > 2 {
|
||||||
backStr = quoteMatches[0][2]
|
backStr = quoteMatches[0][2]
|
||||||
|
@ -1929,7 +1928,7 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
|
||||||
|
|
||||||
puppet := sender.bridge.GetPuppetByJID(msg.Sender)
|
puppet := sender.bridge.GetPuppetByJID(msg.Sender)
|
||||||
|
|
||||||
newContent = fmt.Sprintf(`<quote author="%s" authorname="%s" timestamp="%s" conversation="%s" messageid="%s" cuid="%s"><legacyquote>[%s] %s: </legacyquote>%s<legacyquote>\n\n<<< </legacyquote></quote>%s`,
|
newContent = fmt.Sprintf(`<quote author="%s" authorname="%s" timestamp="%s" conversation="%s" messageid="%s" cuid="%s"><legacyquote>[%s] %s: </legacyquote>%s<legacyquote>\n\n<<< </legacyquote></quote>`,
|
||||||
author,
|
author,
|
||||||
puppet.Displayname,
|
puppet.Displayname,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
@ -1938,8 +1937,7 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
|
||||||
cuid,
|
cuid,
|
||||||
timestamp,
|
timestamp,
|
||||||
puppet.Displayname,
|
puppet.Displayname,
|
||||||
quoteMessage,
|
quoteMessage)
|
||||||
backStr)
|
|
||||||
content.FormattedBody = newContent
|
content.FormattedBody = newContent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1975,9 +1973,12 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
|
||||||
text = "/me " + text
|
text = "/me " + text
|
||||||
}
|
}
|
||||||
if len(content.FormattedBody) > 0 {
|
if len(content.FormattedBody) > 0 {
|
||||||
//r := regexp.MustCompile(`<a[^>]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.Domain + `/#/@skype&([^"]+):(.*?)">(.*?)</a>*`)
|
matchStr := content.FormattedBody
|
||||||
r := regexp.MustCompile(`<a[^>]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.Domain + `/#/@([^"]+):(.*?)">(.*?)</a>*`)
|
if len(backStr) > 0 {
|
||||||
matches := r.FindAllStringSubmatch(content.FormattedBody, -1)
|
matchStr = backStr
|
||||||
|
}
|
||||||
|
r := regexp.MustCompile(`(?m)<a[^>]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.Domain + `/#/@([^"]+):(.*?)">(.*?)</a>`)
|
||||||
|
matches := r.FindAllStringSubmatch(matchStr, -1)
|
||||||
fmt.Println("matches: ", matches)
|
fmt.Println("matches: ", matches)
|
||||||
if len(matches) > 0 {
|
if len(matches) > 0 {
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
|
@ -1986,10 +1987,19 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
|
||||||
skyId = strings.ReplaceAll(skyId, "skype&", "")
|
skyId = strings.ReplaceAll(skyId, "skype&", "")
|
||||||
skyId = strings.ReplaceAll(skyId, "-", ":")
|
skyId = strings.ReplaceAll(skyId, "-", ":")
|
||||||
// Adapt to the message format sent by the matrix front end
|
// Adapt to the message format sent by the matrix front end
|
||||||
content.FormattedBody = strings.ReplaceAll(content.FormattedBody, match[0] + ":", fmt.Sprintf(`<at id="%s">%s</at>`, skyId, match[4]))
|
matchStr = strings.ReplaceAll(matchStr, match[0] + ":", fmt.Sprintf(`<at id="%s">%s</at>`, skyId, match[4]))
|
||||||
content.FormattedBody = strings.ReplaceAll(content.FormattedBody, match[0], fmt.Sprintf(`<at id="%s">%s</at>`, skyId, match[4]))
|
matchStr = strings.ReplaceAll(matchStr, match[0], fmt.Sprintf(`<at id="%s">%s</at>`, skyId, match[4]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(backStr) > 0 {
|
||||||
|
content.FormattedBody = content.FormattedBody + matchStr
|
||||||
|
} else {
|
||||||
|
content.FormattedBody = matchStr
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if len(backStr) > 0 {
|
||||||
|
content.FormattedBody = content.FormattedBody + backStr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info.SendTextMessage = &skype.SendTextMessage{
|
info.SendTextMessage = &skype.SendTextMessage{
|
||||||
|
|
Loading…
Reference in New Issue