Skip to content

Commit 781c5bd

Browse files
committed
[WAHA] Fix group.description - attrs id
1 parent a12716b commit 781c5bd

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

group.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ package whatsmeow
88

99
import (
1010
"context"
11+
"encoding/hex"
1112
"errors"
1213
"fmt"
14+
"math/rand"
1315
"strings"
1416

1517
waBinary "go.mau.fi/whatsmeow/binary"
@@ -983,7 +985,11 @@ func (cli *Client) SetGroupDescription(jid types.JID, description string) error
983985
Tag: "description",
984986
Content: []waBinary.Node{
985987
{
986-
Tag: "body",
988+
Tag: "body",
989+
Attrs: waBinary.Attrs{
990+
"id": generateId(),
991+
"prev": "undefined",
992+
},
987993
Content: []byte(description),
988994
},
989995
},
@@ -992,3 +998,15 @@ func (cli *Client) SetGroupDescription(jid types.JID, description string) error
992998
_, err := cli.sendGroupIQ(context.TODO(), iqSet, jid, content)
993999
return err
9941000
}
1001+
1002+
func randomHex(n int) string {
1003+
bytes := make([]byte, n)
1004+
for i := range bytes {
1005+
bytes[i] = byte(rand.Intn(256))
1006+
}
1007+
return hex.EncodeToString(bytes)
1008+
}
1009+
1010+
func generateId() string {
1011+
return strings.ToUpper(randomHex(8))
1012+
}

0 commit comments

Comments
 (0)