Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.07k stars 492 forks source link

Messange SenderJId and PushName Always empty #421

Open ribeiroferreiralucas opened 4 years ago

ribeiroferreiralucas commented 4 years ago
func (wpp *waHandler) HandleTextMessage(message whatsapp.TextMessage) {

    fmt.Printf("message %v \nchat %v %v %v sender: %v %v %v \n %v \n\n-------\n\n",
        message.Info.Id,
        wpp.c.Store.Chats[message.Info.RemoteJid].Name, wpp.c.Store.Chats[message.Info.RemoteJid].Jid, message.Info.RemoteJid,
        message.Info.PushName, message.Info.SenderJid, message.ContextInfo.Participant,
        message.Text)
    // fmt.Printf("%v %v %v %v %v %v\n\t%v\n", message.Info.Timestamp, message.Info.Id, message.Info.RemoteJid, message.Info.SenderJid, message.ContextInfo.Participant, message.ContextInfo.QuotedMessageID, message.Text)
}

Output:

message 91DA7C773E616AF6AE204AD61B8E882C
chat Lecy 5521XXXXXXXXX@s.whatsapp.net 5521XXXXXXXXX@s.whatsapp.net sender:
 Não haverá mais reunião  amanhã

-------

message EDBCB2503E3ADD135BC26D2A41C4DDAA
chat Lecy 5521XXXXXXXXX@s.whatsapp.net 5521XXXXXXXXX@s.whatsapp.net sender:
 🥰🥰🥰

-------

message 00CD056CCDBB2479CAF27D45782951DF
chat Lecy 5521XXXXXXXXX@s.whatsapp.net 5521XXXXXXXXX@s.whatsapp.net sender:
 Venha com Deus.

-------
UFailed commented 4 years ago

Yes, I have the same problem

ribeiroferreiralucas commented 4 years ago

I'm still with the problem. I really need some way to solve this or some idea to how to solve this.

cianoscatolo commented 4 years ago

If you just want the sender JID for knowing the message sender in a group, just use the following:

var jid string
if message.Info.Source.Participant == nil {
    jid = message.Info.RemoteJid
}else{
    jid = *message.Info.Source.Participant
}
mbprog91 commented 3 years ago

Unfourtenately, I have the same problem and dont know how to solve it. Tried many ways, but without any result

ribeiroferreiralucas commented 3 years ago

Unfourtenately, I have the same problem and dont know how to solve it. Tried many ways, but without any result

Hi, the following suggestion (by @cianoscatolo ) worked to me.

If you just want the sender JID for knowing the message sender in a group, just use the following:

var jid string
if message.Info.Source.Participant == nil {
  jid = message.Info.RemoteJid
}else{
  jid = *message.Info.Source.Participant
}
RynKings commented 3 years ago

maybe you can use contacts store ?

wac.Store.Contacts[senderJid]

SchulteMK commented 3 years ago

485 should fix the issue with the empty SenderJid, but I do not have a solution for the PushName...

SchulteMK commented 3 years ago

Does anyone know how to retrieve the PushName? Or in which conditions the field is not empty? I imagined that the PushName is only transmitted if the number is not in your contact list, but a quick test showed that even then it is empty.