riftcore 1.4.6 → 1.4.7
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 +1 -0
- package/WAProto/index.js +119389 -86758
- package/example.js +13 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +8 -25
- package/lib/Socket/chats.d.ts +28 -215
- package/lib/Socket/chats.js +49 -155
- package/lib/Socket/{luxu.d.ts → erlanggaofficial.d.ts} +14 -82
- package/lib/Socket/{luxu.js → erlanggaofficial.js} +10 -178
- package/lib/Socket/groups.js +18 -82
- package/lib/Socket/index.js +0 -1
- package/lib/Socket/messages-send.d.ts +2 -2
- package/lib/Socket/messages-send.js +277 -373
- package/lib/Socket/newsletter.js +21 -99
- package/lib/Socket/socket.d.ts +0 -1
- package/lib/Socket/socket.js +30 -136
- package/lib/Store/make-in-memory-store.js +1 -1
- package/lib/Types/Newsletter.d.ts +86 -97
- package/lib/Types/Newsletter.js +32 -38
- package/lib/Utils/generics.js +33 -65
- package/lib/Utils/messages-media.js +57 -145
- package/lib/Utils/messages.js +14 -26
- package/lib/Utils/signal.js +46 -48
- package/lib/Utils/use-multi-file-auth-state.js +6 -45
- package/lib/Utils/validate-connection.js +66 -90
- package/lib/WABinary/constants.d.ts +24 -27
- package/lib/WABinary/encode.js +123 -160
- package/lib/WABinary/generic-utils.d.ts +1 -2
- package/lib/WABinary/generic-utils.js +43 -123
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/index.js +6 -6
- package/package.json +105 -99
- package/WAProto/fix-import.js +0 -29
- package/engine-requirements.js +0 -10
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
// Xzzzzz
|
|
1
2
|
import { proto } from '../../WAProto';
|
|
2
3
|
|
|
3
|
-
declare namespace
|
|
4
|
+
declare namespace erlangga {
|
|
4
5
|
interface MediaUploadOptions {
|
|
5
6
|
fileEncSha256?: Buffer;
|
|
6
7
|
mediaType?: string;
|
|
@@ -77,12 +78,11 @@ declare namespace imup {
|
|
|
77
78
|
document?: Buffer;
|
|
78
79
|
mimetype?: string;
|
|
79
80
|
fileName?: string;
|
|
80
|
-
jpegThumbnail?: Buffer;
|
|
81
|
+
jpegThumbnail?: Buffer; // Hanya Buffer saja
|
|
81
82
|
contextInfo?: {
|
|
82
83
|
mentionedJid?: string[];
|
|
83
84
|
forwardingScore?: number;
|
|
84
85
|
isForwarded?: boolean;
|
|
85
|
-
forwardedNewsletterMessageInfo?: proto.Message.ContextInfo.ForwardedNewsletterMessageInfo;
|
|
86
86
|
externalAdReply?: {
|
|
87
87
|
title?: string;
|
|
88
88
|
body?: string;
|
|
@@ -145,43 +145,6 @@ declare namespace imup {
|
|
|
145
145
|
interface PollResultMessage {
|
|
146
146
|
name: string;
|
|
147
147
|
pollVotes: PollVote[];
|
|
148
|
-
newsletter?: {
|
|
149
|
-
newsletterName: string;
|
|
150
|
-
newsletterJid: string;
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
interface StatusMention {
|
|
155
|
-
message?: any;
|
|
156
|
-
image?: string | Buffer | { url: string };
|
|
157
|
-
video?: string | Buffer | { url: string };
|
|
158
|
-
text?: string;
|
|
159
|
-
caption?: string;
|
|
160
|
-
document?: string | Buffer | { url: string };
|
|
161
|
-
mentions: string[];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
interface OrderMessage {
|
|
165
|
-
thumbnail?: Buffer | string,
|
|
166
|
-
itemCount?: string | number,
|
|
167
|
-
message: string,
|
|
168
|
-
orderTitle: string,
|
|
169
|
-
totalAmount1000?: string | number,
|
|
170
|
-
totalCurrencyCode?: string
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
interface GroupStatus {
|
|
174
|
-
message?: any;
|
|
175
|
-
image?: string | Buffer | { url: string };
|
|
176
|
-
video?: string | Buffer | { url: string };
|
|
177
|
-
text?: string;
|
|
178
|
-
caption?: string;
|
|
179
|
-
document?: string | Buffer | { url: string };
|
|
180
|
-
[key: string]: any;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
interface GroupLabel {
|
|
184
|
-
labelText: string;
|
|
185
148
|
}
|
|
186
149
|
|
|
187
150
|
interface MessageContent {
|
|
@@ -191,9 +154,6 @@ declare namespace imup {
|
|
|
191
154
|
albumMessage?: AlbumItem[];
|
|
192
155
|
eventMessage?: EventMessage;
|
|
193
156
|
pollResultMessage?: PollResultMessage;
|
|
194
|
-
groupStatus?: GroupStatus;
|
|
195
|
-
orderMessage?: OrderMessage;
|
|
196
|
-
groupLabel?: GroupLabel;
|
|
197
157
|
sender?: string;
|
|
198
158
|
}
|
|
199
159
|
|
|
@@ -211,77 +171,49 @@ declare namespace imup {
|
|
|
211
171
|
}
|
|
212
172
|
}
|
|
213
173
|
|
|
214
|
-
declare class
|
|
174
|
+
declare class erlangga {
|
|
215
175
|
constructor(
|
|
216
|
-
utils:
|
|
217
|
-
waUploadToServer:
|
|
176
|
+
utils: erlangga.Utils,
|
|
177
|
+
waUploadToServer: erlangga.WAMediaUploadFunction,
|
|
218
178
|
relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
|
|
219
179
|
);
|
|
220
180
|
|
|
221
|
-
detectType(content:
|
|
181
|
+
detectType(content: erlangga.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | null;
|
|
222
182
|
|
|
223
183
|
handlePayment(
|
|
224
|
-
content: { requestPaymentMessage:
|
|
184
|
+
content: { requestPaymentMessage: erlangga.PaymentMessage },
|
|
225
185
|
quoted?: proto.IWebMessageInfo
|
|
226
186
|
): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
|
|
227
187
|
|
|
228
188
|
handleProduct(
|
|
229
|
-
content: { productMessage:
|
|
189
|
+
content: { productMessage: erlangga.ProductMessage },
|
|
230
190
|
jid: string,
|
|
231
191
|
quoted?: proto.IWebMessageInfo
|
|
232
192
|
): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
|
|
233
193
|
|
|
234
194
|
handleInteractive(
|
|
235
|
-
content: { interactiveMessage:
|
|
195
|
+
content: { interactiveMessage: erlangga.InteractiveMessage },
|
|
236
196
|
jid: string,
|
|
237
197
|
quoted?: proto.IWebMessageInfo
|
|
238
198
|
): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
|
|
239
199
|
|
|
240
200
|
handleAlbum(
|
|
241
|
-
content: { albumMessage:
|
|
201
|
+
content: { albumMessage: erlangga.AlbumItem[] },
|
|
242
202
|
jid: string,
|
|
243
203
|
quoted?: proto.IWebMessageInfo
|
|
244
204
|
): Promise<any>;
|
|
245
205
|
|
|
246
206
|
handleEvent(
|
|
247
|
-
content: { eventMessage:
|
|
207
|
+
content: { eventMessage: erlangga.EventMessage },
|
|
248
208
|
jid: string,
|
|
249
209
|
quoted?: proto.IWebMessageInfo
|
|
250
210
|
): Promise<any>;
|
|
251
211
|
|
|
252
212
|
handlePollResult(
|
|
253
|
-
content: { pollResultMessage:
|
|
213
|
+
content: { pollResultMessage: erlangga.PollResultMessage },
|
|
254
214
|
jid: string,
|
|
255
215
|
quoted?: proto.IWebMessageInfo
|
|
256
216
|
): Promise<any>;
|
|
257
|
-
|
|
258
|
-
handleStMention(
|
|
259
|
-
content: { statusMentionMessage: imup.StatusMentionMessage },
|
|
260
|
-
jid: string,
|
|
261
|
-
quoted?: proto.IWebMessageInfo
|
|
262
|
-
): Promise<any>;
|
|
263
|
-
|
|
264
|
-
handleOrderMessage(
|
|
265
|
-
content: { orderMessage: imup.OrderMessage },
|
|
266
|
-
jid: string,
|
|
267
|
-
quoted?: proto.IWebMessageInfo
|
|
268
|
-
): Promise<any>;
|
|
269
|
-
|
|
270
|
-
handleGroupStory(
|
|
271
|
-
content: { groupStatus: imup.GroupStatus },
|
|
272
|
-
jid: string,
|
|
273
|
-
quoted?: proto.IWebMessageInfo
|
|
274
|
-
): Promise<any>;
|
|
275
|
-
|
|
276
|
-
handleGbLabel(
|
|
277
|
-
content: { groupLabel: imup.GroupLabel },
|
|
278
|
-
jid: string,
|
|
279
|
-
): Promise<any>;
|
|
280
|
-
|
|
281
|
-
handleStatusMention(
|
|
282
|
-
content: { statusMention: imup.StatusMention },
|
|
283
|
-
jid: string,
|
|
284
|
-
): Promise<any>;
|
|
285
217
|
}
|
|
286
218
|
|
|
287
|
-
export =
|
|
219
|
+
export = erlangga;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
const WAProto = require('../../WAProto').proto;
|
|
2
|
-
const Utils_1 = require('../Utils');
|
|
3
4
|
const crypto = require('crypto');
|
|
4
5
|
|
|
5
|
-
class
|
|
6
|
+
class erlangga {
|
|
6
7
|
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
7
8
|
this.utils = utils;
|
|
8
9
|
this.relayMessage = relayMessageFn
|
|
@@ -15,11 +16,7 @@ class imup {
|
|
|
15
16
|
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
16
17
|
if (content.albumMessage) return 'ALBUM';
|
|
17
18
|
if (content.eventMessage) return 'EVENT';
|
|
18
|
-
if (content.pollResultMessage) return 'POLL_RESULT'
|
|
19
|
-
if (content.orderMessage) return 'ORDER';
|
|
20
|
-
if (content.groupStatus) return 'GROUP_STATUS';
|
|
21
|
-
if (content.groupLabel) return 'GROUP_LABEL';
|
|
22
|
-
if (content.statusMention) return 'STATUS_MENTION';
|
|
19
|
+
if (content.pollResultMessage) return 'POLL_RESULT'
|
|
23
20
|
return null;
|
|
24
21
|
}
|
|
25
22
|
|
|
@@ -325,8 +322,8 @@ class imup {
|
|
|
325
322
|
newsletterName: `WhatsApp`,
|
|
326
323
|
contentType: 1,
|
|
327
324
|
timestamp: new Date().toISOString(),
|
|
328
|
-
senderName: "
|
|
329
|
-
|
|
325
|
+
senderName: "ridzcoder",
|
|
326
|
+
content: "Text Message",
|
|
330
327
|
priority: "high",
|
|
331
328
|
status: "sent",
|
|
332
329
|
};
|
|
@@ -385,7 +382,7 @@ class imup {
|
|
|
385
382
|
participant: jid,
|
|
386
383
|
remoteJid: "status@broadcast",
|
|
387
384
|
forwardedNewsletterMessageInfo: {
|
|
388
|
-
newsletterName: "Airbyte
|
|
385
|
+
newsletterName: "Airbyte Synegetic Labs",
|
|
389
386
|
newsletterJid: "120363404529319592@newsletter",
|
|
390
387
|
serverMessageId: 1
|
|
391
388
|
}
|
|
@@ -415,6 +412,7 @@ class imup {
|
|
|
415
412
|
|
|
416
413
|
async handlePollResult(content, jid, quoted) {
|
|
417
414
|
const pollData = content.pollResultMessage;
|
|
415
|
+
|
|
418
416
|
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
419
417
|
pollResultSnapshotMessage: {
|
|
420
418
|
name: pollData.name,
|
|
@@ -423,17 +421,7 @@ class imup {
|
|
|
423
421
|
optionVoteCount: typeof vote.optionVoteCount === 'number'
|
|
424
422
|
? vote.optionVoteCount.toString()
|
|
425
423
|
: vote.optionVoteCount
|
|
426
|
-
}))
|
|
427
|
-
contextInfo: {
|
|
428
|
-
isForwarded: true,
|
|
429
|
-
forwardingScore: 1,
|
|
430
|
-
forwardedNewsletterMessageInfo: {
|
|
431
|
-
newsletterName: pollData.newsletter.newsletterName || "120363405241240098@newsletter",
|
|
432
|
-
newsletterJid: pollData.newsletter.newsletterJid || "Newsletter",
|
|
433
|
-
serverMessageId: 1000,
|
|
434
|
-
contentType: "UPDATE"
|
|
435
|
-
}
|
|
436
|
-
}
|
|
424
|
+
}))
|
|
437
425
|
}
|
|
438
426
|
}, {
|
|
439
427
|
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
@@ -446,162 +434,6 @@ class imup {
|
|
|
446
434
|
|
|
447
435
|
return msg;
|
|
448
436
|
}
|
|
449
|
-
|
|
450
|
-
async handleOrderMessage(content, jid, quoted) {
|
|
451
|
-
const orderData = content.orderMessage;
|
|
452
|
-
|
|
453
|
-
const Haha = await this.utils.generateWAMessageFromContent(jid, {
|
|
454
|
-
orderMessage: {
|
|
455
|
-
orderId: "7EPPELI25022008",
|
|
456
|
-
thumbnail: orderData.thumbnail || null,
|
|
457
|
-
itemCount: orderData.itemCount || 0,
|
|
458
|
-
status: "ACCEPTED",
|
|
459
|
-
surface: "CATALOG",
|
|
460
|
-
message: orderData.message,
|
|
461
|
-
orderTitle: orderData.orderTitle,
|
|
462
|
-
sellerJid: "0@whatsapp.net",
|
|
463
|
-
token: "7EPPELI_EXAMPLE_TOKEN",
|
|
464
|
-
totalAmount1000: orderData.totalAmount1000 || 0,
|
|
465
|
-
totalCurrencyCode: orderData.totalCurrencyCode || "IDR",
|
|
466
|
-
messageVersion: 2
|
|
467
|
-
}
|
|
468
|
-
}, { quoted:quoted });
|
|
469
|
-
|
|
470
|
-
await this.relayMessage(jid, Haha.message, {});
|
|
471
|
-
return Haha;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
async handleGroupStory(content, jid, quoted) {
|
|
475
|
-
const storyData = content.groupStatus;
|
|
476
|
-
let messageContent;
|
|
477
|
-
|
|
478
|
-
if (storyData.message) {
|
|
479
|
-
messageContent = storyData;
|
|
480
|
-
} else {
|
|
481
|
-
if (typeof this.utils?.generateWAMessageContent === "function") {
|
|
482
|
-
messageContent = await this.utils.generateWAMessageContent(storyData, {
|
|
483
|
-
upload: this.waUploadToServer
|
|
484
|
-
});
|
|
485
|
-
} else if (typeof this.utils?.generateWAMessageContent === "function") {
|
|
486
|
-
messageContent = await this.utils.generateWAMessageContent(storyData, {
|
|
487
|
-
upload: this.waUploadToServer
|
|
488
|
-
});
|
|
489
|
-
} else if (typeof this.utils?.prepareMessageContent === "function") {
|
|
490
|
-
messageContent = await this.utils.prepareMessageContent(storyData, {
|
|
491
|
-
upload: this.waUploadToServer
|
|
492
|
-
});
|
|
493
|
-
} else {
|
|
494
|
-
messageContent = await Utils_1.generateWAMessageContent(storyData, {
|
|
495
|
-
upload: this.waUploadToServer
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
let msg = {
|
|
501
|
-
message: {
|
|
502
|
-
groupStatusMessageV2: {
|
|
503
|
-
message: messageContent.message || messageContent
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
return await this.relayMessage(jid, msg.message, {
|
|
509
|
-
messageId: this.utils.generateMessageID()
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
async handleGbLabel(content, jid) {
|
|
513
|
-
const x = content.groupLabel;
|
|
514
|
-
if (!jid.endsWith('@g.us')) {
|
|
515
|
-
throw new Error('group required!')
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
const msg = this.utils.generateWAMessageFromContent(jid, {
|
|
519
|
-
protocolMessage: {
|
|
520
|
-
type: "GROUP_MEMBER_LABEL_CHANGE",
|
|
521
|
-
memberLabel: {
|
|
522
|
-
label: x.labelText.slice(0, 30)
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}, {});
|
|
526
|
-
await this.relayMessage(jid, msg.message, {
|
|
527
|
-
additionalNodes: [
|
|
528
|
-
{
|
|
529
|
-
tag: 'meta',
|
|
530
|
-
attrs: {
|
|
531
|
-
tag_reason: 'user_update',
|
|
532
|
-
appdata: 'member_tag'
|
|
533
|
-
},
|
|
534
|
-
content: undefined
|
|
535
|
-
}
|
|
536
|
-
]
|
|
537
|
-
})
|
|
538
|
-
}
|
|
539
|
-
async handleStatusMention(content, jid) {
|
|
540
|
-
const z = content.statusMention;
|
|
541
|
-
let messageContent;
|
|
542
|
-
|
|
543
|
-
if (z.message) {
|
|
544
|
-
messageContent = z;
|
|
545
|
-
} else {
|
|
546
|
-
if (typeof this.utils?.generateWAMessageContent === "function") {
|
|
547
|
-
messageContent = await this.utils.generateWAMessageContent(z, {
|
|
548
|
-
upload: this.waUploadToServer
|
|
549
|
-
});
|
|
550
|
-
} else if (typeof this.utils?.generateWAMessageContent === "function") {
|
|
551
|
-
messageContent = await this.utils.generateWAMessageContent(z, {
|
|
552
|
-
upload: this.waUploadToServer
|
|
553
|
-
});
|
|
554
|
-
} else if (typeof this.utils?.prepareMessageContent === "function") {
|
|
555
|
-
messageContent = await this.utils.prepareMessageContent(z, {
|
|
556
|
-
upload: this.waUploadToServer
|
|
557
|
-
});
|
|
558
|
-
} else {
|
|
559
|
-
messageContent = await Utils_1.generateWAMessageContent(z, {
|
|
560
|
-
upload: this.waUploadToServer
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
let msg = messageContent.message || messageContent;
|
|
566
|
-
|
|
567
|
-
await this.relayMessage("status@broadcast", msg.message, {
|
|
568
|
-
statusJidList: [...z.mentions, this.authState.creds.me],
|
|
569
|
-
additionalAttributes: [
|
|
570
|
-
{
|
|
571
|
-
tag: "meta",
|
|
572
|
-
attrs: {},
|
|
573
|
-
content: [
|
|
574
|
-
{
|
|
575
|
-
tag: "mentioned_users",
|
|
576
|
-
attrs: {},
|
|
577
|
-
content: z.mentions.map(jid => ({
|
|
578
|
-
tag: "to",
|
|
579
|
-
attrs: { jid }
|
|
580
|
-
}))
|
|
581
|
-
}
|
|
582
|
-
]
|
|
583
|
-
}
|
|
584
|
-
]
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
let tagged;
|
|
588
|
-
for (const jids of z.mentions) {
|
|
589
|
-
await this.relayMessage(jids, {
|
|
590
|
-
protocolMessage: {
|
|
591
|
-
type: WaProto.Message.ProtocolMessage.Type.STATUS_MENTION_MESSAGE,
|
|
592
|
-
key: msg.key
|
|
593
|
-
}
|
|
594
|
-
}, {
|
|
595
|
-
additionalAttributes: [
|
|
596
|
-
{
|
|
597
|
-
tag: "meta",
|
|
598
|
-
attrs: { is_status_mentioned: "true" }
|
|
599
|
-
}
|
|
600
|
-
]
|
|
601
|
-
})
|
|
602
|
-
}
|
|
603
|
-
return tagged;
|
|
604
|
-
}
|
|
605
437
|
}
|
|
606
438
|
|
|
607
|
-
module.exports =
|
|
439
|
+
module.exports = erlangga;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -23,70 +23,6 @@ const makeGroupsSocket = (config) => {
|
|
|
23
23
|
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
24
24
|
return (0, exports.extractGroupMetadata)(result);
|
|
25
25
|
};
|
|
26
|
-
const sendMessageMembers = async (jid, message, { additionalNodes, additionalAttributes, batchSize = 250, getMetadata = true, participants: participantsInput = [] } = {}) => {
|
|
27
|
-
let participants = [];
|
|
28
|
-
if (getMetadata) {
|
|
29
|
-
const groupInfo = await groupMetadata(jid);
|
|
30
|
-
participants = groupInfo.participants.filter(p => p && (p.admin === null || typeof p.admin === 'undefined' || p.admin === false)).map(p => p.phoneNumber || p.id).filter(id => id && typeof id === 'string' && !id.includes('@lid'));
|
|
31
|
-
} else {
|
|
32
|
-
participants = participantsInput.filter(id => id && typeof id === 'string' && !id.includes('@lid'));
|
|
33
|
-
}
|
|
34
|
-
if (!participants.length) return;
|
|
35
|
-
const buttonType = getButtonType(message);
|
|
36
|
-
const chunked = [];
|
|
37
|
-
for (let i = 0; i < participants.length; i += batchSize) {
|
|
38
|
-
chunked.push(participants.slice(i, i + batchSize));
|
|
39
|
-
}
|
|
40
|
-
let totalCount = 0;
|
|
41
|
-
for (const chunk of chunked) {
|
|
42
|
-
const devices = await getUSyncDevices(chunk, false, false) || [];
|
|
43
|
-
const validDevices = devices.filter(j => {
|
|
44
|
-
const raw = j.device;
|
|
45
|
-
const d = typeof raw === 'string' ? parseInt(raw, 10) : raw;
|
|
46
|
-
return j.user && (d == null || (Number.isInteger(d) && d >= 0 && d < 99));
|
|
47
|
-
});
|
|
48
|
-
const mappedDevices = validDevices.map(j => {
|
|
49
|
-
const raw = j.device;
|
|
50
|
-
const d = typeof raw === 'string' ? parseInt(raw, 10) : raw;
|
|
51
|
-
return (d == null || d === 0) ? `${j.user}@s.whatsapp.net` : `${j.user}:${d}@s.whatsapp.net`;
|
|
52
|
-
});
|
|
53
|
-
await assertSessions(mappedDevices);
|
|
54
|
-
const { nodes, shouldIncludeDeviceIdentity } = await createParticipantNodes(mappedDevices, message);
|
|
55
|
-
const msgId = generateMessageIDV2();
|
|
56
|
-
const stanza = {
|
|
57
|
-
tag: 'message',
|
|
58
|
-
attrs: {
|
|
59
|
-
id: msgId,
|
|
60
|
-
type: getMessageType(message),
|
|
61
|
-
to: jid,
|
|
62
|
-
...(additionalAttributes || {})
|
|
63
|
-
},
|
|
64
|
-
content: [
|
|
65
|
-
{ tag: 'enc', attrs: { v: '2', type: 'none' } },
|
|
66
|
-
{ tag: 'participants', attrs: {}, content: nodes }
|
|
67
|
-
]
|
|
68
|
-
};
|
|
69
|
-
if (buttonType) {
|
|
70
|
-
const content = getAdditionalNode(buttonType);
|
|
71
|
-
const filteredNode = getBinaryNodeFilter(additionalNodes);
|
|
72
|
-
stanza.content.push(...(filteredNode ? additionalNodes : content));
|
|
73
|
-
}
|
|
74
|
-
if (additionalNodes?.length) {
|
|
75
|
-
stanza.content.push(...additionalNodes);
|
|
76
|
-
}
|
|
77
|
-
if (shouldIncludeDeviceIdentity) {
|
|
78
|
-
stanza.content.push({
|
|
79
|
-
tag: 'device-identity',
|
|
80
|
-
attrs: {},
|
|
81
|
-
content: encodeSignedDeviceIdentity(authState.creds.account, true)
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
const res = await query(stanza);
|
|
85
|
-
const count = Number(res?.attrs?.count || 0);
|
|
86
|
-
totalCount += count;
|
|
87
|
-
}
|
|
88
|
-
return totalCount
|
|
89
|
-
};
|
|
90
26
|
const groupFetchAllParticipating = async () => {
|
|
91
27
|
const result = await query({
|
|
92
28
|
tag: 'iq',
|
|
@@ -327,46 +263,46 @@ const makeGroupsSocket = (config) => {
|
|
|
327
263
|
exports.makeGroupsSocket = makeGroupsSocket;
|
|
328
264
|
const extractGroupMetadata = (result) => {
|
|
329
265
|
var _a, _b;
|
|
330
|
-
const group = WABinary_1.getBinaryNodeChild(result, 'group');
|
|
331
|
-
const descChild = WABinary_1.getBinaryNodeChild(group, 'description');
|
|
266
|
+
const group = (0, WABinary_1.getBinaryNodeChild)(result, 'group');
|
|
267
|
+
const descChild = (0, WABinary_1.getBinaryNodeChild)(group, 'description');
|
|
332
268
|
let desc;
|
|
333
269
|
let descId;
|
|
334
270
|
let descOwner;
|
|
335
271
|
let descOwnerLid;
|
|
336
272
|
let descTime;
|
|
337
273
|
if (descChild) {
|
|
338
|
-
desc = WABinary_1.getBinaryNodeChildString(descChild, 'body');
|
|
339
|
-
descOwner = WABinary_1.jidNormalizedUser(descChild.attrs.participant_pn || descChild.attrs.participant);
|
|
274
|
+
desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
|
|
275
|
+
descOwner = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn || descChild.attrs.participant);
|
|
340
276
|
if (group.attrs.addressing_mode === 'lid') {
|
|
341
|
-
descOwnerLid = WABinary_1.jidNormalizedUser(descChild.attrs.participant);
|
|
277
|
+
descOwnerLid = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant);
|
|
342
278
|
}
|
|
343
279
|
descId = descChild.attrs.id;
|
|
344
280
|
descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
|
|
345
281
|
}
|
|
346
282
|
const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
|
|
347
283
|
const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
|
|
348
|
-
const eph = WABinary_1.getBinaryNodeChild(group, 'ephemeral')
|
|
349
|
-
const memberAddMode = WABinary_1.getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
|
|
284
|
+
const eph = (_a = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs.expiration;
|
|
285
|
+
const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
|
|
350
286
|
const metadata = {
|
|
351
287
|
id: groupId,
|
|
352
288
|
addressingMode: group.attrs.addressing_mode,
|
|
353
289
|
subject: group.attrs.subject,
|
|
354
|
-
subjectOwner: WABinary_1.jidNormalizedUser(group.attrs.s_o_pn || group.attrs.s_o),
|
|
355
|
-
...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: WABinary_1.jidNormalizedUser(group.attrs.s_o) } : {}),
|
|
290
|
+
subjectOwner: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o_pn || group.attrs.s_o),
|
|
291
|
+
...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o) } : {}),
|
|
356
292
|
subjectTime: group.attrs.s_t ? +group.attrs.s_t : undefined,
|
|
357
|
-
size: groupSize || WABinary_1.getBinaryNodeChildren(group, 'participant').length,
|
|
293
|
+
size: groupSize || (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
|
|
358
294
|
creation: group.attrs.creation ? +group.attrs.creation : undefined,
|
|
359
|
-
owner: WABinary_1.jidNormalizedUser(group.attrs.creator_pn || group.attrs.creator),
|
|
360
|
-
...(group.attrs.addressing_mode === 'lid' ? { ownerLid: WABinary_1.jidNormalizedUser(group.attrs.creator) } : {}),
|
|
295
|
+
owner: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn || group.attrs.creator),
|
|
296
|
+
...(group.attrs.addressing_mode === 'lid' ? { ownerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) } : {}),
|
|
361
297
|
descOwner,
|
|
362
298
|
descOwnerLid,
|
|
363
|
-
restrict: !!WABinary_1.getBinaryNodeChild(group, 'locked'),
|
|
364
|
-
announce: !!WABinary_1.getBinaryNodeChild(group, 'announcement'),
|
|
365
|
-
isCommunity: !!WABinary_1.getBinaryNodeChild(group, 'parent'),
|
|
366
|
-
isCommunityAnnounce: !!WABinary_1.getBinaryNodeChild(group, 'default_sub_group'),
|
|
367
|
-
joinApprovalMode: !!WABinary_1.getBinaryNodeChild(group, 'membership_approval_mode'),
|
|
299
|
+
restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
|
|
300
|
+
announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
|
|
301
|
+
isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(group, 'parent'),
|
|
302
|
+
isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
|
|
303
|
+
joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode'),
|
|
368
304
|
memberAddMode,
|
|
369
|
-
participants: WABinary_1.getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
305
|
+
participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
|
|
370
306
|
return {
|
|
371
307
|
id: attrs.jid,
|
|
372
308
|
jid: attrs.phone_number || attrs.jid,
|
package/lib/Socket/index.js
CHANGED
|
@@ -6,9 +6,10 @@ import { BinaryNode, JidWithDevice } from '../WABinary';
|
|
|
6
6
|
export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
7
7
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
8
8
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
9
|
-
relayMessage: (jid: string, message: proto.IMessage, { messageId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata,
|
|
9
|
+
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
10
10
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
11
11
|
sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
12
|
+
getButtonArgs: (message: proto.IMessage) => BinaryNode['attrs'];
|
|
12
13
|
readMessages: (keys: WAMessageKey[]) => Promise<void>;
|
|
13
14
|
refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
|
|
14
15
|
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<JidWithDevice[]>;
|
|
@@ -21,7 +22,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
21
22
|
[_: string]: string;
|
|
22
23
|
}>;
|
|
23
24
|
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
24
|
-
rahmi: any;
|
|
25
25
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
26
26
|
sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
|
|
27
27
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|