Skip to content

Commit

Permalink
feat: Added WPP.group.getAllGroups function (#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jan 13, 2023
1 parent d12d8ae commit 75fb318
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/group/functions/getAllGroups.ts
@@ -0,0 +1,35 @@
/*!
* Copyright 2023 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { get } from '../../chat';
import { queryAllGroups } from '../../whatsapp/functions';

/**
* Get all groups
*
* @example
* ```javascript
* WPP.group.queryAllGroups();
* ```
*/
export async function getAllGroups() {
const groupsArr = [];
const groups = await queryAllGroups();
for (const grp of groups) {
groupsArr.push(get(grp.id));
}
return groupsArr;
}
1 change: 1 addition & 0 deletions src/group/functions/index.ts
Expand Up @@ -23,6 +23,7 @@ export { create } from './create';
export { demoteParticipants } from './demoteParticipants';
export { ensureGroup } from './ensureGroup';
export { ensureGroupAndParticipants } from './ensureGroupAndParticipants';
export { getAllGroups } from './getAllGroups';
export { getGroupInfoFromInviteCode } from './getGroupInfoFromInviteCode';
export { getInviteCode } from './getInviteCode';
export { getParticipants } from './getParticipants';
Expand Down
1 change: 1 addition & 0 deletions src/whatsapp/functions/index.ts
Expand Up @@ -53,6 +53,7 @@ export * from './processRawSticker';
export * from './products';
export * from './productVisibilitySet';
export * from './profilePic';
export * from './queryAllGroups';
export * from './queryGroupInviteCode';
export * from './randomHex';
export * from './randomId';
Expand Down
54 changes: 54 additions & 0 deletions src/whatsapp/functions/queryAllGroups.ts
@@ -0,0 +1,54 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { exportModule } from '../exportModule';
import { Wid } from '../misc';

/**
* @whatsapp 113269
*/

export interface Group {
announce: boolean;
creation: number;
defaultSubgroup: boolean;
id: Wid;
incognito: boolean;
isParentGroup: boolean;
isParentGroupClosed: boolean;
membershipApprovalModed: boolean;
membershipApprovalRequest: any;
noFrequentlyForwarded: boolean;
numSubgroups: number;
owner: Wid;
participants: Wid[];
pvId: number;
restrict: boolean;
size: any;
subject: string;
subjectTime: number;
support: boolean;
suspended: boolean;
}
export declare function queryAllGroups(): Promise<Group[]>;

exportModule(
exports,
{
queryAllGroups: 'queryAllGroups',
},
(m) => m.queryAllGroups
);

0 comments on commit 75fb318

Please sign in to comment.