mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Add groupRevokeInvite, groupAcceptInvite and fix groupLeave (#860)
* Update groups.ts * Fix: error TS2448: Block-scoped variable 'result' used before its declaration.
This commit is contained in:
@@ -52,7 +52,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
|||||||
)
|
)
|
||||||
return extractGroupMetadata(result)
|
return extractGroupMetadata(result)
|
||||||
},
|
},
|
||||||
groupLeave: async(jid: string) => {
|
groupLeave: async(id: string) => {
|
||||||
await groupQuery(
|
await groupQuery(
|
||||||
'@g.us',
|
'@g.us',
|
||||||
'set',
|
'set',
|
||||||
@@ -61,7 +61,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
|||||||
tag: 'leave',
|
tag: 'leave',
|
||||||
attrs: { },
|
attrs: { },
|
||||||
content: [
|
content: [
|
||||||
{ tag: 'group', attrs: { jid } }
|
{ tag: 'group', attrs: { id } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -124,6 +124,16 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
|||||||
const inviteNode = getBinaryNodeChild(result, 'invite')
|
const inviteNode = getBinaryNodeChild(result, 'invite')
|
||||||
return inviteNode.attrs.code
|
return inviteNode.attrs.code
|
||||||
},
|
},
|
||||||
|
groupRevokeInvite: async (jid: string) => {
|
||||||
|
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }])
|
||||||
|
const inviteNode = getBinaryNodeChild(result, 'invite')
|
||||||
|
return inviteNode.attrs.code
|
||||||
|
},
|
||||||
|
groupAcceptInvite: async (code: string) => {
|
||||||
|
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }])
|
||||||
|
const result = getBinaryNodeChild(results, 'group')
|
||||||
|
return result.attrs.jid
|
||||||
|
},
|
||||||
groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => {
|
groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => {
|
||||||
const content: BinaryNode = ephemeralExpiration ?
|
const content: BinaryNode = ephemeralExpiration ?
|
||||||
{ tag: 'ephemeral', attrs: { ephemeral: ephemeralExpiration.toString() } } :
|
{ tag: 'ephemeral', attrs: { ephemeral: ephemeralExpiration.toString() } } :
|
||||||
@@ -202,4 +212,4 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
ephemeralDuration: eph ? +eph : undefined
|
ephemeralDuration: eph ? +eph : undefined
|
||||||
}
|
}
|
||||||
return metadata
|
return metadata
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user