whatsapp-web.js 1.23.1-alpha.0 → 1.23.1-alpha.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/README.md +4 -2
- package/index.d.ts +81 -8
- package/package.json +1 -1
- package/src/Client.js +2 -1
- package/src/structures/Message.js +10 -5
- package/src/util/Injected.js +14 -14
package/README.md
CHANGED
|
@@ -63,8 +63,8 @@ For more information on saving and restoring sessions, check out the available [
|
|
|
63
63
|
| Receive media (images/audio/video/documents) | ✅ |
|
|
64
64
|
| Send contact cards | ✅ |
|
|
65
65
|
| Send location | ✅ |
|
|
66
|
-
| Send buttons |
|
|
67
|
-
| Send lists |
|
|
66
|
+
| Send buttons | ❌ |
|
|
67
|
+
| Send lists | ❌ [(DEPRECATED)](https://www.youtube.com/watch?v=hv1R1rLeVVE) |
|
|
68
68
|
| Receive location | ✅ |
|
|
69
69
|
| Message replies | ✅ |
|
|
70
70
|
| Join groups by invite | ✅ |
|
|
@@ -81,6 +81,8 @@ For more information on saving and restoring sessions, check out the available [
|
|
|
81
81
|
| Get profile pictures | ✅ |
|
|
82
82
|
| Set user status message | ✅ |
|
|
83
83
|
| React to messages | ✅ |
|
|
84
|
+
| Vote in polls | 🔜 |
|
|
85
|
+
| Create polls | ✅ |
|
|
84
86
|
|
|
85
87
|
Something missing? Make an issue and let us know!
|
|
86
88
|
|
package/index.d.ts
CHANGED
|
@@ -981,17 +981,19 @@ declare namespace WAWebJS {
|
|
|
981
981
|
* The custom message secret, can be used as a poll ID
|
|
982
982
|
* @note It has to be a unique vector with a length of 32
|
|
983
983
|
*/
|
|
984
|
-
messageSecret:
|
|
984
|
+
messageSecret: Array<number>|undefined
|
|
985
985
|
}
|
|
986
986
|
|
|
987
987
|
/** Represents a Poll on WhatsApp */
|
|
988
|
-
export
|
|
989
|
-
pollName: string
|
|
988
|
+
export class Poll {
|
|
989
|
+
pollName: string
|
|
990
990
|
pollOptions: Array<{
|
|
991
991
|
name: string,
|
|
992
992
|
localId: number
|
|
993
|
-
}
|
|
993
|
+
}>
|
|
994
994
|
options: PollSendOptions
|
|
995
|
+
|
|
996
|
+
constructor(pollName: string, pollOptions: Array<string>, options?: PollSendOptions)
|
|
995
997
|
}
|
|
996
998
|
|
|
997
999
|
export interface Label {
|
|
@@ -1189,13 +1191,84 @@ declare namespace WAWebJS {
|
|
|
1189
1191
|
user: string,
|
|
1190
1192
|
_serialized: string,
|
|
1191
1193
|
}
|
|
1194
|
+
|
|
1195
|
+
export interface BusinessCategory {
|
|
1196
|
+
id: string,
|
|
1197
|
+
localized_display_name: string,
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
export interface BusinessHoursOfDay {
|
|
1201
|
+
mode: string,
|
|
1202
|
+
hours: number[]
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
export interface BusinessHours {
|
|
1206
|
+
config: {
|
|
1207
|
+
sun: BusinessHoursOfDay,
|
|
1208
|
+
mon: BusinessHoursOfDay,
|
|
1209
|
+
tue: BusinessHoursOfDay,
|
|
1210
|
+
wed: BusinessHoursOfDay,
|
|
1211
|
+
thu: BusinessHoursOfDay,
|
|
1212
|
+
fri: BusinessHoursOfDay,
|
|
1213
|
+
}
|
|
1214
|
+
timezone: string,
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
|
|
1192
1218
|
|
|
1193
1219
|
export interface BusinessContact extends Contact {
|
|
1194
1220
|
/**
|
|
1195
1221
|
* The contact's business profile
|
|
1196
|
-
* @todo add a more specific type for the object
|
|
1197
1222
|
*/
|
|
1198
|
-
businessProfile:
|
|
1223
|
+
businessProfile: {
|
|
1224
|
+
/** The contact's business profile id */
|
|
1225
|
+
id: ContactId,
|
|
1226
|
+
|
|
1227
|
+
/** The contact's business profile tag */
|
|
1228
|
+
tag: string,
|
|
1229
|
+
|
|
1230
|
+
/** The contact's business profile description */
|
|
1231
|
+
description: string,
|
|
1232
|
+
|
|
1233
|
+
/** The contact's business profile categories */
|
|
1234
|
+
categories: BusinessCategory[],
|
|
1235
|
+
|
|
1236
|
+
/** The contact's business profile options */
|
|
1237
|
+
profileOptions: {
|
|
1238
|
+
/** The contact's business profile commerce experience*/
|
|
1239
|
+
commerceExperience: string,
|
|
1240
|
+
|
|
1241
|
+
/** The contact's business profile cart options */
|
|
1242
|
+
cartEnabled: boolean,
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
/** The contact's business profile email */
|
|
1246
|
+
email: string,
|
|
1247
|
+
|
|
1248
|
+
/** The contact's business profile websites */
|
|
1249
|
+
website: string[],
|
|
1250
|
+
|
|
1251
|
+
/** The contact's business profile latitude */
|
|
1252
|
+
latitude: number,
|
|
1253
|
+
|
|
1254
|
+
/** The contact's business profile longitude */
|
|
1255
|
+
longitude: number,
|
|
1256
|
+
|
|
1257
|
+
/** The contact's business profile work hours*/
|
|
1258
|
+
businessHours: BusinessHours
|
|
1259
|
+
|
|
1260
|
+
/** The contact's business profile address */
|
|
1261
|
+
address: string,
|
|
1262
|
+
|
|
1263
|
+
/** The contact's business profile facebook page */
|
|
1264
|
+
fbPage: object,
|
|
1265
|
+
|
|
1266
|
+
/** Indicate if the contact's business profile linked */
|
|
1267
|
+
ifProfileLinked: boolean
|
|
1268
|
+
|
|
1269
|
+
/** The contact's business profile coverPhoto */
|
|
1270
|
+
coverPhoto: null | any,
|
|
1271
|
+
}
|
|
1199
1272
|
}
|
|
1200
1273
|
|
|
1201
1274
|
export interface PrivateContact extends Contact {
|
|
@@ -1341,7 +1414,7 @@ declare namespace WAWebJS {
|
|
|
1341
1414
|
code: number;
|
|
1342
1415
|
message: string;
|
|
1343
1416
|
isInviteV4Sent: boolean,
|
|
1344
|
-
}
|
|
1417
|
+
}
|
|
1345
1418
|
};
|
|
1346
1419
|
|
|
1347
1420
|
/** An object that handles options for adding participants */
|
|
@@ -1410,7 +1483,7 @@ declare namespace WAWebJS {
|
|
|
1410
1483
|
/** Group participants */
|
|
1411
1484
|
participants: Array<GroupParticipant>;
|
|
1412
1485
|
/** Adds a list of participants by ID to the group */
|
|
1413
|
-
addParticipants: (participantIds: string|string[], options?: AddParticipantsOptions) => Promise<
|
|
1486
|
+
addParticipants: (participantIds: string | string[], options?: AddParticipantsOptions) => Promise<{ [key: string]: AddParticipantsResult } | string>;
|
|
1414
1487
|
/** Removes a list of participants by ID to the group */
|
|
1415
1488
|
removeParticipants: (participantIds: string[]) => Promise<{ status: number }>;
|
|
1416
1489
|
/** Promotes participants by IDs to admins */
|
package/package.json
CHANGED
package/src/Client.js
CHANGED
|
@@ -43,6 +43,7 @@ const NoAuth = require('./authStrategies/NoAuth');
|
|
|
43
43
|
* @fires Client#message_create
|
|
44
44
|
* @fires Client#message_revoke_me
|
|
45
45
|
* @fires Client#message_revoke_everyone
|
|
46
|
+
* @fires Client#message_edit
|
|
46
47
|
* @fires Client#media_uploaded
|
|
47
48
|
* @fires Client#group_join
|
|
48
49
|
* @fires Client#group_leave
|
|
@@ -665,7 +666,7 @@ class Client extends EventEmitter {
|
|
|
665
666
|
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
|
666
667
|
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe && !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
|
667
668
|
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
|
668
|
-
window.Store.Msg.on('change:body', (msg, newBody, prevBody) => { window.onEditMessageEvent(window.WWebJS.getMessageModel(msg), newBody, prevBody); });
|
|
669
|
+
window.Store.Msg.on('change:body change:caption', (msg, newBody, prevBody) => { window.onEditMessageEvent(window.WWebJS.getMessageModel(msg), newBody, prevBody); });
|
|
669
670
|
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
|
670
671
|
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
|
|
671
672
|
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
|
|
@@ -431,7 +431,7 @@ class Message extends Base {
|
|
|
431
431
|
|
|
432
432
|
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
|
433
433
|
const msg = window.Store.Msg.get(msgId);
|
|
434
|
-
if (!msg) {
|
|
434
|
+
if (!msg || !msg.mediaData) {
|
|
435
435
|
return undefined;
|
|
436
436
|
}
|
|
437
437
|
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
|
@@ -534,15 +534,20 @@ class Message extends Base {
|
|
|
534
534
|
*/
|
|
535
535
|
|
|
536
536
|
/**
|
|
537
|
-
* Get information about message delivery status.
|
|
537
|
+
* Get information about message delivery status.
|
|
538
|
+
* May return null if the message does not exist or is not sent by you.
|
|
538
539
|
* @returns {Promise<?MessageInfo>}
|
|
539
540
|
*/
|
|
540
541
|
async getInfo() {
|
|
541
542
|
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
|
542
543
|
const msg = window.Store.Msg.get(msgId);
|
|
543
|
-
if (!msg) return null;
|
|
544
|
+
if (!msg || !msg.id.fromMe) return null;
|
|
544
545
|
|
|
545
|
-
return
|
|
546
|
+
return new Promise((resolve) => {
|
|
547
|
+
setTimeout(async () => {
|
|
548
|
+
resolve(await window.Store.getMsgInfo(msg.id));
|
|
549
|
+
}, (Date.now() - msg.t * 1000 < 1250) && Math.floor(Math.random() * (1200 - 1100 + 1)) + 1100 || 0);
|
|
550
|
+
});
|
|
546
551
|
}, this.id._serialized);
|
|
547
552
|
|
|
548
553
|
return info;
|
|
@@ -639,7 +644,7 @@ class Message extends Base {
|
|
|
639
644
|
let msg = window.Store.Msg.get(msgId);
|
|
640
645
|
if (!msg) return null;
|
|
641
646
|
|
|
642
|
-
let catEdit = (msg
|
|
647
|
+
let catEdit = window.Store.MsgActionChecks.canEditText(msg) || window.Store.MsgActionChecks.canEditCaption(msg);
|
|
643
648
|
if (catEdit) {
|
|
644
649
|
const msgEdit = await window.WWebJS.editMessage(msg, message, options);
|
|
645
650
|
return msgEdit.serialize();
|
package/src/util/Injected.js
CHANGED
|
@@ -23,7 +23,6 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
23
23
|
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
|
|
24
24
|
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
|
25
25
|
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
|
|
26
|
-
window.Store.MessageInfo = window.mR.findModule('sendQueryMsgInfo')[0];
|
|
27
26
|
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
|
|
28
27
|
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
|
29
28
|
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
|
@@ -58,16 +57,17 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
58
57
|
window.Store.LidUtils = window.mR.findModule('getCurrentLid')[0];
|
|
59
58
|
window.Store.WidToJid = window.mR.findModule('widToUserJid')[0];
|
|
60
59
|
window.Store.JidToWid = window.mR.findModule('userJidToUserWid')[0];
|
|
61
|
-
window.Store.Settings = {
|
|
62
|
-
...window.mR.findModule('ChatlistPanelState')[0],
|
|
63
|
-
setPushname: window.mR.findModule((m) => m.setPushname && !m.ChatlistPanelState)[0].setPushname
|
|
64
|
-
};
|
|
65
60
|
|
|
66
61
|
/* eslint-disable no-undef, no-cond-assign */
|
|
67
62
|
window.Store.QueryExist = ((m = window.mR.findModule('queryExists')[0]) ? m.queryExists : window.mR.findModule('queryExist')[0].queryWidExists);
|
|
68
63
|
window.Store.ReplyUtils = (m = window.mR.findModule('canReplyMsg')).length > 0 && m[0];
|
|
64
|
+
window.Store.getMsgInfo = (window.mR.findModule('sendQueryMsgInfo')[0] || {}).sendQueryMsgInfo || window.mR.findModule('queryMsgInfo')[0].queryMsgInfo;
|
|
69
65
|
/* eslint-enable no-undef, no-cond-assign */
|
|
70
66
|
|
|
67
|
+
window.Store.Settings = {
|
|
68
|
+
...window.mR.findModule('ChatlistPanelState')[0],
|
|
69
|
+
setPushname: window.mR.findModule((m) => m.setPushname && !m.ChatlistPanelState)[0].setPushname
|
|
70
|
+
};
|
|
71
71
|
window.Store.StickerTools = {
|
|
72
72
|
...window.mR.findModule('toWebpSticker')[0],
|
|
73
73
|
...window.mR.findModule('addWebpMetadata')[0]
|
|
@@ -128,9 +128,9 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
128
128
|
/**
|
|
129
129
|
* Target options object description
|
|
130
130
|
* @typedef {Object} TargetOptions
|
|
131
|
-
* @property {string|number}
|
|
131
|
+
* @property {string|number} module The name or a key of the target module to search
|
|
132
132
|
* @property {number} index The index value of the target module
|
|
133
|
-
* @property {string}
|
|
133
|
+
* @property {string} function The function name to get from a module
|
|
134
134
|
*/
|
|
135
135
|
|
|
136
136
|
/**
|
|
@@ -139,17 +139,17 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
139
139
|
* @param {Function} callback Modified function
|
|
140
140
|
*/
|
|
141
141
|
window.injectToFunction = (target, callback) => {
|
|
142
|
-
const module = typeof target.
|
|
143
|
-
? window.mR.findModule(target.
|
|
144
|
-
: window.mR.modules[target.
|
|
145
|
-
const originalFunction = module[target.index][target.
|
|
142
|
+
const module = typeof target.module === 'string'
|
|
143
|
+
? window.mR.findModule(target.module)
|
|
144
|
+
: window.mR.modules[target.module];
|
|
145
|
+
const originalFunction = module[target.index][target.function];
|
|
146
146
|
const modifiedFunction = (...args) => callback(originalFunction, ...args);
|
|
147
|
-
module[target.index][target.
|
|
147
|
+
module[target.index][target.function] = modifiedFunction;
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
window.injectToFunction({
|
|
150
|
+
window.injectToFunction({ module: 'mediaTypeFromProtobuf', index: 0, function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); });
|
|
151
151
|
|
|
152
|
-
window.injectToFunction({
|
|
152
|
+
window.injectToFunction({ module: 'typeAttributeFromProtobuf', index: 0, function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
exports.LoadUtils = () => {
|