@wppconnect-team/wppconnect 2.0.0 → 2.0.1
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/helpers/base64-mimetype.js +2 -2
- package/dist/api/helpers/decrypt.js +65 -72
- package/dist/api/helpers/download-file.js +31 -81
- package/dist/api/helpers/evaluate-and-return.js +98 -93
- package/dist/api/helpers/file-to-base64.js +30 -81
- package/dist/api/helpers/filename-from-mimetype.js +4 -4
- package/dist/api/helpers/scrape-img-qr.js +37 -86
- package/dist/api/helpers/scrape-login.js +12 -57
- package/dist/api/helpers/select-sticker.js +35 -100
- package/dist/api/layers/business.layer.js +29 -134
- package/dist/api/layers/catalog.layer.js +59 -210
- package/dist/api/layers/community.layer.js +29 -120
- package/dist/api/layers/controls.layer.js +62 -262
- package/dist/api/layers/group.layer.js +126 -391
- package/dist/api/layers/host.layer.js +348 -702
- package/dist/api/layers/labels.layer.js +35 -131
- package/dist/api/layers/listener.layer.js +386 -504
- package/dist/api/layers/newsletter.layer.js +20 -89
- package/dist/api/layers/profile.layer.js +73 -184
- package/dist/api/layers/retriever.layer.js +161 -468
- package/dist/api/layers/sender.layer.js +554 -1094
- package/dist/api/layers/status.layer.js +80 -179
- package/dist/api/layers/ui.layer.js +32 -129
- package/dist/api/model/enum/definitions.js +1 -1
- package/dist/api/whatsapp.js +200 -437
- package/dist/config/WAuserAgente.js +1 -1
- package/dist/config/create-config.js +1 -1
- package/dist/config/puppeteer.config.js +1 -1
- package/dist/controllers/auth.js +42 -110
- package/dist/controllers/browser.js +251 -411
- package/dist/controllers/initializer.js +171 -265
- package/dist/controllers/websocket.js +29 -28
- package/dist/controllers/welcome.js +38 -88
- package/dist/token-store/fileTokenStore.js +83 -173
- package/dist/token-store/isValidSessionToken.js +2 -2
- package/dist/token-store/isValidTokenStore.js +2 -2
- package/dist/token-store/memoryTokenStore.js +11 -14
- package/dist/utils/ffmpeg.js +75 -131
- package/dist/utils/logger.js +5 -5
- package/dist/utils/semver.js +6 -6
- package/dist/utils/sleep.js +1 -1
- package/package.json +6 -6
|
@@ -15,67 +15,15 @@
|
|
|
15
15
|
* You should have received a copy of the GNU Lesser General Public License
|
|
16
16
|
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
17
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
44
|
-
return g.next = verb(0), g["throw"] = verb(1), g["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
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
19
|
exports.CommunityLayer = void 0;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return _this;
|
|
20
|
+
const helpers_1 = require("../helpers");
|
|
21
|
+
const newsletter_layer_1 = require("./newsletter.layer");
|
|
22
|
+
class CommunityLayer extends newsletter_layer_1.NewsletterLayer {
|
|
23
|
+
page;
|
|
24
|
+
constructor(page, session, options) {
|
|
25
|
+
super(page, session, options);
|
|
26
|
+
this.page = page;
|
|
79
27
|
}
|
|
80
28
|
/**
|
|
81
29
|
* Create a community
|
|
@@ -83,100 +31,61 @@ var CommunityLayer = /** @class */ (function (_super) {
|
|
|
83
31
|
* @category Community
|
|
84
32
|
* @param groupIds Array with groups id
|
|
85
33
|
*/
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
|
|
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
|
-
};
|
|
34
|
+
async createCommunity(name, description, groupIds) {
|
|
35
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (name, description, groupIds) => WPP.community.create(name, description, groupIds), name, description, groupIds);
|
|
36
|
+
}
|
|
95
37
|
/**
|
|
96
38
|
* Deactivate a community
|
|
97
39
|
* @category Community
|
|
98
40
|
* @param communityId id
|
|
99
41
|
*/
|
|
100
|
-
|
|
101
|
-
return
|
|
102
|
-
|
|
103
|
-
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (communityId) { return WPP.community.deactivate(communityId); }, communityId)];
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
};
|
|
42
|
+
async deactivateCommunity(communityId) {
|
|
43
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (communityId) => WPP.community.deactivate(communityId), communityId);
|
|
44
|
+
}
|
|
107
45
|
/**
|
|
108
46
|
* Add groups to community
|
|
109
47
|
*
|
|
110
48
|
* @category Community
|
|
111
49
|
* @param communityId id
|
|
112
50
|
*/
|
|
113
|
-
|
|
114
|
-
return
|
|
115
|
-
|
|
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
|
-
};
|
|
51
|
+
async addSubgroupsCommunity(communityId, groupsIds) {
|
|
52
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (communityId, groupsIds) => WPP.community.addSubgroups(communityId, groupsIds), communityId, groupsIds);
|
|
53
|
+
}
|
|
122
54
|
/**
|
|
123
55
|
* Remove groups of community
|
|
124
56
|
*
|
|
125
57
|
* @category Community
|
|
126
58
|
* @param communityId id
|
|
127
59
|
*/
|
|
128
|
-
|
|
129
|
-
return
|
|
130
|
-
|
|
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
|
-
};
|
|
60
|
+
async removeSubgroupsCommunity(communityId, groupsIds) {
|
|
61
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (communityId, groupsIds) => WPP.community.removeSubgroups(communityId, groupsIds), communityId, groupsIds);
|
|
62
|
+
}
|
|
137
63
|
/**
|
|
138
64
|
* Remove admin of community participant
|
|
139
65
|
*
|
|
140
66
|
* @category Community
|
|
141
67
|
* @param communityId id
|
|
142
68
|
*/
|
|
143
|
-
|
|
144
|
-
return
|
|
145
|
-
|
|
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
|
-
};
|
|
69
|
+
async demoteCommunityParticipant(communityId, participantId) {
|
|
70
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (communityId, participantId) => WPP.community.demoteParticipants(communityId, participantId), communityId, participantId);
|
|
71
|
+
}
|
|
152
72
|
/**
|
|
153
73
|
* Promote participant of community to admin
|
|
154
74
|
*
|
|
155
75
|
* @category Community
|
|
156
76
|
* @param communityId id
|
|
157
77
|
*/
|
|
158
|
-
|
|
159
|
-
return
|
|
160
|
-
|
|
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
|
-
};
|
|
78
|
+
async promoteCommunityParticipant(communityId, participantId) {
|
|
79
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (communityId, participantId) => WPP.community.promoteParticipants(communityId, participantId), communityId, participantId);
|
|
80
|
+
}
|
|
167
81
|
/**
|
|
168
82
|
* Get all participants of a community
|
|
169
83
|
*
|
|
170
84
|
* @category Community
|
|
171
85
|
* @param communityId id
|
|
172
86
|
*/
|
|
173
|
-
|
|
174
|
-
return
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
return CommunityLayer;
|
|
181
|
-
}(newsletter_layer_1.NewsletterLayer));
|
|
87
|
+
async getCommunityParticipants(communityId) {
|
|
88
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (communityId) => WPP.community.getParticipants(communityId), communityId);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
182
91
|
exports.CommunityLayer = CommunityLayer;
|
|
@@ -15,67 +15,15 @@
|
|
|
15
15
|
* You should have received a copy of the GNU Lesser General Public License
|
|
16
16
|
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
17
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
44
|
-
return g.next = verb(0), g["throw"] = verb(1), g["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
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
19
|
exports.ControlsLayer = void 0;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return _this;
|
|
20
|
+
const helpers_1 = require("../helpers");
|
|
21
|
+
const ui_layer_1 = require("./ui.layer");
|
|
22
|
+
class ControlsLayer extends ui_layer_1.UILayer {
|
|
23
|
+
page;
|
|
24
|
+
constructor(page, session, options) {
|
|
25
|
+
super(page, session, options);
|
|
26
|
+
this.page = page;
|
|
79
27
|
}
|
|
80
28
|
/**
|
|
81
29
|
* Unblock contact
|
|
@@ -83,73 +31,40 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
83
31
|
* @param contactId {string} id '000000000000@c.us'
|
|
84
32
|
* @returns boolean
|
|
85
33
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (contactId) { return WPP.blocklist.unblockContact(contactId); }, contactId)];
|
|
91
|
-
case 1:
|
|
92
|
-
_a.sent();
|
|
93
|
-
return [2 /*return*/, true];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
};
|
|
34
|
+
async unblockContact(contactId) {
|
|
35
|
+
await (0, helpers_1.evaluateAndReturn)(this.page, (contactId) => WPP.blocklist.unblockContact(contactId), contactId);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
98
38
|
/**
|
|
99
39
|
* Block contact
|
|
100
40
|
* @category Blocklist
|
|
101
41
|
* @param contactId {string} id '000000000000@c.us'
|
|
102
42
|
* @returns boolean
|
|
103
43
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (contactId) { return WPP.blocklist.blockContact(contactId); }, contactId)];
|
|
109
|
-
case 1:
|
|
110
|
-
_a.sent();
|
|
111
|
-
return [2 /*return*/, true];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
44
|
+
async blockContact(contactId) {
|
|
45
|
+
await (0, helpers_1.evaluateAndReturn)(this.page, (contactId) => WPP.blocklist.blockContact(contactId), contactId);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
116
48
|
/**
|
|
117
49
|
* puts the chat as unread
|
|
118
50
|
* @category Chat
|
|
119
51
|
* @param contactId {string} id '000000000000@c.us'
|
|
120
52
|
* @returns boolean
|
|
121
53
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (contactId) { return WPP.chat.markIsUnread(contactId); }, contactId)];
|
|
127
|
-
case 1:
|
|
128
|
-
_a.sent();
|
|
129
|
-
return [2 /*return*/, true];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
};
|
|
54
|
+
async markUnseenMessage(contactId) {
|
|
55
|
+
await (0, helpers_1.evaluateAndReturn)(this.page, (contactId) => WPP.chat.markIsUnread(contactId), contactId);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
134
58
|
/**
|
|
135
59
|
* Deletes the given chat
|
|
136
60
|
* @category Chat
|
|
137
61
|
* @param chatId {string} id '000000000000@c.us'
|
|
138
62
|
* @returns boolean
|
|
139
63
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
switch (_a.label) {
|
|
145
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (chatId) { return WPP.chat.delete(chatId); }, chatId)];
|
|
146
|
-
case 1:
|
|
147
|
-
result = _a.sent();
|
|
148
|
-
return [2 /*return*/, result.status === 200];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
};
|
|
64
|
+
async deleteChat(chatId) {
|
|
65
|
+
const result = await (0, helpers_1.evaluateAndReturn)(this.page, (chatId) => WPP.chat.delete(chatId), chatId);
|
|
66
|
+
return result.status === 200;
|
|
67
|
+
}
|
|
153
68
|
/**
|
|
154
69
|
* Archive and unarchive chat messages with true or false
|
|
155
70
|
* @category Chat
|
|
@@ -157,17 +72,9 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
157
72
|
* @param option {boolean} true or false
|
|
158
73
|
* @returns boolean
|
|
159
74
|
*/
|
|
160
|
-
|
|
161
|
-
return
|
|
162
|
-
|
|
163
|
-
return __generator(this, function (_a) {
|
|
164
|
-
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
165
|
-
var chatId = _a.chatId, option = _a.option;
|
|
166
|
-
return WPP.chat.archive(chatId, option);
|
|
167
|
-
}, { chatId: chatId, option: option })];
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
};
|
|
75
|
+
async archiveChat(chatId, option = true) {
|
|
76
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, ({ chatId, option }) => WPP.chat.archive(chatId, option), { chatId, option });
|
|
77
|
+
}
|
|
171
78
|
/**
|
|
172
79
|
* Pin and Unpin chat messages with true or false
|
|
173
80
|
* @category Chat
|
|
@@ -176,28 +83,12 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
176
83
|
* @param nonExistent {boolean} Pin chat, non-existent (optional)
|
|
177
84
|
* @returns object
|
|
178
85
|
*/
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
186
|
-
var chatId = _a.chatId;
|
|
187
|
-
return WPP.chat.find(chatId);
|
|
188
|
-
}, { chatId: chatId })];
|
|
189
|
-
case 1:
|
|
190
|
-
_a.sent();
|
|
191
|
-
_a.label = 2;
|
|
192
|
-
case 2: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
193
|
-
var chatId = _a.chatId, option = _a.option;
|
|
194
|
-
return WPP.chat.pin(chatId, option);
|
|
195
|
-
}, { chatId: chatId, option: option })];
|
|
196
|
-
case 3: return [2 /*return*/, _a.sent()];
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
};
|
|
86
|
+
async pinChat(chatId, option, nonExistent) {
|
|
87
|
+
if (nonExistent) {
|
|
88
|
+
await (0, helpers_1.evaluateAndReturn)(this.page, ({ chatId }) => WPP.chat.find(chatId), { chatId });
|
|
89
|
+
}
|
|
90
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ chatId, option }) => WPP.chat.pin(chatId, option), { chatId, option });
|
|
91
|
+
}
|
|
201
92
|
/**
|
|
202
93
|
* Deletes all messages of given chat
|
|
203
94
|
* @category Chat
|
|
@@ -205,23 +96,10 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
205
96
|
* @param keepStarred Keep starred messages
|
|
206
97
|
* @returns boolean
|
|
207
98
|
*/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return __generator(this, function (_a) {
|
|
213
|
-
switch (_a.label) {
|
|
214
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
215
|
-
var chatId = _a.chatId, keepStarred = _a.keepStarred;
|
|
216
|
-
return WPP.chat.clear(chatId, keepStarred);
|
|
217
|
-
}, { chatId: chatId, keepStarred: keepStarred })];
|
|
218
|
-
case 1:
|
|
219
|
-
result = _a.sent();
|
|
220
|
-
return [2 /*return*/, result.status === 200];
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
};
|
|
99
|
+
async clearChat(chatId, keepStarred = true) {
|
|
100
|
+
const result = await (0, helpers_1.evaluateAndReturn)(this.page, ({ chatId, keepStarred }) => WPP.chat.clear(chatId, keepStarred), { chatId, keepStarred });
|
|
101
|
+
return result.status === 200;
|
|
102
|
+
}
|
|
225
103
|
/**
|
|
226
104
|
* Deletes message of given message id
|
|
227
105
|
* @category Chat
|
|
@@ -229,23 +107,10 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
229
107
|
* @param messageId The specific message id of the message to be deleted
|
|
230
108
|
* @param onlyLocal If it should only delete locally (message remains on the other recipienct's phone). Defaults to false.
|
|
231
109
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return __generator(this, function (_a) {
|
|
237
|
-
switch (_a.label) {
|
|
238
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
239
|
-
var chatId = _a.chatId, messageId = _a.messageId, onlyLocal = _a.onlyLocal, deleteMediaInDevice = _a.deleteMediaInDevice;
|
|
240
|
-
return WPP.chat.deleteMessage(chatId, messageId, deleteMediaInDevice, !onlyLocal);
|
|
241
|
-
}, { chatId: chatId, messageId: messageId, onlyLocal: onlyLocal, deleteMediaInDevice: deleteMediaInDevice })];
|
|
242
|
-
case 1:
|
|
243
|
-
_a.sent();
|
|
244
|
-
return [2 /*return*/, true];
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
};
|
|
110
|
+
async deleteMessage(chatId, messageId, onlyLocal = false, deleteMediaInDevice = true) {
|
|
111
|
+
await (0, helpers_1.evaluateAndReturn)(this.page, ({ chatId, messageId, onlyLocal, deleteMediaInDevice }) => WPP.chat.deleteMessage(chatId, messageId, deleteMediaInDevice, !onlyLocal), { chatId, messageId, onlyLocal, deleteMediaInDevice });
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
249
114
|
/**
|
|
250
115
|
* Edits message of given message id
|
|
251
116
|
* @category Chat
|
|
@@ -259,61 +124,24 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
259
124
|
* client.editMessage('true_<number>@c.us_messageId', 'new Text For Simple Message');
|
|
260
125
|
* ```
|
|
261
126
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return WPP.chat.editMessage(msgId, newText, options);
|
|
272
|
-
}, { msgId: msgId, newText: newText, options: options })];
|
|
273
|
-
case 1:
|
|
274
|
-
editResult = _a.sent();
|
|
275
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
276
|
-
var _c, _d, _e, _f;
|
|
277
|
-
var messageId = _b.messageId;
|
|
278
|
-
return __generator(this, function (_g) {
|
|
279
|
-
switch (_g.label) {
|
|
280
|
-
case 0:
|
|
281
|
-
_d = (_c = JSON).parse;
|
|
282
|
-
_f = (_e = JSON).stringify;
|
|
283
|
-
return [4 /*yield*/, WAPI.getMessageById(messageId)];
|
|
284
|
-
case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
}); }, { messageId: editResult.id })];
|
|
288
|
-
case 2:
|
|
289
|
-
result = (_a.sent());
|
|
290
|
-
if (result.body !== newText)
|
|
291
|
-
throw editResult;
|
|
292
|
-
return [2 /*return*/, result];
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
};
|
|
127
|
+
async editMessage(msgId, newText, options = {}) {
|
|
128
|
+
const editResult = await (0, helpers_1.evaluateAndReturn)(this.page, ({ msgId, newText, options }) => WPP.chat.editMessage(msgId, newText, options), { msgId, newText, options });
|
|
129
|
+
const result = (await (0, helpers_1.evaluateAndReturn)(this.page, async ({ messageId }) => {
|
|
130
|
+
return JSON.parse(JSON.stringify(await WAPI.getMessageById(messageId)));
|
|
131
|
+
}, { messageId: editResult.id }));
|
|
132
|
+
if (result.body !== newText)
|
|
133
|
+
throw editResult;
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
297
136
|
/**
|
|
298
137
|
* Stars message of given message id
|
|
299
138
|
* @category Chat
|
|
300
139
|
* @param messagesId The specific message id of the message to be starred
|
|
301
140
|
* @param star Add or remove star of the message. Defaults to true.
|
|
302
141
|
*/
|
|
303
|
-
|
|
304
|
-
return
|
|
305
|
-
|
|
306
|
-
return __generator(this, function (_a) {
|
|
307
|
-
switch (_a.label) {
|
|
308
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
309
|
-
var messagesId = _a.messagesId, star = _a.star;
|
|
310
|
-
return WAPI.starMessages(messagesId, star);
|
|
311
|
-
}, { messagesId: messagesId, star: star })];
|
|
312
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
};
|
|
142
|
+
async starMessage(messagesId, star = true) {
|
|
143
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ messagesId, star }) => WAPI.starMessages(messagesId, star), { messagesId, star });
|
|
144
|
+
}
|
|
317
145
|
/**
|
|
318
146
|
* Allow only admin to send messages with true or false
|
|
319
147
|
* @category Group
|
|
@@ -321,16 +149,9 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
321
149
|
* @param option {boolean} true or false
|
|
322
150
|
* @returns boolean
|
|
323
151
|
*/
|
|
324
|
-
|
|
325
|
-
return
|
|
326
|
-
|
|
327
|
-
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
328
|
-
var chatId = _a.chatId, option = _a.option;
|
|
329
|
-
return WAPI.setMessagesAdminsOnly(chatId, option);
|
|
330
|
-
}, { chatId: chatId, option: option })];
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
};
|
|
152
|
+
async setMessagesAdminsOnly(chatId, option) {
|
|
153
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, ({ chatId, option }) => WAPI.setMessagesAdminsOnly(chatId, option), { chatId, option });
|
|
154
|
+
}
|
|
334
155
|
/**
|
|
335
156
|
* Enable or disable temporary messages with true or false
|
|
336
157
|
* @category Chat
|
|
@@ -338,19 +159,9 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
338
159
|
* @param value true or false
|
|
339
160
|
* @returns boolean
|
|
340
161
|
*/
|
|
341
|
-
|
|
342
|
-
return
|
|
343
|
-
|
|
344
|
-
switch (_a.label) {
|
|
345
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
346
|
-
var chatOrGroupId = _a.chatOrGroupId, value = _a.value;
|
|
347
|
-
return WAPI.setTemporaryMessages(chatOrGroupId, value);
|
|
348
|
-
}, { chatOrGroupId: chatOrGroupId, value: value })];
|
|
349
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
};
|
|
162
|
+
async setTemporaryMessages(chatOrGroupId, value) {
|
|
163
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ chatOrGroupId, value }) => WAPI.setTemporaryMessages(chatOrGroupId, value), { chatOrGroupId, value });
|
|
164
|
+
}
|
|
354
165
|
/**
|
|
355
166
|
* Change limits of whatsapp web
|
|
356
167
|
* * @example
|
|
@@ -372,19 +183,8 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
372
183
|
* ```
|
|
373
184
|
* @category Chat
|
|
374
185
|
*/
|
|
375
|
-
|
|
376
|
-
return
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
380
|
-
var key = _a.key, value = _a.value;
|
|
381
|
-
return WPP.conn.setLimit(key, value);
|
|
382
|
-
}, { key: key, value: value })];
|
|
383
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
};
|
|
388
|
-
return ControlsLayer;
|
|
389
|
-
}(ui_layer_1.UILayer));
|
|
186
|
+
async setLimit(key, value) {
|
|
187
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ key, value }) => WPP.conn.setLimit(key, value), { key, value });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
390
190
|
exports.ControlsLayer = ControlsLayer;
|