alipclutch-baileys 8.3.0 → 8.4.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/LICENSE +3 -1
- package/README.md +10 -9
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.d.ts +55057 -0
- package/WAProto/index.js +56887 -17535
- package/WAProto/index.ts.ts +53473 -0
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/index.d.ts +16 -7
- package/lib/Defaults/index.js +90 -119
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/types.d.ts +0 -1
- package/lib/Socket/Client/types.js +0 -1
- package/lib/Socket/Client/websocket.d.ts +0 -1
- package/lib/Socket/Client/websocket.js +0 -1
- package/lib/Socket/business.d.ts +59 -58
- package/lib/Socket/chats.d.ts +45 -230
- package/lib/Socket/chats.js +139 -238
- package/lib/Socket/groups.d.ts +41 -32
- package/lib/Socket/groups.js +38 -23
- package/lib/Socket/index.d.ts +63 -64
- package/lib/Socket/index.js +2 -3
- package/lib/Socket/messages-recv.js +9 -65
- package/lib/Socket/messages-send.d.ts +49 -47
- package/lib/Socket/messages-send.js +584 -395
- package/lib/Socket/newsletter.d.ts +39 -37
- package/lib/Socket/newsletter.js +88 -123
- package/lib/Socket/setup.js +433 -0
- package/lib/Socket/{dugong.d.ts → setup.ts} +17 -52
- package/lib/Socket/socket.d.ts +10 -10
- package/lib/Socket/socket.js +62 -38
- package/lib/Socket/usync.d.ts +3 -4
- package/lib/Socket/usync.js +0 -1
- package/lib/Store/index.d.ts +1 -2
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.d.ts +24 -24
- package/lib/Store/make-in-memory-store.js +26 -14
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +0 -7
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +14 -7
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +44 -2
- package/lib/Types/GroupMetadata.d.ts +11 -2
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +148 -21
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.d.ts +73 -97
- package/lib/Types/Newsletter.js +18 -38
- package/lib/Types/Socket.d.ts +17 -9
- package/lib/Types/index.d.ts +8 -1
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +6 -13
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +15 -16
- package/lib/Utils/chat-utils.js +36 -35
- package/lib/Utils/crypto.d.ts +15 -16
- package/lib/Utils/crypto.js +71 -29
- package/lib/Utils/decode-wa-message.d.ts +22 -6
- package/lib/Utils/decode-wa-message.js +65 -56
- package/lib/Utils/event-buffer.d.ts +2 -2
- package/lib/Utils/event-buffer.js +11 -7
- package/lib/Utils/generics.d.ts +17 -20
- package/lib/Utils/generics.js +95 -75
- package/lib/Utils/history.d.ts +4 -0
- package/lib/Utils/history.js +4 -6
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +34 -1
- package/lib/Utils/logger.d.ts +10 -3
- package/lib/Utils/lt-hash.d.ts +2 -2
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +28 -24
- package/lib/Utils/messages-media.js +272 -111
- package/lib/Utils/messages.d.ts +13 -10
- package/lib/Utils/messages.js +323 -50
- package/lib/Utils/noise-handler.d.ts +10 -12
- package/lib/Utils/noise-handler.js +18 -23
- package/lib/Utils/process-message.d.ts +5 -4
- package/lib/Utils/process-message.js +108 -25
- package/lib/Utils/signal.d.ts +2 -1
- package/lib/Utils/signal.js +26 -26
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -1
- package/lib/Utils/use-multi-file-auth-state.js +51 -6
- package/lib/Utils/validate-connection.d.ts +3 -4
- package/lib/Utils/validate-connection.js +90 -66
- package/lib/WABinary/constants.d.ts +24 -27
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +3 -4
- package/lib/WABinary/decode.js +26 -13
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +137 -152
- package/lib/WABinary/generic-utils.d.ts +1 -4
- package/lib/WABinary/generic-utils.js +37 -125
- package/lib/WABinary/jid-utils.d.ts +11 -5
- package/lib/WABinary/jid-utils.js +28 -5
- package/lib/WABinary/jid-utils.js.bak +83 -0
- package/lib/WAM/BinaryInfo.d.ts +2 -11
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +27 -15
- package/package.json +18 -31
- package/engine-requirements.js +0 -10
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/dugong.js +0 -483
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-cache-manager-store.js +0 -83
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
const WAProto = require('../../WAProto').proto;
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
class yaoii {
|
|
5
|
+
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
6
|
+
this.utils = utils;
|
|
7
|
+
this.relayMessage = relayMessageFn
|
|
8
|
+
this.waUploadToServer = waUploadToServer;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
detectType(content) {
|
|
12
|
+
if (content.requestPaymentMessage) return 'PAYMENT';
|
|
13
|
+
if (content.productMessage) return 'PRODUCT';
|
|
14
|
+
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
15
|
+
if (content.albumMessage) return 'ALBUM';
|
|
16
|
+
if (content.eventMessage) return 'EVENT';
|
|
17
|
+
if (content.pollResultMessage) return 'POLL_RESULT'
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async handlePayment(content, quoted) {
|
|
22
|
+
const data = content.requestPaymentMessage;
|
|
23
|
+
let notes = {};
|
|
24
|
+
|
|
25
|
+
if (data.sticker?.stickerMessage) {
|
|
26
|
+
notes = {
|
|
27
|
+
stickerMessage: {
|
|
28
|
+
...data.sticker.stickerMessage,
|
|
29
|
+
contextInfo: {
|
|
30
|
+
stanzaId: quoted?.key?.id,
|
|
31
|
+
participant: quoted?.key?.participant || content.sender,
|
|
32
|
+
quotedMessage: quoted?.message
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
} else if (data.note) {
|
|
37
|
+
notes = {
|
|
38
|
+
extendedTextMessage: {
|
|
39
|
+
text: data.note,
|
|
40
|
+
contextInfo: {
|
|
41
|
+
stanzaId: quoted?.key?.id,
|
|
42
|
+
participant: quoted?.key?.participant || content.sender,
|
|
43
|
+
quotedMessage: quoted?.message
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
requestPaymentMessage: WAProto.Message.RequestPaymentMessage.fromObject({
|
|
51
|
+
expiryTimestamp: data.expiry || 0,
|
|
52
|
+
amount1000: data.amount || 0,
|
|
53
|
+
currencyCodeIso4217: data.currency || "IDR",
|
|
54
|
+
requestFrom: data.from || "0@s.whatsapp.net",
|
|
55
|
+
noteMessage: notes,
|
|
56
|
+
background: data.background ?? {
|
|
57
|
+
id: "DEFAULT",
|
|
58
|
+
placeholderArgb: 0xFFF0F0F0
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async handleProduct(content, jid, quoted) {
|
|
65
|
+
const {
|
|
66
|
+
title,
|
|
67
|
+
description,
|
|
68
|
+
thumbnail,
|
|
69
|
+
productId,
|
|
70
|
+
retailerId,
|
|
71
|
+
url,
|
|
72
|
+
body = "",
|
|
73
|
+
footer = "",
|
|
74
|
+
buttons = [],
|
|
75
|
+
} = content.productMessage;
|
|
76
|
+
|
|
77
|
+
let productImage;
|
|
78
|
+
|
|
79
|
+
if (Buffer.isBuffer(thumbnail)) {
|
|
80
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
81
|
+
{ image: thumbnail },
|
|
82
|
+
{ upload: this.waUploadToServer }
|
|
83
|
+
);
|
|
84
|
+
productImage = imageMessage;
|
|
85
|
+
} else if (typeof thumbnail === 'object' && thumbnail.url) {
|
|
86
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
87
|
+
{ image: { url: thumbnail.url }},
|
|
88
|
+
{ upload: this.waUploadToServer }
|
|
89
|
+
);
|
|
90
|
+
productImage = imageMessage;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
viewOnceMessage: {
|
|
95
|
+
message: {
|
|
96
|
+
interactiveMessage: {
|
|
97
|
+
body: { text: body },
|
|
98
|
+
footer: { text: footer },
|
|
99
|
+
header: {
|
|
100
|
+
title,
|
|
101
|
+
hasMediaAttachment: true,
|
|
102
|
+
productMessage: {
|
|
103
|
+
product: {
|
|
104
|
+
productImage,
|
|
105
|
+
productId,
|
|
106
|
+
title,
|
|
107
|
+
description,
|
|
108
|
+
retailerId,
|
|
109
|
+
url,
|
|
110
|
+
productImageCount: 1
|
|
111
|
+
},
|
|
112
|
+
businessOwnerJid: "0@s.whatsapp.net"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
nativeFlowMessage: { buttons }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async handleInteractive(content, jid, quoted) {
|
|
123
|
+
const {
|
|
124
|
+
title,
|
|
125
|
+
footer,
|
|
126
|
+
thumbnail,
|
|
127
|
+
image,
|
|
128
|
+
video,
|
|
129
|
+
document,
|
|
130
|
+
mimetype,
|
|
131
|
+
fileName,
|
|
132
|
+
jpegThumbnail,
|
|
133
|
+
contextInfo,
|
|
134
|
+
externalAdReply,
|
|
135
|
+
buttons = [],
|
|
136
|
+
nativeFlowMessage
|
|
137
|
+
} = content.interactiveMessage;
|
|
138
|
+
|
|
139
|
+
let media = null;
|
|
140
|
+
let mediaType = null;
|
|
141
|
+
|
|
142
|
+
if (thumbnail) {
|
|
143
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
144
|
+
{ image: { url: thumbnail } },
|
|
145
|
+
{ upload: this.waUploadToServer }
|
|
146
|
+
);
|
|
147
|
+
mediaType = 'image';
|
|
148
|
+
} else if (image) {
|
|
149
|
+
if (typeof image === 'object' && image.url) {
|
|
150
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
151
|
+
{ image: { url: image.url } },
|
|
152
|
+
{ upload: this.waUploadToServer }
|
|
153
|
+
);
|
|
154
|
+
} else {
|
|
155
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
156
|
+
{ image: image },
|
|
157
|
+
{ upload: this.waUploadToServer }
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
mediaType = 'image';
|
|
161
|
+
} else if (video) {
|
|
162
|
+
if (typeof video === 'object' && video.url) {
|
|
163
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
164
|
+
{ video: { url: video.url } },
|
|
165
|
+
{ upload: this.waUploadToServer }
|
|
166
|
+
);
|
|
167
|
+
} else {
|
|
168
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
169
|
+
{ video: video },
|
|
170
|
+
{ upload: this.waUploadToServer }
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
mediaType = 'video';
|
|
174
|
+
} else if (document) {
|
|
175
|
+
let documentPayload = { document: document };
|
|
176
|
+
|
|
177
|
+
if (jpegThumbnail) {
|
|
178
|
+
if (typeof jpegThumbnail === 'object' && jpegThumbnail.url) {
|
|
179
|
+
documentPayload.jpegThumbnail = { url: jpegThumbnail.url };
|
|
180
|
+
} else {
|
|
181
|
+
documentPayload.jpegThumbnail = jpegThumbnail;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
186
|
+
documentPayload,
|
|
187
|
+
{ upload: this.waUploadToServer }
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
if (fileName) {
|
|
191
|
+
media.documentMessage.fileName = fileName;
|
|
192
|
+
}
|
|
193
|
+
if (mimetype) {
|
|
194
|
+
media.documentMessage.mimetype = mimetype;
|
|
195
|
+
}
|
|
196
|
+
mediaType = 'document';
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let interactiveMessage = {
|
|
200
|
+
body: { text: title || "" },
|
|
201
|
+
footer: { text: footer || "" }
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
if (buttons && buttons.length > 0) {
|
|
205
|
+
interactiveMessage.nativeFlowMessage = {
|
|
206
|
+
buttons: buttons
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
if (nativeFlowMessage) {
|
|
210
|
+
interactiveMessage.nativeFlowMessage = {
|
|
211
|
+
...interactiveMessage.nativeFlowMessage,
|
|
212
|
+
...nativeFlowMessage
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
} else if (nativeFlowMessage) {
|
|
216
|
+
interactiveMessage.nativeFlowMessage = nativeFlowMessage;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (media) {
|
|
220
|
+
interactiveMessage.header = {
|
|
221
|
+
title: "",
|
|
222
|
+
hasMediaAttachment: true,
|
|
223
|
+
...media
|
|
224
|
+
};
|
|
225
|
+
} else {
|
|
226
|
+
interactiveMessage.header = {
|
|
227
|
+
title: "",
|
|
228
|
+
hasMediaAttachment: false
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let finalContextInfo = {};
|
|
233
|
+
|
|
234
|
+
if (contextInfo) {
|
|
235
|
+
finalContextInfo = {
|
|
236
|
+
mentionedJid: contextInfo.mentionedJid || [],
|
|
237
|
+
forwardingScore: contextInfo.forwardingScore || 0,
|
|
238
|
+
isForwarded: contextInfo.isForwarded || false,
|
|
239
|
+
...contextInfo
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (externalAdReply) {
|
|
244
|
+
finalContextInfo.externalAdReply = {
|
|
245
|
+
title: externalAdReply.title || "",
|
|
246
|
+
body: externalAdReply.body || "",
|
|
247
|
+
mediaType: externalAdReply.mediaType || 1,
|
|
248
|
+
thumbnailUrl: externalAdReply.thumbnailUrl || "",
|
|
249
|
+
mediaUrl: externalAdReply.mediaUrl || "",
|
|
250
|
+
sourceUrl: externalAdReply.sourceUrl || "",
|
|
251
|
+
showAdAttribution: externalAdReply.showAdAttribution || false,
|
|
252
|
+
renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
|
|
253
|
+
...externalAdReply
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (Object.keys(finalContextInfo).length > 0) {
|
|
258
|
+
interactiveMessage.contextInfo = finalContextInfo;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
interactiveMessage: interactiveMessage
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async handleAlbum(content, jid, quoted) {
|
|
267
|
+
const array = content.albumMessage;
|
|
268
|
+
const album = await this.utils.generateWAMessageFromContent(jid, {
|
|
269
|
+
messageContextInfo: {
|
|
270
|
+
messageSecret: crypto.randomBytes(32),
|
|
271
|
+
},
|
|
272
|
+
albumMessage: {
|
|
273
|
+
expectedImageCount: array.filter((a) => a.hasOwnProperty("image")).length,
|
|
274
|
+
expectedVideoCount: array.filter((a) => a.hasOwnProperty("video")).length,
|
|
275
|
+
},
|
|
276
|
+
}, {
|
|
277
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
278
|
+
quoted,
|
|
279
|
+
upload: this.waUploadToServer
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
await this.relayMessage(jid, album.message, {
|
|
283
|
+
messageId: album.key.id,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
for (let content of array) {
|
|
287
|
+
const img = await this.utils.generateWAMessage(jid, content, {
|
|
288
|
+
upload: this.waUploadToServer,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
img.message.messageContextInfo = {
|
|
292
|
+
messageSecret: crypto.randomBytes(32),
|
|
293
|
+
messageAssociation: {
|
|
294
|
+
associationType: 1,
|
|
295
|
+
parentMessageKey: album.key,
|
|
296
|
+
},
|
|
297
|
+
participant: "0@s.whatsapp.net",
|
|
298
|
+
remoteJid: "status@broadcast",
|
|
299
|
+
forwardingScore: 99999,
|
|
300
|
+
isForwarded: true,
|
|
301
|
+
mentionedJid: [jid],
|
|
302
|
+
starred: true,
|
|
303
|
+
labels: ["Y", "Important"],
|
|
304
|
+
isHighlighted: true,
|
|
305
|
+
businessMessageForwardInfo: {
|
|
306
|
+
businessOwnerJid: jid,
|
|
307
|
+
},
|
|
308
|
+
dataSharingContext: {
|
|
309
|
+
showMmDisclosure: true,
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
img.message.forwardedNewsletterMessageInfo = {
|
|
314
|
+
newsletterJid: "0@newsletter",
|
|
315
|
+
serverMessageId: 1,
|
|
316
|
+
newsletterName: `WhatsApp`,
|
|
317
|
+
contentType: 1,
|
|
318
|
+
timestamp: new Date().toISOString(),
|
|
319
|
+
senderName: "yaoii",
|
|
320
|
+
content: "Text Message",
|
|
321
|
+
priority: "high",
|
|
322
|
+
status: "sent",
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
img.message.disappearingMode = {
|
|
326
|
+
initiator: 3,
|
|
327
|
+
trigger: 4,
|
|
328
|
+
initiatorDeviceJid: jid,
|
|
329
|
+
initiatedByExternalService: true,
|
|
330
|
+
initiatedByUserDevice: true,
|
|
331
|
+
initiatedBySystem: true,
|
|
332
|
+
initiatedByServer: true,
|
|
333
|
+
initiatedByAdmin: true,
|
|
334
|
+
initiatedByUser: true,
|
|
335
|
+
initiatedByApp: true,
|
|
336
|
+
initiatedByBot: true,
|
|
337
|
+
initiatedByMe: true,
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
await this.relayMessage(jid, img.message, {
|
|
341
|
+
messageId: img.key.id,
|
|
342
|
+
quoted: {
|
|
343
|
+
key: {
|
|
344
|
+
remoteJid: album.key.remoteJid,
|
|
345
|
+
id: album.key.id,
|
|
346
|
+
fromMe: true,
|
|
347
|
+
participant: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
348
|
+
},
|
|
349
|
+
message: album.message,
|
|
350
|
+
},
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return album;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async handleEvent(content, jid, quoted) {
|
|
357
|
+
const eventData = content.eventMessage;
|
|
358
|
+
|
|
359
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
360
|
+
viewOnceMessage: {
|
|
361
|
+
message: {
|
|
362
|
+
messageContextInfo: {
|
|
363
|
+
deviceListMetadata: {},
|
|
364
|
+
deviceListMetadataVersion: 2,
|
|
365
|
+
messageSecret: crypto.randomBytes(32),
|
|
366
|
+
supportPayload: JSON.stringify({
|
|
367
|
+
version: 2,
|
|
368
|
+
is_ai_message: true,
|
|
369
|
+
should_show_system_message: true,
|
|
370
|
+
ticket_id: crypto.randomBytes(16).toString('hex')
|
|
371
|
+
})
|
|
372
|
+
},
|
|
373
|
+
eventMessage: {
|
|
374
|
+
contextInfo: {
|
|
375
|
+
mentionedJid: [jid],
|
|
376
|
+
participant: jid,
|
|
377
|
+
remoteJid: "status@broadcast",
|
|
378
|
+
forwardedNewsletterMessageInfo: {
|
|
379
|
+
newsletterName: "Yaoii — Baileys",
|
|
380
|
+
newsletterJid: "120363374309117436@newsletter",
|
|
381
|
+
serverMessageId: 1
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
isCanceled: eventData.isCanceled || false,
|
|
385
|
+
name: eventData.name,
|
|
386
|
+
description: eventData.description,
|
|
387
|
+
location: eventData.location || {
|
|
388
|
+
degreesLatitude: 0,
|
|
389
|
+
degreesLongitude: 0,
|
|
390
|
+
name: "Location"
|
|
391
|
+
},
|
|
392
|
+
joinLink: eventData.joinLink || '',
|
|
393
|
+
startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
|
|
394
|
+
endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
|
|
395
|
+
extraGuestsAllowed: eventData.extraGuestsAllowed !== false
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}, { quoted });
|
|
400
|
+
|
|
401
|
+
await this.relayMessage(jid, msg.message, {
|
|
402
|
+
messageId: msg.key.id
|
|
403
|
+
});
|
|
404
|
+
return msg;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
async handlePollResult(content, jid, quoted) {
|
|
408
|
+
const pollData = content.pollResultMessage;
|
|
409
|
+
|
|
410
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
411
|
+
pollResultSnapshotMessage: {
|
|
412
|
+
name: pollData.name,
|
|
413
|
+
pollVotes: pollData.pollVotes.map(vote => ({
|
|
414
|
+
optionName: vote.optionName,
|
|
415
|
+
optionVoteCount: typeof vote.optionVoteCount === 'number'
|
|
416
|
+
? vote.optionVoteCount.toString()
|
|
417
|
+
: vote.optionVoteCount
|
|
418
|
+
}))
|
|
419
|
+
}
|
|
420
|
+
}, {
|
|
421
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
422
|
+
quoted
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
await this.relayMessage(jid, msg.message, {
|
|
426
|
+
messageId: msg.key.id
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
return msg;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
module.exports = yaoii;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//
|
|
1
|
+
// setup.d.ts
|
|
2
2
|
import { proto } from '../../WAProto';
|
|
3
3
|
|
|
4
|
-
declare namespace
|
|
4
|
+
declare namespace NotForrAll {
|
|
5
5
|
interface MediaUploadOptions {
|
|
6
6
|
fileEncSha256?: Buffer;
|
|
7
7
|
mediaType?: string;
|
|
@@ -70,16 +70,15 @@ declare namespace kikyy {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
interface InteractiveMessage {
|
|
73
|
-
header?: string;
|
|
74
73
|
title: string;
|
|
75
74
|
footer?: string;
|
|
76
75
|
thumbnail?: string;
|
|
77
76
|
image?: string | Buffer | { url: string };
|
|
78
77
|
video?: string | Buffer | { url: string };
|
|
79
|
-
document?:
|
|
78
|
+
document?: Buffer;
|
|
80
79
|
mimetype?: string;
|
|
81
80
|
fileName?: string;
|
|
82
|
-
jpegThumbnail?:
|
|
81
|
+
jpegThumbnail?: Buffer; // Hanya Buffer saja
|
|
83
82
|
contextInfo?: {
|
|
84
83
|
mentionedJid?: string[];
|
|
85
84
|
forwardingScore?: number;
|
|
@@ -117,8 +116,8 @@ declare namespace kikyy {
|
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
interface AlbumItem {
|
|
120
|
-
image?:
|
|
121
|
-
video?:
|
|
119
|
+
image?: { url: string; caption?: string };
|
|
120
|
+
video?: { url: string; caption?: string };
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
interface EventMessageLocation {
|
|
@@ -147,16 +146,6 @@ declare namespace kikyy {
|
|
|
147
146
|
name: string;
|
|
148
147
|
pollVotes: PollVote[];
|
|
149
148
|
}
|
|
150
|
-
|
|
151
|
-
interface GroupStatusMessage {
|
|
152
|
-
message?: any;
|
|
153
|
-
image?: string | Buffer | { url: string };
|
|
154
|
-
video?: string | Buffer | { url: string };
|
|
155
|
-
text?: string;
|
|
156
|
-
caption?: string;
|
|
157
|
-
document?: string | Buffer | { url: string };
|
|
158
|
-
[key: string]: any;
|
|
159
|
-
}
|
|
160
149
|
|
|
161
150
|
interface MessageContent {
|
|
162
151
|
requestPaymentMessage?: PaymentMessage;
|
|
@@ -165,7 +154,6 @@ declare namespace kikyy {
|
|
|
165
154
|
albumMessage?: AlbumItem[];
|
|
166
155
|
eventMessage?: EventMessage;
|
|
167
156
|
pollResultMessage?: PollResultMessage;
|
|
168
|
-
groupStatusMessage?: GroupStatusMessage;
|
|
169
157
|
sender?: string;
|
|
170
158
|
}
|
|
171
159
|
|
|
@@ -180,75 +168,52 @@ declare namespace kikyy {
|
|
|
180
168
|
generateWAMessageFromContent: (jid: string, content: any, options?: any) => Promise<any>;
|
|
181
169
|
generateWAMessage: (jid: string, content: any, options?: any) => Promise<any>;
|
|
182
170
|
generateMessageID: () => string;
|
|
183
|
-
prepareMessageContent?: (content: any, options?: any) => Promise<any>;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
interface BailUtils {
|
|
187
|
-
generateWAMessageContent?: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
|
|
188
|
-
generateMessageID: () => string;
|
|
189
|
-
getContentType: (msg: any) => string;
|
|
190
171
|
}
|
|
191
172
|
}
|
|
192
173
|
|
|
193
|
-
declare class
|
|
174
|
+
declare class NotForrAll {
|
|
194
175
|
constructor(
|
|
195
|
-
utils:
|
|
196
|
-
waUploadToServer:
|
|
176
|
+
utils: NotForrAll.Utils,
|
|
177
|
+
waUploadToServer: NotForrAll.WAMediaUploadFunction,
|
|
197
178
|
relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
|
|
198
179
|
);
|
|
199
180
|
|
|
200
|
-
detectType(content:
|
|
181
|
+
detectType(content: NotForrAll.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | null;
|
|
201
182
|
|
|
202
183
|
handlePayment(
|
|
203
|
-
content: { requestPaymentMessage:
|
|
184
|
+
content: { requestPaymentMessage: NotForrAll.PaymentMessage },
|
|
204
185
|
quoted?: proto.IWebMessageInfo
|
|
205
186
|
): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
|
|
206
187
|
|
|
207
188
|
handleProduct(
|
|
208
|
-
content: { productMessage:
|
|
189
|
+
content: { productMessage: NotForrAll.ProductMessage },
|
|
209
190
|
jid: string,
|
|
210
191
|
quoted?: proto.IWebMessageInfo
|
|
211
192
|
): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
|
|
212
193
|
|
|
213
194
|
handleInteractive(
|
|
214
|
-
content: { interactiveMessage:
|
|
195
|
+
content: { interactiveMessage: NotForrAll.InteractiveMessage },
|
|
215
196
|
jid: string,
|
|
216
197
|
quoted?: proto.IWebMessageInfo
|
|
217
198
|
): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
|
|
218
199
|
|
|
219
200
|
handleAlbum(
|
|
220
|
-
content: { albumMessage:
|
|
201
|
+
content: { albumMessage: NotForrAll.AlbumItem[] },
|
|
221
202
|
jid: string,
|
|
222
203
|
quoted?: proto.IWebMessageInfo
|
|
223
204
|
): Promise<any>;
|
|
224
205
|
|
|
225
206
|
handleEvent(
|
|
226
|
-
content: { eventMessage:
|
|
207
|
+
content: { eventMessage: NotForrAll.EventMessage },
|
|
227
208
|
jid: string,
|
|
228
209
|
quoted?: proto.IWebMessageInfo
|
|
229
210
|
): Promise<any>;
|
|
230
211
|
|
|
231
212
|
handlePollResult(
|
|
232
|
-
content: { pollResultMessage:
|
|
213
|
+
content: { pollResultMessage: NotForrAll.PollResultMessage },
|
|
233
214
|
jid: string,
|
|
234
215
|
quoted?: proto.IWebMessageInfo
|
|
235
216
|
): Promise<any>;
|
|
236
|
-
|
|
237
|
-
handleGroupStory(
|
|
238
|
-
content: { groupStatusMessage: kikyy.GroupStatusMessage },
|
|
239
|
-
jid: string,
|
|
240
|
-
quoted?: proto.IWebMessageInfo
|
|
241
|
-
): Promise<any>;
|
|
242
|
-
|
|
243
|
-
buildMessageContent(
|
|
244
|
-
content: any,
|
|
245
|
-
opts?: kikyy.WAMessageContentGenerationOptions
|
|
246
|
-
): Promise<any>;
|
|
247
|
-
|
|
248
|
-
utils: kikyy.Utils;
|
|
249
|
-
relayMessage: (jid: string, content: any, options?: any) => Promise<any>;
|
|
250
|
-
waUploadToServer: kikyy.WAMediaUploadFunction;
|
|
251
|
-
bail: kikyy.BailUtils;
|
|
252
217
|
}
|
|
253
218
|
|
|
254
|
-
export =
|
|
219
|
+
export = NotForrAll;
|
package/lib/Socket/socket.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Boom } from '@hapi/boom';
|
|
3
2
|
import { SocketConfig } from '../Types';
|
|
4
3
|
import { BinaryNode } from '../WABinary';
|
|
4
|
+
import { WebSocketClient } from './Client';
|
|
5
5
|
/**
|
|
6
6
|
* Connects to WA servers and performs:
|
|
7
7
|
* - simple queries (no retry mechanism, wait for connection establishment)
|
|
@@ -10,12 +10,12 @@ import { BinaryNode } from '../WABinary';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const makeSocket: (config: SocketConfig) => {
|
|
12
12
|
type: "md";
|
|
13
|
-
ws:
|
|
13
|
+
ws: WebSocketClient;
|
|
14
14
|
ev: import("../Types").BaileysEventEmitter & {
|
|
15
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
15
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
16
16
|
buffer(): void;
|
|
17
|
-
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T
|
|
18
|
-
flush(force?: boolean
|
|
17
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
18
|
+
flush(force?: boolean): boolean;
|
|
19
19
|
isBuffering(): boolean;
|
|
20
20
|
};
|
|
21
21
|
authState: {
|
|
@@ -25,8 +25,8 @@ export declare const makeSocket: (config: SocketConfig) => {
|
|
|
25
25
|
signalRepository: import("../Types").SignalRepository;
|
|
26
26
|
readonly user: import("../Types").Contact | undefined;
|
|
27
27
|
generateMessageTag: () => string;
|
|
28
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
29
|
-
waitForMessage: <
|
|
28
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
29
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
30
30
|
waitForSocketOpen: () => Promise<void>;
|
|
31
31
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
32
32
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -35,9 +35,9 @@ export declare const makeSocket: (config: SocketConfig) => {
|
|
|
35
35
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
36
36
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
37
37
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
38
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
38
|
+
requestPairingCode: (phoneNumber: any, pairKey?: string) => Promise<string>;
|
|
39
39
|
/** Waits for the connection to WA to reach a state */
|
|
40
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined
|
|
41
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
40
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
41
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
42
42
|
};
|
|
43
43
|
export type Socket = ReturnType<typeof makeSocket>;
|