diff --git a/src/group/functions/getAllGroups.ts b/src/group/functions/getAllGroups.ts new file mode 100644 index 0000000000..8c69b84dd6 --- /dev/null +++ b/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; +} diff --git a/src/group/functions/index.ts b/src/group/functions/index.ts index 2c2ead07d0..7f2035de7a 100644 --- a/src/group/functions/index.ts +++ b/src/group/functions/index.ts @@ -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'; diff --git a/src/whatsapp/functions/index.ts b/src/whatsapp/functions/index.ts index d1d720c94e..f99492504b 100644 --- a/src/whatsapp/functions/index.ts +++ b/src/whatsapp/functions/index.ts @@ -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'; diff --git a/src/whatsapp/functions/queryAllGroups.ts b/src/whatsapp/functions/queryAllGroups.ts new file mode 100644 index 0000000000..828715894e --- /dev/null +++ b/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; + +exportModule( + exports, + { + queryAllGroups: 'queryAllGroups', + }, + (m) => m.queryAllGroups +);