Group update description (#859)

* Added groupUpdateDescription

* Updated README

Co-authored-by: Ilya Borodin <ilya.borodin@botconversa.com.br>
This commit is contained in:
Ilya Borodin
2021-11-15 05:39:10 +03:00
committed by GitHub
parent b1eab17409
commit ae80566c0e
2 changed files with 23 additions and 0 deletions

View File

@@ -542,6 +542,10 @@ Of course, replace ``` xyz ``` with an actual ID.
``` ts
await conn.groupUpdateSubject("abcd-xyz@g.us", "New Subject!")
```
- To change the group's description
``` ts
await conn.groupUpdateDescription("abcd-xyz@g.us", "New Description!")
```
- To change group settings
``` ts
// only allow admins to send messages

View File

@@ -100,6 +100,25 @@ export const makeGroupsSocket = (config: SocketConfig) => {
const participantsAffected = getBinaryNodeChildren(node!, 'participant')
return participantsAffected.map(p => p.attrs.jid)
},
groupUpdateDescription: async(jid: string, description?: string) => {
const metadata = await groupMetadata(jid);
const prev = metadata.descId ?? null;
await groupQuery(
jid,
'set',
[
{
tag: 'description',
attrs: {
...( description ? { id: generateMessageID() } : { delete: 'true' } ),
...(prev ? { prev } : {})
},
content: description ? [{tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8')}] : null
}
]
)
},
groupInviteCode: async(jid: string) => {
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }])
const inviteNode = getBinaryNodeChild(result, 'invite')