Rhymen / go-whatsapp

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

How to do a push name? #540

Closed danielspk closed 3 years ago

danielspk commented 3 years ago

Hi, how can I update the pushname of the profile? There is a method for the avatar called UploadProfilePic(), but I can't find anything for the pushname. Any suggestions?

danielspk commented 3 years ago

The following code would seem to work:

package whatsapp

import ...

func (wac *Conn) UploadProfilePic(image, preview []byte) (<-chan string, error) ...

func (wac *Conn) UpdateProfileName(name string) (<-chan string, error) {
    tag := fmt.Sprintf("%d.--%d", time.Now().Unix(), wac.msgCount*19)
    n := binary.Node{
        Description: "action",
        Attributes: map[string]string{
            "type":  "set",
            "epoch": strconv.Itoa(wac.msgCount),
        },
        Content: []interface{}{
            binary.Node{
                Description: "profile",
                Attributes: map[string]string{
                    "name": name,
                },
                Content: []binary.Node{},
            },
        },
    }
    return wac.writeBinary(n, profile, ignore, tag)
}

If there is no native form in Rhymen, can I make a pull request?

beshoo commented 3 years ago

Yes please do

Regard

On Wed, Mar 31, 2021, 2:13 AM Daniel M. Spiridione @.***> wrote:

The following code would seem to work:

package whatsapp import ... func (wac Conn) UploadProfilePic(image, preview []byte) (<-chan string, error) ... func (wac Conn) UpdateProfileName(name string) (<-chan string, error) { tag := fmt.Sprintf("%d.--%d", time.Now().Unix(), wac.msgCount*19) n := binary.Node{ Description: "action", Attributes: map[string]string{ "type": "set", "epoch": strconv.Itoa(wac.msgCount), }, Content: []interface{}{ binary.Node{ Description: "profile", Attributes: map[string]string{ "name": name, }, Content: []binary.Node{}, }, }, } return wac.writeBinary(n, profile, ignore, tag) }

If there is no native form in Rhymen, can I make a pull request?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Rhymen/go-whatsapp/issues/540#issuecomment-810638163, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDLT225WERMANVRVKOM42LTGJLKPANCNFSM42DD6B7A .

danielspk commented 3 years ago

Close.

Pull request accepted https://github.com/Rhymen/go-whatsapp/pull/541