whatsapp-web.js 1.30.0 → 1.30.1-alpha.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/example.js +30 -0
- package/index.d.ts +4 -6
- package/package.json +1 -1
- package/src/Client.js +3 -1
- package/src/structures/Message.js +2 -12
- package/src/util/Injected/Store.js +5 -1
- package/src/util/Injected/Utils.js +16 -9
package/example.js
CHANGED
|
@@ -470,6 +470,36 @@ client.on('message', async msg => {
|
|
|
470
470
|
console.log(statuses);
|
|
471
471
|
const chat = await statuses[0]?.getChat(); // Get user chat of a first status
|
|
472
472
|
console.log(chat);
|
|
473
|
+
} else if (msg.body === '!sendMediaHD' && msg.hasQuotedMsg) {
|
|
474
|
+
const quotedMsg = await msg.getQuotedMessage();
|
|
475
|
+
if (quotedMsg.hasMedia) {
|
|
476
|
+
const media = await quotedMsg.downloadMedia();
|
|
477
|
+
await client.sendMessage(msg.from, media, { sendMediaAsHd: true });
|
|
478
|
+
}
|
|
479
|
+
} else if (msg.body === '!parseVCard') {
|
|
480
|
+
const vCard =
|
|
481
|
+
'BEGIN:VCARD\n' +
|
|
482
|
+
'VERSION:3.0\n' +
|
|
483
|
+
'FN:John Doe\n' +
|
|
484
|
+
'ORG:Microsoft;\n' +
|
|
485
|
+
'EMAIL;type=INTERNET:john.doe@gmail.com\n' +
|
|
486
|
+
'URL:www.johndoe.com\n' +
|
|
487
|
+
'TEL;type=CELL;type=VOICE;waid=18006427676:+1 (800) 642 7676\n' +
|
|
488
|
+
'END:VCARD';
|
|
489
|
+
const vCardExtended =
|
|
490
|
+
'BEGIN:VCARD\n' +
|
|
491
|
+
'VERSION:3.0\n' +
|
|
492
|
+
'FN:John Doe\n' +
|
|
493
|
+
'ORG:Microsoft;\n' +
|
|
494
|
+
'item1.TEL:+1 (800) 642 7676\n' +
|
|
495
|
+
'item1.X-ABLabel:USA Customer Service\n' +
|
|
496
|
+
'item2.TEL:+55 11 4706 0900\n' +
|
|
497
|
+
'item2.X-ABLabel:Brazil Customer Service\n' +
|
|
498
|
+
'PHOTO;BASE64:here you can paste a binary data of a contact photo in Base64 encoding\n' +
|
|
499
|
+
'END:VCARD';
|
|
500
|
+
const userId = 'XXXXXXXXXX@c.us';
|
|
501
|
+
await client.sendMessage(userId, vCard);
|
|
502
|
+
await client.sendMessage(userId, vCardExtended);
|
|
473
503
|
} else if (msg.body === '!changeSync') {
|
|
474
504
|
// NOTE: this action will take effect after you restart the client.
|
|
475
505
|
const backgroundSync = await client.setBackgroundSync(true);
|
package/index.d.ts
CHANGED
|
@@ -991,15 +991,11 @@ declare namespace WAWebJS {
|
|
|
991
991
|
/** MediaKey that represents the sticker 'ID' */
|
|
992
992
|
mediaKey?: string,
|
|
993
993
|
/** Indicates the mentions in the message body. */
|
|
994
|
-
mentionedIds:
|
|
994
|
+
mentionedIds: string[],
|
|
995
995
|
/** Indicates whether there are group mentions in the message body */
|
|
996
996
|
groupMentions: {
|
|
997
997
|
groupSubject: string;
|
|
998
|
-
groupJid:
|
|
999
|
-
server: string;
|
|
1000
|
-
user: string;
|
|
1001
|
-
_serialized: string;
|
|
1002
|
-
};
|
|
998
|
+
groupJid: string;
|
|
1003
999
|
}[],
|
|
1004
1000
|
/** Unix timestamp for when the message was created */
|
|
1005
1001
|
timestamp: number,
|
|
@@ -1229,6 +1225,8 @@ declare namespace WAWebJS {
|
|
|
1229
1225
|
sendMediaAsSticker?: boolean
|
|
1230
1226
|
/** Send media as document */
|
|
1231
1227
|
sendMediaAsDocument?: boolean
|
|
1228
|
+
/** Send media as quality HD */
|
|
1229
|
+
sendMediaAsHd?: boolean
|
|
1232
1230
|
/** Send photo/video as a view once message */
|
|
1233
1231
|
isViewOnce?: boolean
|
|
1234
1232
|
/** Automatically parse vCards and send them as contacts */
|
package/package.json
CHANGED
package/src/Client.js
CHANGED
|
@@ -840,6 +840,7 @@ class Client extends EventEmitter {
|
|
|
840
840
|
* @property {boolean} [sendVideoAsGif=false] - Send video as gif
|
|
841
841
|
* @property {boolean} [sendMediaAsSticker=false] - Send media as a sticker
|
|
842
842
|
* @property {boolean} [sendMediaAsDocument=false] - Send media as a document
|
|
843
|
+
* @property {boolean} [sendMediaAsHd=false] - Send image as quality HD
|
|
843
844
|
* @property {boolean} [isViewOnce=false] - Send photo/video as a view once message
|
|
844
845
|
* @property {boolean} [parseVCards=true] - Automatically parse vCards and send them as contacts
|
|
845
846
|
* @property {string} [caption] - Image or video caption
|
|
@@ -894,6 +895,7 @@ class Client extends EventEmitter {
|
|
|
894
895
|
sendVideoAsGif: options.sendVideoAsGif,
|
|
895
896
|
sendMediaAsSticker: options.sendMediaAsSticker,
|
|
896
897
|
sendMediaAsDocument: options.sendMediaAsDocument,
|
|
898
|
+
sendMediaAsHd: options.sendMediaAsHd,
|
|
897
899
|
caption: options.caption,
|
|
898
900
|
quotedMessageId: options.quotedMessageId,
|
|
899
901
|
parseVCards: options.parseVCards !== false,
|
|
@@ -2145,7 +2147,7 @@ class Client extends EventEmitter {
|
|
|
2145
2147
|
return false;
|
|
2146
2148
|
}, chatId);
|
|
2147
2149
|
}
|
|
2148
|
-
|
|
2150
|
+
|
|
2149
2151
|
/**
|
|
2150
2152
|
* Save new contact to user's addressbook or edit the existing one
|
|
2151
2153
|
* @param {string} phoneNumber The contact's phone number in a format "17182222222", where "1" is a country code
|
|
@@ -186,26 +186,16 @@ class Message extends Base {
|
|
|
186
186
|
toId: typeof data.to === 'object' && '_serialized' in data.to ? data.to._serialized : data.to
|
|
187
187
|
} : undefined;
|
|
188
188
|
|
|
189
|
-
/**
|
|
190
|
-
* @typedef {Object} Mention
|
|
191
|
-
* @property {string} server
|
|
192
|
-
* @property {string} user
|
|
193
|
-
* @property {string} _serialized
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
189
|
/**
|
|
197
190
|
* Indicates the mentions in the message body.
|
|
198
|
-
* @type {
|
|
191
|
+
* @type {string[]}
|
|
199
192
|
*/
|
|
200
193
|
this.mentionedIds = data.mentionedJidList || [];
|
|
201
194
|
|
|
202
195
|
/**
|
|
203
196
|
* @typedef {Object} GroupMention
|
|
204
197
|
* @property {string} groupSubject The name of the group
|
|
205
|
-
* @property {
|
|
206
|
-
* @property {string} groupJid.server
|
|
207
|
-
* @property {string} groupJid.user
|
|
208
|
-
* @property {string} groupJid._serialized
|
|
198
|
+
* @property {string} groupJid The group ID
|
|
209
199
|
*/
|
|
210
200
|
|
|
211
201
|
/**
|
|
@@ -67,7 +67,6 @@ exports.ExposeStore = () => {
|
|
|
67
67
|
window.Store.ContactMethods = window.require('WAWebContactGetters');
|
|
68
68
|
window.Store.UserConstructor = window.require('WAWebWid');
|
|
69
69
|
window.Store.Validators = window.require('WALinkify');
|
|
70
|
-
window.Store.VCard = window.require('WAWebFrontendVcardUtils');
|
|
71
70
|
window.Store.WidFactory = window.require('WAWebWidFactory');
|
|
72
71
|
window.Store.ProfilePic = window.require('WAWebContactProfilePicThumbBridge');
|
|
73
72
|
window.Store.PresenceUtils = window.require('WAWebPresenceChatAction');
|
|
@@ -112,6 +111,11 @@ exports.ExposeStore = () => {
|
|
|
112
111
|
window.Store.ForwardUtils = {
|
|
113
112
|
...window.require('WAWebForwardMessagesToChat')
|
|
114
113
|
};
|
|
114
|
+
window.Store.VCard = {
|
|
115
|
+
...window.require('WAWebFrontendVcardUtils'),
|
|
116
|
+
...window.require('WAWebVcardParsingUtils'),
|
|
117
|
+
...window.require('WAWebVcardGetNameFromParsed')
|
|
118
|
+
};
|
|
115
119
|
window.Store.StickerTools = {
|
|
116
120
|
...window.require('WAWebImageUtils'),
|
|
117
121
|
...window.require('WAWebAddWebpMetadata')
|
|
@@ -34,6 +34,7 @@ exports.LoadUtils = () => {
|
|
|
34
34
|
forceGif: options.sendVideoAsGif,
|
|
35
35
|
forceVoice: options.sendAudioAsVoice,
|
|
36
36
|
forceDocument: options.sendMediaAsDocument,
|
|
37
|
+
forceMediaHd: options.sendMediaAsHd,
|
|
37
38
|
sendToChannel: isChannel
|
|
38
39
|
});
|
|
39
40
|
mediaOptions.caption = options.caption;
|
|
@@ -135,11 +136,12 @@ exports.LoadUtils = () => {
|
|
|
135
136
|
vcardOptions = {
|
|
136
137
|
type: 'multi_vcard',
|
|
137
138
|
vcardList: vcards,
|
|
138
|
-
body:
|
|
139
|
+
body: null
|
|
139
140
|
};
|
|
140
141
|
delete options.contactCardList;
|
|
141
142
|
} else if (options.parseVCards && typeof (content) === 'string' && content.startsWith('BEGIN:VCARD')) {
|
|
142
143
|
delete options.parseVCards;
|
|
144
|
+
delete options.linkPreview;
|
|
143
145
|
try {
|
|
144
146
|
const parsed = window.Store.VCard.parseVcard(content);
|
|
145
147
|
if (parsed) {
|
|
@@ -362,16 +364,21 @@ exports.LoadUtils = () => {
|
|
|
362
364
|
};
|
|
363
365
|
};
|
|
364
366
|
|
|
365
|
-
window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, sendToChannel }) => {
|
|
367
|
+
window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, forceMediaHd, sendToChannel }) => {
|
|
366
368
|
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
|
367
369
|
const opaqueData = await window.Store.OpaqueData.createFromData(file, file.type);
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
const mediaParams = {
|
|
371
|
+
asSticker: forceSticker,
|
|
372
|
+
asGif: forceGif,
|
|
373
|
+
isPtt: forceVoice,
|
|
374
|
+
asDocument: forceDocument
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
if (forceMediaHd && file.type.indexOf('image/') === 0) {
|
|
378
|
+
mediaParams.maxDimension = 2560;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const mediaPrep = window.Store.MediaPrep.prepRawMedia(opaqueData, mediaParams);
|
|
375
382
|
const mediaData = await mediaPrep.waitForPrep();
|
|
376
383
|
const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);
|
|
377
384
|
const mediaType = window.Store.MediaTypes.msgToMediaType({
|