tulir / whatsmeow

Go library for the WhatsApp web multidevice API

Home Page:https://go.mau.fi/whatsmeow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WhatsApp Name from Local Contact

azickri opened this issue · comments

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

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

ContactInfo.FullName

ref :

whatsmeow/types/user.go

Lines 37 to 47 in 350073d

// ContactInfo contains the cached names of a WhatsApp user.
type ContactInfo struct {
Found bool
FirstName string
FullName string
PushName string
BusinessName string
}

Here is how to get the contact info :

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

fmt.Println(ci.FullName)

Thanks, i will try it.

@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?

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