From 7b6370532ea533eb0887d49c04a193bb3ad4a613 Mon Sep 17 00:00:00 2001 From: zhaoYangguang <1163765691@qq.com> Date: Sat, 8 May 2021 16:42:07 +0800 Subject: [PATCH] optimize forward message and details --- formatting.go | 6 +++++- matrix.go | 2 +- portal.go | 9 +++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/formatting.go b/formatting.go index 54bad50..9c8d881 100644 --- a/formatting.go +++ b/formatting.go @@ -136,7 +136,11 @@ func (formatter *Formatter) ParseSkype(content *event.MessageEventContent, RoomM if portal.Key.JID != match[4] { content.FormattedBody = match[6] content.Body = fmt.Sprintf("%s\n\n", match[6]) - continue + + // this means that there are forwarding messages across groups + if strings.HasSuffix(match[4], skypeExt.GroupSuffix) || strings.HasSuffix(portal.Key.JID, skypeExt.GroupSuffix){ + continue + } } msgMXID := "" msg := formatter.bridge.DB.Message.GetByID(match[5]) diff --git a/matrix.go b/matrix.go index 69fcfde..74a5396 100644 --- a/matrix.go +++ b/matrix.go @@ -366,7 +366,7 @@ func (mx *MatrixHandler) shouldIgnoreEvent(evt *event.Event) bool { fmt.Println() return true } - isCustomPuppet, ok := evt.Content.Raw["net.maunium.whatsapp.puppet"].(bool) + isCustomPuppet, ok := evt.Content.Raw["net.maunium.skype.puppet"].(bool) if ok && isCustomPuppet && mx.bridge.GetPuppetByCustomMXID(evt.Sender) != nil { return true } diff --git a/portal.go b/portal.go index 192e404..206a289 100644 --- a/portal.go +++ b/portal.go @@ -1419,7 +1419,7 @@ func (portal *Portal) sendMessage(intent *appservice.IntentAPI, eventType event. wrappedContent := event.Content{Parsed: content} if timestamp != 0 && intent.IsCustomPuppet { wrappedContent.Raw = map[string]interface{}{ - "net.maunium.whatsapp.puppet": intent.IsCustomPuppet, + "net.maunium.skype.puppet": intent.IsCustomPuppet, } } fmt.Println("portal sendMessage timestamp:", timestamp) @@ -1477,17 +1477,14 @@ func (portal *Portal) HandleTextMessage(source *User, message skype.Resource) { } } // portal.SetReplySkype(content, message) - - fmt.Println() - fmt.Printf("portal HandleTextMessage2: %+v", content) + fmt.Printf("\nportal HandleTextMessage2: %+v", content) _, _ = intent.UserTyping(portal.MXID, false, 0) resp, err := portal.sendMessage(intent, event.EventMessage, content, message.Timestamp * 1000) if err != nil { portal.log.Errorfln("Failed to handle message %s: %v", message.Id, err) return } - fmt.Println() - fmt.Printf("portal HandleTextMessage3: %+v", content) + fmt.Printf("\nportal HandleTextMessage3: %+v", content) portal.finishHandlingSkype(source, &message, resp.EventID) } }