@heavstaltech/baileys 2.3.4 → 3.2.4
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 +226 -53
- package/WAProto/index.js +14270 -302
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +118 -79
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
- package/lib/Signal/libsignal.js +51 -29
- package/lib/Socket/business.d.ts +43 -42
- package/lib/Socket/chats.d.ts +222 -36
- package/lib/Socket/chats.js +186 -153
- package/lib/Socket/dugong.d.ts +254 -0
- package/lib/Socket/dugong.js +484 -0
- package/lib/Socket/groups.d.ts +7 -7
- package/lib/Socket/groups.js +37 -35
- package/lib/Socket/index.d.ts +52 -51
- package/lib/Socket/index.js +1 -0
- package/lib/Socket/messages-recv.d.ts +37 -34
- package/lib/Socket/messages-recv.js +175 -37
- package/lib/Socket/messages-send.d.ts +12 -18
- package/lib/Socket/messages-send.js +396 -574
- package/lib/Socket/newsletter.d.ts +28 -26
- package/lib/Socket/newsletter.js +140 -25
- package/lib/Socket/registration.d.ts +52 -49
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.d.ts +0 -1
- package/lib/Socket/socket.js +47 -198
- package/lib/Socket/usync.d.ts +10 -11
- package/lib/Store/make-cache-manager-store.d.ts +1 -2
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +1 -5
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -12
- package/lib/Types/Events.d.ts +2 -17
- package/lib/Types/GroupMetadata.d.ts +2 -3
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +10 -170
- package/lib/Types/Newsletter.d.ts +97 -86
- package/lib/Types/Newsletter.js +38 -32
- package/lib/Types/Socket.d.ts +2 -7
- package/lib/Types/index.d.ts +0 -9
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +14 -35
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +12 -11
- package/lib/Utils/chat-utils.js +36 -52
- package/lib/Utils/crypto.d.ts +16 -15
- package/lib/Utils/crypto.js +26 -74
- package/lib/Utils/decode-wa-message.d.ts +0 -17
- package/lib/Utils/decode-wa-message.js +17 -53
- package/lib/Utils/event-buffer.js +7 -10
- package/lib/Utils/generics.d.ts +17 -13
- package/lib/Utils/generics.js +79 -58
- package/lib/Utils/history.d.ts +2 -6
- package/lib/Utils/history.js +6 -4
- package/lib/Utils/logger.d.ts +3 -1
- package/lib/Utils/lt-hash.js +12 -12
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +28 -25
- package/lib/Utils/messages-media.js +201 -103
- package/lib/Utils/messages.js +36 -473
- package/lib/Utils/noise-handler.d.ts +5 -4
- package/lib/Utils/noise-handler.js +14 -19
- package/lib/Utils/process-message.d.ts +5 -5
- package/lib/Utils/process-message.js +23 -75
- package/lib/Utils/signal.d.ts +1 -2
- package/lib/Utils/signal.js +26 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +66 -242
- package/lib/Utils/validate-connection.d.ts +1 -1
- package/lib/Utils/validate-connection.js +88 -64
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/decode.d.ts +2 -1
- package/lib/WABinary/decode.js +11 -23
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +147 -134
- package/lib/WABinary/generic-utils.d.ts +5 -2
- package/lib/WABinary/generic-utils.js +125 -37
- package/lib/WABinary/jid-utils.d.ts +1 -1
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +12 -0
- package/package.json +102 -98
- package/WAProto/index.d.ts +0 -50383
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
// "kikyy dugonggg", ah dejavu (r)
|
|
2
|
+
// tanggal 14 agustus 2025 makassar
|
|
3
|
+
// telegram: @tskiofc & @kyuucode
|
|
4
|
+
|
|
5
|
+
const WAProto = require('../../WAProto').proto;
|
|
6
|
+
const crypto = require('crypto');
|
|
7
|
+
const Utils_1 = require("../Utils");
|
|
8
|
+
|
|
9
|
+
class kikyy {
|
|
10
|
+
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
11
|
+
this.utils = utils;
|
|
12
|
+
this.relayMessage = relayMessageFn
|
|
13
|
+
this.waUploadToServer = waUploadToServer;
|
|
14
|
+
|
|
15
|
+
this.bail = {
|
|
16
|
+
generateWAMessageContent: this.utils.generateWAMessageContent || Utils_1.generateWAMessageContent,
|
|
17
|
+
generateMessageID: Utils_1.generateMessageID,
|
|
18
|
+
getContentType: (msg) => Object.keys(msg.message || {})[0]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
detectType(content) {
|
|
23
|
+
if (content.requestPaymentMessage) return 'PAYMENT';
|
|
24
|
+
if (content.productMessage) return 'PRODUCT';
|
|
25
|
+
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
26
|
+
if (content.albumMessage) return 'ALBUM';
|
|
27
|
+
if (content.eventMessage) return 'EVENT';
|
|
28
|
+
if (content.pollResultMessage) return 'POLL_RESULT';
|
|
29
|
+
if (content.groupStatusMessage) return 'GROUP_STORY';
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async handlePayment(content, quoted) {
|
|
34
|
+
const data = content.requestPaymentMessage;
|
|
35
|
+
let notes = {};
|
|
36
|
+
|
|
37
|
+
if (data.sticker?.stickerMessage) {
|
|
38
|
+
notes = {
|
|
39
|
+
stickerMessage: {
|
|
40
|
+
...data.sticker.stickerMessage,
|
|
41
|
+
contextInfo: {
|
|
42
|
+
stanzaId: quoted?.key?.id,
|
|
43
|
+
participant: quoted?.key?.participant || content.sender,
|
|
44
|
+
quotedMessage: quoted?.message
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
} else if (data.note) {
|
|
49
|
+
notes = {
|
|
50
|
+
extendedTextMessage: {
|
|
51
|
+
text: data.note,
|
|
52
|
+
contextInfo: {
|
|
53
|
+
stanzaId: quoted?.key?.id,
|
|
54
|
+
participant: quoted?.key?.participant || content.sender,
|
|
55
|
+
quotedMessage: quoted?.message
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
requestPaymentMessage: WAProto.Message.RequestPaymentMessage.fromObject({
|
|
63
|
+
expiryTimestamp: data.expiry || 0,
|
|
64
|
+
amount1000: data.amount || 0,
|
|
65
|
+
currencyCodeIso4217: data.currency || "IDR",
|
|
66
|
+
requestFrom: data.from || "0@s.whatsapp.net",
|
|
67
|
+
noteMessage: notes,
|
|
68
|
+
background: data.background ?? {
|
|
69
|
+
id: "DEFAULT",
|
|
70
|
+
placeholderArgb: 0xFFF0F0F0
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async handleProduct(content, jid, quoted) {
|
|
77
|
+
const {
|
|
78
|
+
title,
|
|
79
|
+
description,
|
|
80
|
+
thumbnail,
|
|
81
|
+
productId,
|
|
82
|
+
retailerId,
|
|
83
|
+
url,
|
|
84
|
+
body = "",
|
|
85
|
+
footer = "",
|
|
86
|
+
buttons = [],
|
|
87
|
+
priceAmount1000 = null,
|
|
88
|
+
currencyCode = "IDR"
|
|
89
|
+
} = content.productMessage;
|
|
90
|
+
|
|
91
|
+
let productImage;
|
|
92
|
+
|
|
93
|
+
if (Buffer.isBuffer(thumbnail)) {
|
|
94
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
95
|
+
{ image: thumbnail },
|
|
96
|
+
{ upload: this.waUploadToServer }
|
|
97
|
+
);
|
|
98
|
+
productImage = imageMessage;
|
|
99
|
+
} else if (typeof thumbnail === 'object' && thumbnail.url) {
|
|
100
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
101
|
+
{ image: { url: thumbnail.url }},
|
|
102
|
+
{ upload: this.waUploadToServer }
|
|
103
|
+
);
|
|
104
|
+
productImage = imageMessage;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
viewOnceMessage: {
|
|
109
|
+
message: {
|
|
110
|
+
interactiveMessage: {
|
|
111
|
+
body: { text: body },
|
|
112
|
+
footer: { text: footer },
|
|
113
|
+
header: {
|
|
114
|
+
title,
|
|
115
|
+
hasMediaAttachment: true,
|
|
116
|
+
productMessage: {
|
|
117
|
+
product: {
|
|
118
|
+
productImage,
|
|
119
|
+
productId,
|
|
120
|
+
title,
|
|
121
|
+
description,
|
|
122
|
+
currencyCode,
|
|
123
|
+
priceAmount1000,
|
|
124
|
+
retailerId,
|
|
125
|
+
url,
|
|
126
|
+
productImageCount: 1
|
|
127
|
+
},
|
|
128
|
+
businessOwnerJid: "0@s.whatsapp.net"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
nativeFlowMessage: { buttons }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async handleInteractive(content, jid, quoted) {
|
|
139
|
+
const {
|
|
140
|
+
title,
|
|
141
|
+
footer,
|
|
142
|
+
thumbnail,
|
|
143
|
+
image,
|
|
144
|
+
video,
|
|
145
|
+
document,
|
|
146
|
+
mimetype,
|
|
147
|
+
fileName,
|
|
148
|
+
jpegThumbnail,
|
|
149
|
+
contextInfo,
|
|
150
|
+
externalAdReply,
|
|
151
|
+
buttons = [],
|
|
152
|
+
nativeFlowMessage,
|
|
153
|
+
header
|
|
154
|
+
} = content.interactiveMessage;
|
|
155
|
+
|
|
156
|
+
let media = null;
|
|
157
|
+
let mediaType = null;
|
|
158
|
+
|
|
159
|
+
if (thumbnail) {
|
|
160
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
161
|
+
{ image: { url: thumbnail } },
|
|
162
|
+
{ upload: this.waUploadToServer }
|
|
163
|
+
);
|
|
164
|
+
mediaType = 'image';
|
|
165
|
+
} else if (image) {
|
|
166
|
+
if (typeof image === 'object' && image.url) {
|
|
167
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
168
|
+
{ image: { url: image.url } },
|
|
169
|
+
{ upload: this.waUploadToServer }
|
|
170
|
+
);
|
|
171
|
+
} else {
|
|
172
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
173
|
+
{ image: image },
|
|
174
|
+
{ upload: this.waUploadToServer }
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
mediaType = 'image';
|
|
178
|
+
} else if (video) {
|
|
179
|
+
if (typeof video === 'object' && video.url) {
|
|
180
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
181
|
+
{ video: { url: video.url } },
|
|
182
|
+
{ upload: this.waUploadToServer }
|
|
183
|
+
);
|
|
184
|
+
} else {
|
|
185
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
186
|
+
{ video: video },
|
|
187
|
+
{ upload: this.waUploadToServer }
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
mediaType = 'video';
|
|
191
|
+
} else if (document) {
|
|
192
|
+
let documentPayload = {
|
|
193
|
+
document: document
|
|
194
|
+
};
|
|
195
|
+
if (jpegThumbnail) {
|
|
196
|
+
if (typeof jpegThumbnail === 'object' && jpegThumbnail.url) {
|
|
197
|
+
documentPayload.jpegThumbnail = { url: jpegThumbnail.url };
|
|
198
|
+
} else {
|
|
199
|
+
documentPayload.jpegThumbnail = jpegThumbnail;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
204
|
+
documentPayload,
|
|
205
|
+
{ upload: this.waUploadToServer }
|
|
206
|
+
);
|
|
207
|
+
if (fileName) {
|
|
208
|
+
media.documentMessage.fileName = fileName;
|
|
209
|
+
}
|
|
210
|
+
if (mimetype) {
|
|
211
|
+
media.documentMessage.mimetype = mimetype;
|
|
212
|
+
}
|
|
213
|
+
mediaType = 'document';
|
|
214
|
+
}
|
|
215
|
+
let interactiveMessage = {
|
|
216
|
+
body: { text: title || "" },
|
|
217
|
+
footer: { text: footer || "" }
|
|
218
|
+
};
|
|
219
|
+
if (buttons && buttons.length > 0) {
|
|
220
|
+
interactiveMessage.nativeFlowMessage = {
|
|
221
|
+
buttons: buttons
|
|
222
|
+
};
|
|
223
|
+
if (nativeFlowMessage) {
|
|
224
|
+
interactiveMessage.nativeFlowMessage = {
|
|
225
|
+
...interactiveMessage.nativeFlowMessage,
|
|
226
|
+
...nativeFlowMessage
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
} else if (nativeFlowMessage) {
|
|
230
|
+
interactiveMessage.nativeFlowMessage = nativeFlowMessage;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (media) {
|
|
234
|
+
interactiveMessage.header = {
|
|
235
|
+
title: header || "",
|
|
236
|
+
hasMediaAttachment: true,
|
|
237
|
+
...media
|
|
238
|
+
};
|
|
239
|
+
} else {
|
|
240
|
+
interactiveMessage.header = {
|
|
241
|
+
title: header || "",
|
|
242
|
+
hasMediaAttachment: false
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
let finalContextInfo = {};
|
|
247
|
+
if (contextInfo) {
|
|
248
|
+
finalContextInfo = {
|
|
249
|
+
mentionedJid: contextInfo.mentionedJid || [],
|
|
250
|
+
forwardingScore: contextInfo.forwardingScore || 0,
|
|
251
|
+
isForwarded: contextInfo.isForwarded || false,
|
|
252
|
+
...contextInfo
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (externalAdReply) {
|
|
257
|
+
finalContextInfo.externalAdReply = {
|
|
258
|
+
title: externalAdReply.title || "",
|
|
259
|
+
body: externalAdReply.body || "",
|
|
260
|
+
mediaType: externalAdReply.mediaType || 1,
|
|
261
|
+
thumbnailUrl: externalAdReply.thumbnailUrl || "",
|
|
262
|
+
mediaUrl: externalAdReply.mediaUrl || "",
|
|
263
|
+
sourceUrl: externalAdReply.sourceUrl || "",
|
|
264
|
+
showAdAttribution: externalAdReply.showAdAttribution || false,
|
|
265
|
+
renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
|
|
266
|
+
...externalAdReply
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (Object.keys(finalContextInfo).length > 0) {
|
|
271
|
+
interactiveMessage.contextInfo = finalContextInfo;
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
interactiveMessage: interactiveMessage
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async handleAlbum(content, jid, quoted) {
|
|
279
|
+
const array = content.albumMessage;
|
|
280
|
+
const album = await this.utils.generateWAMessageFromContent(jid, {
|
|
281
|
+
messageContextInfo: {
|
|
282
|
+
messageSecret: crypto.randomBytes(32),
|
|
283
|
+
},
|
|
284
|
+
albumMessage: {
|
|
285
|
+
expectedImageCount: array.filter((a) => a.hasOwnProperty("image")).length,
|
|
286
|
+
expectedVideoCount: array.filter((a) => a.hasOwnProperty("video")).length,
|
|
287
|
+
},
|
|
288
|
+
}, {
|
|
289
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
290
|
+
quoted,
|
|
291
|
+
upload: this.waUploadToServer
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
await this.relayMessage(jid, album.message, {
|
|
295
|
+
messageId: album.key.id,
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
for (let content of array) {
|
|
299
|
+
const img = await this.utils.generateWAMessage(jid, content, {
|
|
300
|
+
upload: this.waUploadToServer,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
img.message.messageContextInfo = {
|
|
304
|
+
messageSecret: crypto.randomBytes(32),
|
|
305
|
+
messageAssociation: {
|
|
306
|
+
associationType: 1,
|
|
307
|
+
parentMessageKey: album.key,
|
|
308
|
+
},
|
|
309
|
+
participant: "0@s.whatsapp.net",
|
|
310
|
+
remoteJid: "status@broadcast",
|
|
311
|
+
forwardingScore: 99999,
|
|
312
|
+
isForwarded: true,
|
|
313
|
+
mentionedJid: [jid],
|
|
314
|
+
starred: true,
|
|
315
|
+
labels: ["Y", "Important"],
|
|
316
|
+
isHighlighted: true,
|
|
317
|
+
businessMessageForwardInfo: {
|
|
318
|
+
businessOwnerJid: jid,
|
|
319
|
+
},
|
|
320
|
+
dataSharingContext: {
|
|
321
|
+
showMmDisclosure: true,
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
img.message.forwardedNewsletterMessageInfo = {
|
|
326
|
+
newsletterJid: "0@newsletter",
|
|
327
|
+
serverMessageId: 1,
|
|
328
|
+
newsletterName: `WhatsApp`,
|
|
329
|
+
contentType: 1,
|
|
330
|
+
timestamp: new Date().toISOString(),
|
|
331
|
+
senderName: "kikyy dugonggg",
|
|
332
|
+
content: "Text Message",
|
|
333
|
+
priority: "high",
|
|
334
|
+
status: "sent",
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
img.message.disappearingMode = {
|
|
338
|
+
initiator: 3,
|
|
339
|
+
trigger: 4,
|
|
340
|
+
initiatorDeviceJid: jid,
|
|
341
|
+
initiatedByExternalService: true,
|
|
342
|
+
initiatedByUserDevice: true,
|
|
343
|
+
initiatedBySystem: true,
|
|
344
|
+
initiatedByServer: true,
|
|
345
|
+
initiatedByAdmin: true,
|
|
346
|
+
initiatedByUser: true,
|
|
347
|
+
initiatedByApp: true,
|
|
348
|
+
initiatedByBot: true,
|
|
349
|
+
initiatedByMe: true,
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
await this.relayMessage(jid, img.message, {
|
|
353
|
+
messageId: img.key.id,
|
|
354
|
+
quoted: {
|
|
355
|
+
key: {
|
|
356
|
+
remoteJid: album.key.remoteJid,
|
|
357
|
+
id: album.key.id,
|
|
358
|
+
fromMe: true,
|
|
359
|
+
participant: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
360
|
+
},
|
|
361
|
+
message: album.message,
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
return album;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async handleEvent(content, jid, quoted) {
|
|
369
|
+
const eventData = content.eventMessage;
|
|
370
|
+
|
|
371
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
372
|
+
viewOnceMessage: {
|
|
373
|
+
message: {
|
|
374
|
+
messageContextInfo: {
|
|
375
|
+
deviceListMetadata: {},
|
|
376
|
+
deviceListMetadataVersion: 2,
|
|
377
|
+
messageSecret: crypto.randomBytes(32),
|
|
378
|
+
supportPayload: JSON.stringify({
|
|
379
|
+
version: 2,
|
|
380
|
+
is_ai_message: true,
|
|
381
|
+
should_show_system_message: true,
|
|
382
|
+
ticket_id: crypto.randomBytes(16).toString('hex')
|
|
383
|
+
})
|
|
384
|
+
},
|
|
385
|
+
eventMessage: {
|
|
386
|
+
contextInfo: {
|
|
387
|
+
mentionedJid: [jid],
|
|
388
|
+
participant: jid,
|
|
389
|
+
remoteJid: "status@broadcast",
|
|
390
|
+
forwardedNewsletterMessageInfo: {
|
|
391
|
+
newsletterName: "shenvn.",
|
|
392
|
+
newsletterJid: "120363297591152843@newsletter",
|
|
393
|
+
serverMessageId: 1
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
isCanceled: eventData.isCanceled || false,
|
|
397
|
+
name: eventData.name,
|
|
398
|
+
description: eventData.description,
|
|
399
|
+
location: eventData.location || {
|
|
400
|
+
degreesLatitude: 0,
|
|
401
|
+
degreesLongitude: 0,
|
|
402
|
+
name: "Location"
|
|
403
|
+
},
|
|
404
|
+
joinLink: eventData.joinLink || '',
|
|
405
|
+
startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
|
|
406
|
+
endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
|
|
407
|
+
extraGuestsAllowed: eventData.extraGuestsAllowed !== false
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}, { quoted });
|
|
412
|
+
|
|
413
|
+
await this.relayMessage(jid, msg.message, {
|
|
414
|
+
messageId: msg.key.id
|
|
415
|
+
});
|
|
416
|
+
return msg;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
async handlePollResult(content, jid, quoted) {
|
|
420
|
+
const pollData = content.pollResultMessage;
|
|
421
|
+
|
|
422
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
423
|
+
pollResultSnapshotMessage: {
|
|
424
|
+
name: pollData.name,
|
|
425
|
+
pollVotes: pollData.pollVotes.map(vote => ({
|
|
426
|
+
optionName: vote.optionName,
|
|
427
|
+
optionVoteCount: typeof vote.optionVoteCount === 'number'
|
|
428
|
+
? vote.optionVoteCount.toString()
|
|
429
|
+
: vote.optionVoteCount
|
|
430
|
+
}))
|
|
431
|
+
}
|
|
432
|
+
}, {
|
|
433
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
434
|
+
quoted
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
await this.relayMessage(jid, msg.message, {
|
|
438
|
+
messageId: msg.key.id
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
return msg;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async handleGroupStory(content, jid, quoted) {
|
|
445
|
+
const storyData = content.groupStatusMessage;
|
|
446
|
+
let waMsgContent;
|
|
447
|
+
|
|
448
|
+
if (storyData.message) {
|
|
449
|
+
waMsgContent = storyData;
|
|
450
|
+
} else {
|
|
451
|
+
if (typeof this.bail?.generateWAMessageContent === "function") {
|
|
452
|
+
waMsgContent = await this.bail.generateWAMessageContent(storyData, {
|
|
453
|
+
upload: this.waUploadToServer
|
|
454
|
+
});
|
|
455
|
+
} else if (typeof this.utils?.generateWAMessageContent === "function") {
|
|
456
|
+
waMsgContent = await this.utils.generateWAMessageContent(storyData, {
|
|
457
|
+
upload: this.waUploadToServer
|
|
458
|
+
});
|
|
459
|
+
} else if (typeof this.utils?.prepareMessageContent === "function") {
|
|
460
|
+
waMsgContent = await this.utils.prepareMessageContent(storyData, {
|
|
461
|
+
upload: this.waUploadToServer
|
|
462
|
+
});
|
|
463
|
+
} else {
|
|
464
|
+
waMsgContent = await Utils_1.generateWAMessageContent(storyData, {
|
|
465
|
+
upload: this.waUploadToServer
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
let msg = {
|
|
471
|
+
message: {
|
|
472
|
+
groupStatusMessageV2: {
|
|
473
|
+
message: waMsgContent.message || waMsgContent
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
return await this.relayMessage(jid, msg.message, {
|
|
479
|
+
messageId: this.bail.generateMessageID()
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
module.exports = kikyy;
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { proto } from '../../WAProto';
|
|
|
3
3
|
import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
|
|
4
4
|
import { BinaryNode } from '../WABinary';
|
|
5
5
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
6
|
-
groupQuery: (jid: string, type: 'get' | 'set', content: BinaryNode[]) => Promise<BinaryNode>;
|
|
7
6
|
groupMetadata: (jid: string) => Promise<GroupMetadata>;
|
|
8
7
|
groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
|
|
9
8
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -38,7 +37,6 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
38
37
|
groupFetchAllParticipating: () => Promise<{
|
|
39
38
|
[_: string]: GroupMetadata;
|
|
40
39
|
}>;
|
|
41
|
-
interactiveQuery: (userNodes: BinaryNode[], queryNode: BinaryNode) => Promise<BinaryNode[]>;
|
|
42
40
|
processingMutex: {
|
|
43
41
|
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
|
44
42
|
};
|
|
@@ -47,16 +45,19 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
47
45
|
}>;
|
|
48
46
|
upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
49
47
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
50
|
-
fetchUserLid: (jid: string) => Promise<string | undefined>;
|
|
51
48
|
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
|
|
52
49
|
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
|
|
50
|
+
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
|
|
53
51
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
54
52
|
jid: string;
|
|
55
53
|
exists: unknown;
|
|
54
|
+
lid: unknown;
|
|
56
55
|
}[] | undefined>;
|
|
57
56
|
fetchBlocklist: () => Promise<string[]>;
|
|
58
|
-
fetchStatus: (
|
|
59
|
-
|
|
57
|
+
fetchStatus: (jid: string) => Promise<{
|
|
58
|
+
status: string | undefined;
|
|
59
|
+
setAt: Date;
|
|
60
|
+
} | undefined>;
|
|
60
61
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
61
62
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
62
63
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
@@ -81,7 +82,6 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
81
82
|
id: string;
|
|
82
83
|
fromMe?: boolean | undefined;
|
|
83
84
|
}[], star: boolean) => Promise<void>;
|
|
84
|
-
executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
|
|
85
85
|
type: "md";
|
|
86
86
|
ws: any;
|
|
87
87
|
ev: import("../Types").BaileysEventEmitter & {
|
|
@@ -108,7 +108,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
108
108
|
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
|
109
109
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
110
110
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
111
|
-
requestPairingCode: (phoneNumber: string
|
|
111
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
112
112
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
|
113
113
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
114
114
|
};
|
package/lib/Socket/groups.js
CHANGED
|
@@ -6,6 +6,7 @@ const Types_1 = require("../Types");
|
|
|
6
6
|
const Utils_1 = require("../Utils");
|
|
7
7
|
const WABinary_1 = require("../WABinary");
|
|
8
8
|
const chats_1 = require("./chats");
|
|
9
|
+
const WAUSync_1 = require("../WAUSync");
|
|
9
10
|
const makeGroupsSocket = (config) => {
|
|
10
11
|
const sock = (0, chats_1.makeChatsSocket)(config);
|
|
11
12
|
const { authState, ev, query, upsertMessage } = sock;
|
|
@@ -67,10 +68,9 @@ const makeGroupsSocket = (config) => {
|
|
|
67
68
|
});
|
|
68
69
|
return {
|
|
69
70
|
...sock,
|
|
70
|
-
groupQuery,
|
|
71
71
|
groupMetadata,
|
|
72
72
|
groupCreate: async (subject, participants) => {
|
|
73
|
-
const key =
|
|
73
|
+
const key = (0, Utils_1.generateMessageID)();
|
|
74
74
|
const result = await groupQuery('@g.us', 'set', [
|
|
75
75
|
{
|
|
76
76
|
tag: 'create',
|
|
@@ -164,7 +164,7 @@ const makeGroupsSocket = (config) => {
|
|
|
164
164
|
{
|
|
165
165
|
tag: 'description',
|
|
166
166
|
attrs: {
|
|
167
|
-
...(description ? { id:
|
|
167
|
+
...(description ? { id: (0, Utils_1.generateMessageID)() } : { delete: 'true' }),
|
|
168
168
|
...(prev ? { prev } : {})
|
|
169
169
|
},
|
|
170
170
|
content: description ? [
|
|
@@ -188,23 +188,12 @@ const makeGroupsSocket = (config) => {
|
|
|
188
188
|
const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
|
|
189
189
|
return result === null || result === void 0 ? void 0 : result.attrs.jid;
|
|
190
190
|
},
|
|
191
|
-
/**
|
|
192
|
-
* revoke a v4 invite for someone
|
|
193
|
-
* @param groupJid group jid
|
|
194
|
-
* @param invitedJid jid of person you invited
|
|
195
|
-
* @returns true if successful
|
|
196
|
-
*/
|
|
197
|
-
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
198
|
-
const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
|
|
199
|
-
return !!result;
|
|
200
|
-
},
|
|
201
191
|
/**
|
|
202
192
|
* accept a GroupInviteMessage
|
|
203
193
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
204
194
|
* @param inviteMessage the message to accept
|
|
205
195
|
*/
|
|
206
196
|
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
207
|
-
var _a;
|
|
208
197
|
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
209
198
|
const results = await groupQuery(inviteMessage.groupJid, 'set', [{
|
|
210
199
|
tag: 'accept',
|
|
@@ -236,7 +225,7 @@ const makeGroupsSocket = (config) => {
|
|
|
236
225
|
await upsertMessage({
|
|
237
226
|
key: {
|
|
238
227
|
remoteJid: inviteMessage.groupJid,
|
|
239
|
-
id:
|
|
228
|
+
id: (0, Utils_1.generateMessageID)(),
|
|
240
229
|
fromMe: false,
|
|
241
230
|
participant: key.remoteJid,
|
|
242
231
|
},
|
|
@@ -274,37 +263,49 @@ const makeGroupsSocket = (config) => {
|
|
|
274
263
|
exports.makeGroupsSocket = makeGroupsSocket;
|
|
275
264
|
const extractGroupMetadata = (result) => {
|
|
276
265
|
var _a, _b;
|
|
277
|
-
const group =
|
|
278
|
-
const descChild =
|
|
266
|
+
const group = WABinary_1.getBinaryNodeChild(result, 'group');
|
|
267
|
+
const descChild = WABinary_1.getBinaryNodeChild(group, 'description');
|
|
279
268
|
let desc;
|
|
280
269
|
let descId;
|
|
270
|
+
let descOwner;
|
|
271
|
+
let descOwnerLid;
|
|
272
|
+
let descTime;
|
|
281
273
|
if (descChild) {
|
|
282
|
-
desc =
|
|
274
|
+
desc = WABinary_1.getBinaryNodeChildString(descChild, 'body');
|
|
275
|
+
descOwner = WABinary_1.jidNormalizedUser(descChild.attrs.participant_pn || descChild.attrs.participant);
|
|
276
|
+
if (group.attrs.addressing_mode === 'lid') {
|
|
277
|
+
descOwnerLid = WABinary_1.jidNormalizedUser(descChild.attrs.participant);
|
|
278
|
+
}
|
|
283
279
|
descId = descChild.attrs.id;
|
|
280
|
+
descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
|
|
284
281
|
}
|
|
282
|
+
const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
|
|
285
283
|
const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
|
|
286
|
-
const eph =
|
|
287
|
-
const memberAddMode =
|
|
284
|
+
const eph = WABinary_1.getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration
|
|
285
|
+
const memberAddMode = WABinary_1.getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
|
|
288
286
|
const metadata = {
|
|
289
287
|
id: groupId,
|
|
288
|
+
addressingMode: group.attrs.addressing_mode,
|
|
290
289
|
subject: group.attrs.subject,
|
|
291
|
-
subjectOwner: group.attrs.s_o,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
290
|
+
subjectOwner: WABinary_1.jidNormalizedUser(group.attrs.s_o_pn || group.attrs.s_o),
|
|
291
|
+
...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: WABinary_1.jidNormalizedUser(group.attrs.s_o) } : {}),
|
|
292
|
+
subjectTime: group.attrs.s_t ? +group.attrs.s_t : undefined,
|
|
293
|
+
size: groupSize || WABinary_1.getBinaryNodeChildren(group, 'participant').length,
|
|
294
|
+
creation: group.attrs.creation ? +group.attrs.creation : undefined,
|
|
295
|
+
owner: WABinary_1.jidNormalizedUser(group.attrs.creator_pn || group.attrs.creator),
|
|
296
|
+
...(group.attrs.addressing_mode === 'lid' ? { ownerLid: WABinary_1.jidNormalizedUser(group.attrs.creator) } : {}),
|
|
297
|
+
descOwner,
|
|
298
|
+
descOwnerLid,
|
|
299
|
+
restrict: !!WABinary_1.getBinaryNodeChild(group, 'locked'),
|
|
300
|
+
announce: !!WABinary_1.getBinaryNodeChild(group, 'announcement'),
|
|
301
|
+
isCommunity: !!WABinary_1.getBinaryNodeChild(group, 'parent'),
|
|
302
|
+
isCommunityAnnounce: !!WABinary_1.getBinaryNodeChild(group, 'default_sub_group'),
|
|
303
|
+
joinApprovalMode: !!WABinary_1.getBinaryNodeChild(group, 'membership_approval_mode'),
|
|
304
304
|
memberAddMode,
|
|
305
|
-
participants:
|
|
305
|
+
participants: WABinary_1.getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
306
306
|
return {
|
|
307
|
-
id: attrs.
|
|
307
|
+
id: attrs.jid,
|
|
308
|
+
jid: attrs.phone_number || attrs.jid,
|
|
308
309
|
admin: (attrs.type || null),
|
|
309
310
|
};
|
|
310
311
|
}),
|
|
@@ -313,3 +314,4 @@ const extractGroupMetadata = (result) => {
|
|
|
313
314
|
return metadata;
|
|
314
315
|
};
|
|
315
316
|
exports.extractGroupMetadata = extractGroupMetadata;
|
|
317
|
+
|