tulir / whatsmeow

Go library for the WhatsApp web multidevice API
https://go.mau.fi/whatsmeow
Mozilla Public License 2.0
2.29k stars 427 forks source link

WhatsApp Name from Local Contact #573

Closed azickri closed 6 months ago

azickri commented 7 months ago

Is there an option or function to get the WhatsApp contact name instead of the name displayed by the WhatsApp user?

SoursopID commented 7 months ago

The contacts are probably also synced into the database. You can see this in the whatsmeow_contacts table.

ContactInfo.FullName

ref : https://github.com/tulir/whatsmeow/blob/350073db195c6b6fae832a5b420b5b67fd39f6be/types/user.go#L37-L47

Here is how to get the contact info :

ci, err := client.Store.Contacts.GetContact(jid)
if err != nil {
    panic(err)
}

fmt.Println(ci.FullName)
azickri commented 7 months ago

Thanks, i will try it.

azickri commented 6 months ago

@JustSoursop When I delete the .db file and try to reconnect, there are some contact names that go back to the beginning (before they were changed) is there a proper handling for this?

SoursopID commented 6 months ago

The contacts are auto-synced by default, including the update.