mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-29 07:29:29 +01:00
Check for Conversation on receiving messages (whatsapp)
This commit is contained in:
parent
21c4e56d16
commit
4da1444ffc
@ -46,17 +46,24 @@ func (b *Bwhatsapp) handleMessage(message *events.Message) {
|
||||
|
||||
func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto.Message) {
|
||||
senderJID := messageInfo.Sender
|
||||
channel := messageInfo.Chat
|
||||
|
||||
senderName := b.getSenderName(messageInfo.Sender)
|
||||
if senderName == "" {
|
||||
senderName = "Someone" // don't expose telephone number
|
||||
}
|
||||
|
||||
if msg.GetExtendedTextMessage() == nil {
|
||||
if msg.GetExtendedTextMessage() == nil && msg.GetConversation() == "" {
|
||||
b.Log.Debugf("message without text content? %#v", msg)
|
||||
return
|
||||
}
|
||||
|
||||
text := msg.GetExtendedTextMessage().GetText()
|
||||
var text string
|
||||
|
||||
if msg.GetExtendedTextMessage() == nil {
|
||||
text = msg.GetConversation()
|
||||
} else {
|
||||
text = msg.GetExtendedTextMessage().GetText()
|
||||
ci := msg.GetExtendedTextMessage().GetContextInfo()
|
||||
|
||||
if senderJID == (types.JID{}) && ci.Participant != nil {
|
||||
@ -78,12 +85,13 @@ func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto.
|
||||
text = strings.Replace(text, "@"+numberAndSuffix[0], "@"+mention, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rmsg := config.Message{
|
||||
UserID: senderJID.String(),
|
||||
Username: senderName,
|
||||
Text: msg.GetExtendedTextMessage().GetText(),
|
||||
Channel: ci.GetRemoteJid(),
|
||||
Text: text,
|
||||
Channel: channel.String(),
|
||||
Account: b.Account,
|
||||
Protocol: b.Protocol,
|
||||
Extra: make(map[string][]interface{}),
|
||||
|
@ -324,14 +324,9 @@ func (b *Bwhatsapp) Send(msg config.Message) (string, error) {
|
||||
|
||||
message.Conversation = &text
|
||||
|
||||
/*
|
||||
message.ExtendedTextMessage = &proto.ExtendedTextMessage{
|
||||
Text: &text,
|
||||
}
|
||||
*/
|
||||
|
||||
ID := whatsmeow.GenerateMessageID()
|
||||
b.Log.Debugf("=> Sending %#v to %#v with ID %s", message, groupJID, ID)
|
||||
|
||||
b.Log.Debugf("=> Sending %#v", message)
|
||||
|
||||
_, err := b.wc.SendMessage(groupJID, ID, &message)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user