diff --git a/README.md b/README.md index d241d44..83f3560 100644 --- a/README.md +++ b/README.md @@ -749,6 +749,13 @@ Of course, replace ``` xyz ``` with an actual ID. ``` Of course, replace ``` xxx ``` with invitation code. + +- To join the group using groupInviteMessage + ``` ts + const response = await sock.groupAcceptInviteV4(groupInviteMessage) + console.log("joined to: " + response) + ``` + Of course, replace ``` xxx ``` with invitation code. ## Broadcast Lists & Stories **Note:** messages cannot be sent to broadcast lists from the MD version right now diff --git a/src/Socket/groups.ts b/src/Socket/groups.ts index 7421a20..237a994 100644 --- a/src/Socket/groups.ts +++ b/src/Socket/groups.ts @@ -2,6 +2,7 @@ import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types' import { generateMessageID } from '../Utils' import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidEncode, jidNormalizedUser } from '../WABinary' import { makeSocket } from './socket' +import { proto } from '../../WAProto' export const makeGroupsSocket = (config: SocketConfig) => { const sock = makeSocket(config) @@ -134,6 +135,13 @@ export const makeGroupsSocket = (config: SocketConfig) => { const result = getBinaryNodeChild(results, 'group') return result.attrs.jid }, + groupAcceptInviteV4: async(jid: string, inviteMessage: proto.IGroupInviteMessage) => { + const results = await groupQuery(inviteMessage.groupJid, 'set', [{ tag: 'accept', attrs: { + code: inviteMessage.inviteCode, + expiration: inviteMessage.inviteExpiration.toString(), + admin: jid} }]) + return results.attrs.from; + }, groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => { const content: BinaryNode = ephemeralExpiration ? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :