Skip to content

Commit

Permalink
Merge pull request Rhymen#541 from danielspk/updateprofilename
Browse files Browse the repository at this point in the history
Add UpdateProfileName method
  • Loading branch information
SchulteMK authored Mar 31, 2021
2 parents 3c094eb + 0b32512 commit 20ff813
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package whatsapp

import (
"fmt"
"github.com/Rhymen/go-whatsapp/binary"
"strconv"
"time"

"github.com/Rhymen/go-whatsapp/binary"
)

// Pictures must be JPG 640x640 and 96x96, respectively
Expand Down Expand Up @@ -41,3 +42,24 @@ func (wac *Conn) UploadProfilePic(image, preview []byte) (<-chan string, error)
}
return wac.writeBinary(n, profile, 136, tag)
}

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)
}

0 comments on commit 20ff813

Please sign in to comment.