mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: Returns an object with information about the invite code's group (#1562)
* feat: Returns an object with information about the invite code's group * refactor: more information in metadata group
This commit is contained in:
@@ -777,6 +777,11 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|||||||
console.log("joined to: " + response)
|
console.log("joined to: " + response)
|
||||||
```
|
```
|
||||||
Of course, replace ``` xxx ``` with invitation code.
|
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
|
- To join the group using groupInviteMessage
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
|||||||
}])
|
}])
|
||||||
return results.attrs.from
|
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) => {
|
groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => {
|
||||||
const content: BinaryNode = ephemeralExpiration ?
|
const content: BinaryNode = ephemeralExpiration ?
|
||||||
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
|
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
|
||||||
@@ -216,6 +220,9 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
const metadata: GroupMetadata = {
|
const metadata: GroupMetadata = {
|
||||||
id: groupId,
|
id: groupId,
|
||||||
subject: group.attrs.subject,
|
subject: group.attrs.subject,
|
||||||
|
subjectOwner: group.attrs.s_o,
|
||||||
|
subjectTime: +group.attrs.s_t,
|
||||||
|
size: +group.attrs.size,
|
||||||
creation: +group.attrs.creation,
|
creation: +group.attrs.creation,
|
||||||
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
||||||
desc,
|
desc,
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ export interface GroupMetadata {
|
|||||||
id: string
|
id: string
|
||||||
owner: string | undefined
|
owner: string | undefined
|
||||||
subject: string
|
subject: string
|
||||||
|
/** group subject owner */
|
||||||
|
subjectOwner?: string
|
||||||
|
/** group subject modification date */
|
||||||
|
subjectTime?: number
|
||||||
creation: number
|
creation: number
|
||||||
desc?: string
|
desc?: string
|
||||||
descOwner?: string
|
descOwner?: string
|
||||||
@@ -16,6 +20,8 @@ export interface GroupMetadata {
|
|||||||
restrict?: boolean
|
restrict?: boolean
|
||||||
/** is set when the group only allows admins to write messages */
|
/** is set when the group only allows admins to write messages */
|
||||||
announce?: boolean
|
announce?: boolean
|
||||||
|
/** number of group participants */
|
||||||
|
size?: number
|
||||||
// Baileys modified array
|
// Baileys modified array
|
||||||
participants: GroupParticipant[]
|
participants: GroupParticipant[]
|
||||||
ephemeralDuration?: number
|
ephemeralDuration?: number
|
||||||
|
|||||||
Reference in New Issue
Block a user