diff --git a/README.md b/README.md index 56391cd..a128ce1 100644 --- a/README.md +++ b/README.md @@ -777,6 +777,11 @@ Of course, replace ``` xyz ``` with an actual ID. console.log("joined to: " + response) ``` Of course, replace ``` xxx ``` with invitation code. +- To get info group by invite code + ```ts + const response = await sock.groupGetInviteInfo("xxx") + console.log("group information: " + response) + ``` - To join the group using groupInviteMessage diff --git a/src/Socket/groups.ts b/src/Socket/groups.ts index ebfedde..23b2287 100644 --- a/src/Socket/groups.ts +++ b/src/Socket/groups.ts @@ -153,6 +153,10 @@ export const makeGroupsSocket = (config: SocketConfig) => { }]) return results.attrs.from }, + groupGetInviteInfo: async(code: string) => { + const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]) + return extractGroupMetadata(results) + }, groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => { const content: BinaryNode = ephemeralExpiration ? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } : @@ -216,6 +220,9 @@ export const extractGroupMetadata = (result: BinaryNode) => { const metadata: GroupMetadata = { id: groupId, subject: group.attrs.subject, + subjectOwner: group.attrs.s_o, + subjectTime: +group.attrs.s_t, + size: +group.attrs.size, creation: +group.attrs.creation, owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined, desc, diff --git a/src/Types/GroupMetadata.ts b/src/Types/GroupMetadata.ts index c4c0ff7..f09e09a 100644 --- a/src/Types/GroupMetadata.ts +++ b/src/Types/GroupMetadata.ts @@ -8,6 +8,10 @@ export interface GroupMetadata { id: string owner: string | undefined subject: string + /** group subject owner */ + subjectOwner?: string + /** group subject modification date */ + subjectTime?: number creation: number desc?: string descOwner?: string @@ -16,6 +20,8 @@ export interface GroupMetadata { restrict?: boolean /** is set when the group only allows admins to write messages */ announce?: boolean + /** number of group participants */ + size?: number // Baileys modified array participants: GroupParticipant[] ephemeralDuration?: number