mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Added method to join group (#417)
* Added method to join group * Added method to join group in README
This commit is contained in:
@@ -527,6 +527,12 @@ Of course, replace ``` xyz ``` with an actual ID.
|
||||
// Or if you've left the group -- call this
|
||||
const metadata2 = await conn.groupMetadataMinimal ("abcd-xyz@g.us")
|
||||
```
|
||||
- To join the group using the invitation code
|
||||
``` ts
|
||||
const response = await conn.acceptInvite ("xxx")
|
||||
console.log("joined to: " + response.gid)
|
||||
```
|
||||
Of course, replace ``` xxx ``` with invitation code.
|
||||
|
||||
## Broadcast Lists & Stories
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@ WAConnectionTest('Groups', (conn) => {
|
||||
assert.ok(code)
|
||||
assert.strictEqual(typeof code, 'string')
|
||||
})
|
||||
it('should joined group via invite code', async () => {
|
||||
const response = await conn.acceptInvite(gid)
|
||||
assert.ok(response.status)
|
||||
assert.strictEqual(response.status, response.gid)
|
||||
})
|
||||
it('should retrieve group metadata', async () => {
|
||||
const metadata = await conn.groupMetadata(gid)
|
||||
assert.strictEqual(metadata.id, gid)
|
||||
|
||||
@@ -177,4 +177,9 @@ export class WAConnection extends Base {
|
||||
const response = await this.query({json, expect200: true, requiresPhoneConnection: false})
|
||||
return response.code as string
|
||||
}
|
||||
}
|
||||
/** Join group via invite code */
|
||||
async acceptInvite(jid) {
|
||||
const response = await this.query({ json: ['action', 'invite', jid], expect200: true })
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user