@wppconnect-team/wppconnect 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/api/layers/catalog.layer.d.ts +2 -2
- package/dist/api/layers/catalog.layer.js +2 -2
- package/dist/api/layers/community.layer.d.ts +56 -0
- package/dist/api/layers/community.layer.js +182 -0
- package/dist/api/layers/retriever.layer.d.ts +48 -0
- package/dist/api/layers/retriever.layer.js +105 -19
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# 1.27.0 (2023-06-02)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **deps:** update dependency @wppconnect/wa-version to ^1.2.44 ([#1716](https://github.com/wppconnect-team/wppconnect/issues/1716)) ([a62cb18](https://github.com/wppconnect-team/wppconnect/commit/a62cb188f1ee0f0dba8c49ab9638c943486835e7))
|
|
6
|
+
|
|
1
7
|
# 1.26.0 (2023-06-01)
|
|
2
8
|
|
|
3
9
|
# 1.25.0 (2023-05-30)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Page } from 'puppeteer';
|
|
2
2
|
import { CreateConfig } from '../../config/create-config';
|
|
3
|
-
import {
|
|
4
|
-
export declare class CatalogLayer extends
|
|
3
|
+
import { CommunityLayer } from './community.layer';
|
|
4
|
+
export declare class CatalogLayer extends CommunityLayer {
|
|
5
5
|
page: Page;
|
|
6
6
|
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
7
7
|
/**
|
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.CatalogLayer = void 0;
|
|
71
71
|
var helpers_1 = require("../helpers");
|
|
72
|
-
var
|
|
72
|
+
var community_layer_1 = require("./community.layer");
|
|
73
73
|
var CatalogLayer = /** @class */ (function (_super) {
|
|
74
74
|
__extends(CatalogLayer, _super);
|
|
75
75
|
function CatalogLayer(page, session, options) {
|
|
@@ -373,5 +373,5 @@ var CatalogLayer = /** @class */ (function (_super) {
|
|
|
373
373
|
});
|
|
374
374
|
};
|
|
375
375
|
return CatalogLayer;
|
|
376
|
-
}(
|
|
376
|
+
}(community_layer_1.CommunityLayer));
|
|
377
377
|
exports.CatalogLayer = CatalogLayer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Page } from 'puppeteer';
|
|
2
|
+
import { CreateConfig } from '../../config/create-config';
|
|
3
|
+
import { Wid } from '../model';
|
|
4
|
+
import { HostLayer } from './host.layer';
|
|
5
|
+
export declare class CommunityLayer extends HostLayer {
|
|
6
|
+
page: Page;
|
|
7
|
+
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
8
|
+
/**
|
|
9
|
+
* Create a community
|
|
10
|
+
*
|
|
11
|
+
* @category Community
|
|
12
|
+
* @param groupIds Array with groups id
|
|
13
|
+
*/
|
|
14
|
+
createCommunity(name: string, description: string, groupIds: string[] | Wid[]): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Deactivate a community
|
|
17
|
+
* @category Community
|
|
18
|
+
* @param communityId id
|
|
19
|
+
*/
|
|
20
|
+
deactivateCommunity(communityId: string | Wid): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Add groups to community
|
|
23
|
+
*
|
|
24
|
+
* @category Community
|
|
25
|
+
* @param communityId id
|
|
26
|
+
*/
|
|
27
|
+
addSubgroupsCommunity(communityId: string | Wid, groupsIds: string[]): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Remove groups of community
|
|
30
|
+
*
|
|
31
|
+
* @category Community
|
|
32
|
+
* @param communityId id
|
|
33
|
+
*/
|
|
34
|
+
removeSubgroupsCommunity(communityId: string | Wid, groupsIds: string[]): Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Remove admin of community participant
|
|
37
|
+
*
|
|
38
|
+
* @category Community
|
|
39
|
+
* @param communityId id
|
|
40
|
+
*/
|
|
41
|
+
demoteCommunityParticipant(communityId: string | Wid, participantId: string[] | string): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* Promote participant of community to admin
|
|
44
|
+
*
|
|
45
|
+
* @category Community
|
|
46
|
+
* @param communityId id
|
|
47
|
+
*/
|
|
48
|
+
promoteCommunityParticipant(communityId: string | Wid, participantId: string[] | string): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Get all participants of a community
|
|
51
|
+
*
|
|
52
|
+
* @category Community
|
|
53
|
+
* @param communityId id
|
|
54
|
+
*/
|
|
55
|
+
getCommunityParticipants(communityId: string | Wid): Promise<any>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This file is part of WPPConnect.
|
|
4
|
+
*
|
|
5
|
+
* WPPConnect is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* WPPConnect is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
var __extends = (this && this.__extends) || (function () {
|
|
19
|
+
var extendStatics = function (d, b) {
|
|
20
|
+
extendStatics = Object.setPrototypeOf ||
|
|
21
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
22
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
23
|
+
return extendStatics(d, b);
|
|
24
|
+
};
|
|
25
|
+
return function (d, b) {
|
|
26
|
+
if (typeof b !== "function" && b !== null)
|
|
27
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
28
|
+
extendStatics(d, b);
|
|
29
|
+
function __() { this.constructor = d; }
|
|
30
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
34
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
36
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
37
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
38
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
39
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
43
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
44
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
45
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
46
|
+
function step(op) {
|
|
47
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
48
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
49
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
50
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
51
|
+
switch (op[0]) {
|
|
52
|
+
case 0: case 1: t = op; break;
|
|
53
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
54
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
55
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
56
|
+
default:
|
|
57
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
58
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
59
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
60
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
61
|
+
if (t[2]) _.ops.pop();
|
|
62
|
+
_.trys.pop(); continue;
|
|
63
|
+
}
|
|
64
|
+
op = body.call(thisArg, _);
|
|
65
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
66
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.CommunityLayer = void 0;
|
|
71
|
+
var helpers_1 = require("../helpers");
|
|
72
|
+
var host_layer_1 = require("./host.layer");
|
|
73
|
+
var CommunityLayer = /** @class */ (function (_super) {
|
|
74
|
+
__extends(CommunityLayer, _super);
|
|
75
|
+
function CommunityLayer(page, session, options) {
|
|
76
|
+
var _this = _super.call(this, page, session, options) || this;
|
|
77
|
+
_this.page = page;
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create a community
|
|
82
|
+
*
|
|
83
|
+
* @category Community
|
|
84
|
+
* @param groupIds Array with groups id
|
|
85
|
+
*/
|
|
86
|
+
CommunityLayer.prototype.createCommunity = function (name, description, groupIds) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (name, description, groupIds) {
|
|
90
|
+
return WPP.community.create(name, description, groupIds);
|
|
91
|
+
}, name, description, groupIds)];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Deactivate a community
|
|
97
|
+
* @category Community
|
|
98
|
+
* @param communityId id
|
|
99
|
+
*/
|
|
100
|
+
CommunityLayer.prototype.deactivateCommunity = function (communityId) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (communityId) { return WPP.community.deactivate(communityId); }, communityId)];
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Add groups to community
|
|
109
|
+
*
|
|
110
|
+
* @category Community
|
|
111
|
+
* @param communityId id
|
|
112
|
+
*/
|
|
113
|
+
CommunityLayer.prototype.addSubgroupsCommunity = function (communityId, groupsIds) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (communityId, groupsIds) {
|
|
117
|
+
return WPP.community.addSubgroups(communityId, groupsIds);
|
|
118
|
+
}, communityId, groupsIds)];
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Remove groups of community
|
|
124
|
+
*
|
|
125
|
+
* @category Community
|
|
126
|
+
* @param communityId id
|
|
127
|
+
*/
|
|
128
|
+
CommunityLayer.prototype.removeSubgroupsCommunity = function (communityId, groupsIds) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (communityId, groupsIds) {
|
|
132
|
+
return WPP.community.removeSubgroups(communityId, groupsIds);
|
|
133
|
+
}, communityId, groupsIds)];
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Remove admin of community participant
|
|
139
|
+
*
|
|
140
|
+
* @category Community
|
|
141
|
+
* @param communityId id
|
|
142
|
+
*/
|
|
143
|
+
CommunityLayer.prototype.demoteCommunityParticipant = function (communityId, participantId) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (communityId, participantId) {
|
|
147
|
+
return WPP.community.demoteParticipants(communityId, participantId);
|
|
148
|
+
}, communityId, participantId)];
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Promote participant of community to admin
|
|
154
|
+
*
|
|
155
|
+
* @category Community
|
|
156
|
+
* @param communityId id
|
|
157
|
+
*/
|
|
158
|
+
CommunityLayer.prototype.promoteCommunityParticipant = function (communityId, participantId) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (communityId, participantId) {
|
|
162
|
+
return WPP.community.promoteParticipants(communityId, participantId);
|
|
163
|
+
}, communityId, participantId)];
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Get all participants of a community
|
|
169
|
+
*
|
|
170
|
+
* @category Community
|
|
171
|
+
* @param communityId id
|
|
172
|
+
*/
|
|
173
|
+
CommunityLayer.prototype.getCommunityParticipants = function (communityId) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (communityId) { return WPP.community.getParticipants(communityId); }, communityId)];
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
return CommunityLayer;
|
|
181
|
+
}(host_layer_1.HostLayer));
|
|
182
|
+
exports.CommunityLayer = CommunityLayer;
|
|
@@ -3,6 +3,7 @@ import { CreateConfig } from '../../config/create-config';
|
|
|
3
3
|
import { SessionToken } from '../../token-store';
|
|
4
4
|
import { Chat, ContactStatus, ProfilePicThumbObj, WhatsappProfile, Wid } from '../model';
|
|
5
5
|
import { SenderLayer } from './sender.layer';
|
|
6
|
+
import { ChatListOptions } from '@wppconnect/wa-js/dist/chat';
|
|
6
7
|
export declare class RetrieverLayer extends SenderLayer {
|
|
7
8
|
page: Page;
|
|
8
9
|
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
@@ -33,10 +34,45 @@ export declare class RetrieverLayer extends SenderLayer {
|
|
|
33
34
|
getBlockList(): Promise<string[]>;
|
|
34
35
|
/**
|
|
35
36
|
* Retrieves all chats
|
|
37
|
+
* Deprecated in favor of {@link listChats}
|
|
38
|
+
*
|
|
36
39
|
* @category Chat
|
|
37
40
|
* @returns array of [Chat]
|
|
41
|
+
* @deprecated Deprecated in favor of listChats.
|
|
38
42
|
*/
|
|
39
43
|
getAllChats(withNewMessageOnly?: boolean): Promise<Chat[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Return list of chats
|
|
46
|
+
* * @example
|
|
47
|
+
* ```javascript
|
|
48
|
+
* // All chats
|
|
49
|
+
* const chats = await client.chatList();
|
|
50
|
+
*
|
|
51
|
+
* // Some chats
|
|
52
|
+
* const chats = client.chatList({count: 20});
|
|
53
|
+
*
|
|
54
|
+
* // 20 chats before specific chat
|
|
55
|
+
* const chats = client.chatList({count: 20, direction: 'before', id: '[number]@c.us'});
|
|
56
|
+
*
|
|
57
|
+
* // Only users chats
|
|
58
|
+
* const chats = await client.chatList({onlyUsers: true});
|
|
59
|
+
*
|
|
60
|
+
* // Only groups chats
|
|
61
|
+
* const chats = await client.chatList({onlyGroups: true});
|
|
62
|
+
*
|
|
63
|
+
* // Only with label Text
|
|
64
|
+
* const chats = await client.chatList({withLabels: ['Test']});
|
|
65
|
+
*
|
|
66
|
+
* // Only with label id
|
|
67
|
+
* const chats = await client.chatList({withLabels: ['1']});
|
|
68
|
+
*
|
|
69
|
+
* // Only with label with one of text or id
|
|
70
|
+
* const chats = await client.chatList({withLabels: ['Alfa','5']});
|
|
71
|
+
* ```
|
|
72
|
+
* @category Chat
|
|
73
|
+
* @returns array of [Chat]
|
|
74
|
+
*/
|
|
75
|
+
listChats(options?: ChatListOptions): Promise<Chat[]>;
|
|
40
76
|
/**
|
|
41
77
|
* Checks if a number is a valid WA number
|
|
42
78
|
* @category Contact
|
|
@@ -46,14 +82,20 @@ export declare class RetrieverLayer extends SenderLayer {
|
|
|
46
82
|
checkNumberStatus(contactId: string): Promise<WhatsappProfile>;
|
|
47
83
|
/**
|
|
48
84
|
* Retrieves all chats with messages
|
|
85
|
+
* Deprecated in favor of {@link listChats}
|
|
86
|
+
*
|
|
49
87
|
* @category Chat
|
|
50
88
|
* @returns array of [Chat]
|
|
89
|
+
* @deprecated Deprecated in favor of listChats.
|
|
51
90
|
*/
|
|
52
91
|
getAllChatsWithMessages(withNewMessageOnly?: boolean): Promise<Chat[]>;
|
|
53
92
|
/**
|
|
54
93
|
* Retrieve all groups
|
|
94
|
+
* Deprecated in favor of {@link listChats}
|
|
95
|
+
*
|
|
55
96
|
* @category Group
|
|
56
97
|
* @returns array of groups
|
|
98
|
+
* @deprecated Deprecated in favor of listChats.
|
|
57
99
|
*/
|
|
58
100
|
getAllGroups(withNewMessagesOnly?: boolean): Promise<Chat[]>;
|
|
59
101
|
/**
|
|
@@ -239,4 +281,10 @@ export declare class RetrieverLayer extends SenderLayer {
|
|
|
239
281
|
sender: Wid;
|
|
240
282
|
}[];
|
|
241
283
|
}>;
|
|
284
|
+
/**
|
|
285
|
+
* Get the max number of participants for a group
|
|
286
|
+
*
|
|
287
|
+
* @category Group
|
|
288
|
+
*/
|
|
289
|
+
getGroupSizeLimit(): Promise<number>;
|
|
242
290
|
}
|
|
@@ -179,13 +179,17 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
179
179
|
};
|
|
180
180
|
/**
|
|
181
181
|
* Retrieves all chats
|
|
182
|
+
* Deprecated in favor of {@link listChats}
|
|
183
|
+
*
|
|
182
184
|
* @category Chat
|
|
183
185
|
* @returns array of [Chat]
|
|
186
|
+
* @deprecated Deprecated in favor of listChats.
|
|
184
187
|
*/
|
|
185
188
|
RetrieverLayer.prototype.getAllChats = function (withNewMessageOnly) {
|
|
186
189
|
if (withNewMessageOnly === void 0) { withNewMessageOnly = false; }
|
|
187
190
|
return __awaiter(this, void 0, void 0, function () {
|
|
188
191
|
return __generator(this, function (_a) {
|
|
192
|
+
this.logger.warn('Deprecated: This function [getAllChats] is deprecated in favor of the getList function. Please update your code accordingly.');
|
|
189
193
|
if (withNewMessageOnly) {
|
|
190
194
|
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function () { return WAPI.getAllChatsWithNewMsg(); })];
|
|
191
195
|
}
|
|
@@ -196,6 +200,62 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
196
200
|
});
|
|
197
201
|
});
|
|
198
202
|
};
|
|
203
|
+
/**
|
|
204
|
+
* Return list of chats
|
|
205
|
+
* * @example
|
|
206
|
+
* ```javascript
|
|
207
|
+
* // All chats
|
|
208
|
+
* const chats = await client.chatList();
|
|
209
|
+
*
|
|
210
|
+
* // Some chats
|
|
211
|
+
* const chats = client.chatList({count: 20});
|
|
212
|
+
*
|
|
213
|
+
* // 20 chats before specific chat
|
|
214
|
+
* const chats = client.chatList({count: 20, direction: 'before', id: '[number]@c.us'});
|
|
215
|
+
*
|
|
216
|
+
* // Only users chats
|
|
217
|
+
* const chats = await client.chatList({onlyUsers: true});
|
|
218
|
+
*
|
|
219
|
+
* // Only groups chats
|
|
220
|
+
* const chats = await client.chatList({onlyGroups: true});
|
|
221
|
+
*
|
|
222
|
+
* // Only with label Text
|
|
223
|
+
* const chats = await client.chatList({withLabels: ['Test']});
|
|
224
|
+
*
|
|
225
|
+
* // Only with label id
|
|
226
|
+
* const chats = await client.chatList({withLabels: ['1']});
|
|
227
|
+
*
|
|
228
|
+
* // Only with label with one of text or id
|
|
229
|
+
* const chats = await client.chatList({withLabels: ['Alfa','5']});
|
|
230
|
+
* ```
|
|
231
|
+
* @category Chat
|
|
232
|
+
* @returns array of [Chat]
|
|
233
|
+
*/
|
|
234
|
+
RetrieverLayer.prototype.listChats = function (options) {
|
|
235
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
236
|
+
var _this = this;
|
|
237
|
+
return __generator(this, function (_a) {
|
|
238
|
+
switch (_a.label) {
|
|
239
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
240
|
+
var options = _a.options;
|
|
241
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
242
|
+
var chats, serialized;
|
|
243
|
+
return __generator(this, function (_b) {
|
|
244
|
+
switch (_b.label) {
|
|
245
|
+
case 0: return [4 /*yield*/, WPP.chat.list(options)];
|
|
246
|
+
case 1:
|
|
247
|
+
chats = _b.sent();
|
|
248
|
+
serialized = chats.map(function (c) { return WAPI._serializeChatObj(c); });
|
|
249
|
+
return [2 /*return*/, serialized];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
}, { options: options })];
|
|
254
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
};
|
|
199
259
|
/**
|
|
200
260
|
* Checks if a number is a valid WA number
|
|
201
261
|
* @category Contact
|
|
@@ -214,13 +274,17 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
214
274
|
};
|
|
215
275
|
/**
|
|
216
276
|
* Retrieves all chats with messages
|
|
277
|
+
* Deprecated in favor of {@link listChats}
|
|
278
|
+
*
|
|
217
279
|
* @category Chat
|
|
218
280
|
* @returns array of [Chat]
|
|
281
|
+
* @deprecated Deprecated in favor of listChats.
|
|
219
282
|
*/
|
|
220
283
|
RetrieverLayer.prototype.getAllChatsWithMessages = function (withNewMessageOnly) {
|
|
221
284
|
if (withNewMessageOnly === void 0) { withNewMessageOnly = false; }
|
|
222
285
|
return __awaiter(this, void 0, void 0, function () {
|
|
223
286
|
return __generator(this, function (_a) {
|
|
287
|
+
this.logger.warn('Deprecated: This function [getAllChatsWithMessages] is deprecated in favor of the getList function. Please update your code accordingly.');
|
|
224
288
|
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (withNewMessageOnly) {
|
|
225
289
|
return WAPI.getAllChatsWithMessages(withNewMessageOnly);
|
|
226
290
|
}, withNewMessageOnly)];
|
|
@@ -229,8 +293,11 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
229
293
|
};
|
|
230
294
|
/**
|
|
231
295
|
* Retrieve all groups
|
|
296
|
+
* Deprecated in favor of {@link listChats}
|
|
297
|
+
*
|
|
232
298
|
* @category Group
|
|
233
299
|
* @returns array of groups
|
|
300
|
+
* @deprecated Deprecated in favor of listChats.
|
|
234
301
|
*/
|
|
235
302
|
RetrieverLayer.prototype.getAllGroups = function (withNewMessagesOnly) {
|
|
236
303
|
if (withNewMessagesOnly === void 0) { withNewMessagesOnly = false; }
|
|
@@ -238,26 +305,28 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
238
305
|
var _this = this;
|
|
239
306
|
return __generator(this, function (_a) {
|
|
240
307
|
switch (_a.label) {
|
|
241
|
-
case 0:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
var
|
|
245
|
-
return
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
308
|
+
case 0:
|
|
309
|
+
this.logger.warn('Deprecated: This function [getAllGroups] is deprecated in favor of the getList function. Please update your code accordingly.');
|
|
310
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
311
|
+
var withNewMessagesOnly = _a.withNewMessagesOnly;
|
|
312
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
313
|
+
var chats, groups;
|
|
314
|
+
return __generator(this, function (_b) {
|
|
315
|
+
switch (_b.label) {
|
|
316
|
+
case 0: return [4 /*yield*/, WPP.chat.list({
|
|
317
|
+
onlyGroups: true,
|
|
318
|
+
onlyWithUnreadMessage: withNewMessagesOnly,
|
|
319
|
+
})];
|
|
320
|
+
case 1:
|
|
321
|
+
chats = _b.sent();
|
|
322
|
+
return [4 /*yield*/, Promise.all(chats.map(function (c) { return WPP.group.ensureGroup(c.id); }))];
|
|
323
|
+
case 2:
|
|
324
|
+
groups = _b.sent();
|
|
325
|
+
return [2 /*return*/, groups.map(function (g) { return WAPI._serializeChatObj(g); })];
|
|
326
|
+
}
|
|
327
|
+
});
|
|
258
328
|
});
|
|
259
|
-
});
|
|
260
|
-
}, { withNewMessagesOnly: withNewMessagesOnly })];
|
|
329
|
+
}, { withNewMessagesOnly: withNewMessagesOnly })];
|
|
261
330
|
case 1: return [2 /*return*/, _a.sent()];
|
|
262
331
|
}
|
|
263
332
|
});
|
|
@@ -594,6 +663,23 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
594
663
|
});
|
|
595
664
|
});
|
|
596
665
|
};
|
|
666
|
+
/**
|
|
667
|
+
* Get the max number of participants for a group
|
|
668
|
+
*
|
|
669
|
+
* @category Group
|
|
670
|
+
*/
|
|
671
|
+
RetrieverLayer.prototype.getGroupSizeLimit = function () {
|
|
672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
673
|
+
return __generator(this, function (_a) {
|
|
674
|
+
switch (_a.label) {
|
|
675
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
|
|
676
|
+
return WPP.group.getGroupSizeLimit();
|
|
677
|
+
})];
|
|
678
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
};
|
|
597
683
|
return RetrieverLayer;
|
|
598
684
|
}(sender_layer_1.SenderLayer));
|
|
599
685
|
exports.RetrieverLayer = RetrieverLayer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wppconnect-team/wppconnect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"description": "WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination... 😀🤔💭",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@wppconnect/wa-js": "^2.24.2",
|
|
99
|
-
"@wppconnect/wa-version": "^1.2.
|
|
99
|
+
"@wppconnect/wa-version": "^1.2.44",
|
|
100
100
|
"atob": "^2.1.2",
|
|
101
101
|
"axios": "^1.4.0",
|
|
102
102
|
"boxen": "^5.1.2",
|