@nuiisweety/baileys 0.1.16 → 0.1.18
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 +522 -829
- package/README.md.bak +390 -833
- package/lib/Socket/index.js +14 -22
- package/lib/Socket/index.js.bak +4 -4
- package/lib/Socket/messages-send.js +12 -3
- package/lib/Socket/messages-send.js.bak +6 -2
- package/lib/Utils/messages.js +13 -0
- package/lib/Utils/messages.js.bak +921 -309
- package/package.json +1 -1
package/lib/Socket/index.js
CHANGED
|
@@ -5,18 +5,14 @@ import { makeCommunitiesSocket } from './communities.js';
|
|
|
5
5
|
const _require = createRequire(import.meta.url);
|
|
6
6
|
const _pkg = _require('../../package.json');
|
|
7
7
|
|
|
8
|
-
// Kumpulan warna ANSI yang lebih lengkap dan rapi
|
|
9
8
|
const C = {
|
|
10
9
|
r: '\x1b[0m',
|
|
11
10
|
bold: '\x1b[1m',
|
|
12
|
-
dim: '\x1b[2m',
|
|
13
11
|
cyan: '\x1b[36m',
|
|
14
12
|
green: '\x1b[32m',
|
|
15
13
|
yellow: '\x1b[33m',
|
|
16
14
|
magenta: '\x1b[35m',
|
|
17
|
-
blue: '\x1b[34m'
|
|
18
|
-
bgCyan: '\x1b[46m',
|
|
19
|
-
bgBlack: '\x1b[40m'
|
|
15
|
+
blue: '\x1b[34m'
|
|
20
16
|
};
|
|
21
17
|
|
|
22
18
|
let _bannerPrinted = false;
|
|
@@ -25,28 +21,24 @@ const printBanner = () => {
|
|
|
25
21
|
if (_bannerPrinted) return;
|
|
26
22
|
_bannerPrinted = true;
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
console.log(
|
|
31
|
-
console.log(`${C.
|
|
32
|
-
console.log(
|
|
33
|
-
console.log(`${C.
|
|
34
|
-
console.log(`${C.
|
|
35
|
-
console.log(`${C.
|
|
36
|
-
console.log(`${C.
|
|
37
|
-
console.log(
|
|
38
|
-
console.log(`${C.
|
|
24
|
+
const line = `${C.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${C.r}`;
|
|
25
|
+
|
|
26
|
+
console.log(`\n${line}`);
|
|
27
|
+
console.log(`${C.bold} ⚡ BAILEYS MULTI-DEVICE${C.r}`);
|
|
28
|
+
console.log(line);
|
|
29
|
+
console.log(`${C.bold} Package :${C.r} @nuiisweety/baileys`);
|
|
30
|
+
console.log(`${C.bold} Version :${C.r} ${C.yellow}v${_pkg.version}${C.r}`);
|
|
31
|
+
console.log(`${C.bold} Creator :${C.r} ${C.green}© NuiiS4TORU${C.r}`);
|
|
32
|
+
console.log(`${C.bold} NodeJS :${C.r} ${C.blue}${process.version}${C.r}`);
|
|
33
|
+
console.log(line);
|
|
34
|
+
console.log(`${C.magenta} Terimakasih telah menggunakan library ini!${C.r}`);
|
|
35
|
+
console.log(`${line}\n`);
|
|
39
36
|
};
|
|
40
37
|
|
|
41
|
-
// export the last socket layer
|
|
42
38
|
const makeWASocket = (config) => {
|
|
43
|
-
const newConfig = {
|
|
44
|
-
...DEFAULT_CONNECTION_CONFIG,
|
|
45
|
-
...config
|
|
46
|
-
};
|
|
39
|
+
const newConfig = { ...DEFAULT_CONNECTION_CONFIG, ...config };
|
|
47
40
|
printBanner();
|
|
48
41
|
return makeCommunitiesSocket(newConfig);
|
|
49
42
|
};
|
|
50
43
|
|
|
51
44
|
export default makeWASocket;
|
|
52
|
-
//# sourceMappingURL=index.js.map
|
package/lib/Socket/index.js.bak
CHANGED
|
@@ -26,16 +26,16 @@ const printBanner = () => {
|
|
|
26
26
|
_bannerPrinted = true;
|
|
27
27
|
|
|
28
28
|
// Desain Box Banner Premium dengan Emoji
|
|
29
|
-
console.log(`\n${C.cyan}
|
|
29
|
+
console.log(`\n${C.cyan}╭────────────────────────────────────────╮${C.r}`);
|
|
30
30
|
console.log(`${C.cyan}│${C.r} ${C.bgCyan}${C.bgBlack}${C.bold} ⚡ BAILEYS MULTI-DEVICE ⚡ ${C.r} ${C.cyan}│${C.r}`);
|
|
31
|
-
console.log(`${C.cyan}
|
|
31
|
+
console.log(`${C.cyan}├────────────────────────────────────────┤${C.r}`);
|
|
32
32
|
console.log(`${C.cyan}│${C.r} 📦 ${C.bold}Package${C.r} : ${C.cyan}@nuiisweety/baileys${C.r} ${C.cyan}│${C.r}`);
|
|
33
33
|
console.log(`${C.cyan}│${C.r} 🏷️ ${C.bold}Version${C.r} : ${C.yellow}v${_pkg.version}${C.r} ${C.cyan}│${C.r}`);
|
|
34
34
|
console.log(`${C.cyan}│${C.r} 👑 ${C.bold}Creator${C.r} : ${C.green}© NuiiSweety${C.r} ${C.cyan}│${C.r}`);
|
|
35
35
|
console.log(`${C.cyan}│${C.r} 🚀 ${C.bold}NodeJS${C.r} : ${C.blue}${process.version}${r_str => process.version.length === 7 ? ' ' : ' '}${C.r} ${C.cyan}│${C.r}`);
|
|
36
|
-
console.log(`${C.cyan}
|
|
36
|
+
console.log(`${C.cyan}├────────────────────────────────────────┤${C.r}`);
|
|
37
37
|
console.log(`${C.cyan}│${C.r} 💖 ${C.magenta}Terimakasih telah menggunakan library ini!${C.r} ${C.cyan}│${C.r}`);
|
|
38
|
-
console.log(`${C.cyan}
|
|
38
|
+
console.log(`${C.cyan}╰────────────────────────────────────────╯${C.r}\n`);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// export the last socket layer
|
|
@@ -478,10 +478,19 @@ export const makeMessagesSocket = (config) => {
|
|
|
478
478
|
}
|
|
479
479
|
if (isNewsletter) {
|
|
480
480
|
const patched = patchMessageBeforeSending ? await patchMessageBeforeSending(message, []) : message;
|
|
481
|
+
// Evaluate mediaType from patched message (after patchMessageBeforeSending),
|
|
482
|
+
// and place it in plaintext attrs — NOT in stanza attrs (WA server requires it there)
|
|
483
|
+
const newsletterMediaType = getMediaType(normalizeMessageContent(patched) || patched);
|
|
484
|
+
if (newsletterMediaType) {
|
|
485
|
+
extraAttrs['mediatype'] = newsletterMediaType;
|
|
486
|
+
}
|
|
487
|
+
if (patched.interactiveMessage && !extraAttrs['mediatype']) {
|
|
488
|
+
extraAttrs['mediatype'] = 'interactive';
|
|
489
|
+
}
|
|
481
490
|
const bytes = encodeNewsletterMessage(patched);
|
|
482
491
|
binaryNodeContent.push({
|
|
483
492
|
tag: 'plaintext',
|
|
484
|
-
attrs:
|
|
493
|
+
attrs: extraAttrs,
|
|
485
494
|
content: bytes
|
|
486
495
|
});
|
|
487
496
|
const stanza = {
|
|
@@ -489,12 +498,12 @@ export const makeMessagesSocket = (config) => {
|
|
|
489
498
|
attrs: {
|
|
490
499
|
to: jid,
|
|
491
500
|
id: msgId,
|
|
492
|
-
type: getMessageType(
|
|
501
|
+
type: getMessageType(patched),
|
|
493
502
|
...(additionalAttributes || {})
|
|
494
503
|
},
|
|
495
504
|
content: binaryNodeContent
|
|
496
505
|
};
|
|
497
|
-
logger.debug({ msgId }, `sending newsletter message to ${jid}`);
|
|
506
|
+
logger.debug({ msgId, mediaType: newsletterMediaType, extraAttrs }, `sending newsletter message to ${jid}`);
|
|
498
507
|
await sendNode(stanza);
|
|
499
508
|
return;
|
|
500
509
|
}
|
|
@@ -471,7 +471,8 @@ export const makeMessagesSocket = (config) => {
|
|
|
471
471
|
}
|
|
472
472
|
await authState.keys.transaction(async () => {
|
|
473
473
|
const normalizedMsg = normalizeMessageContent(message);
|
|
474
|
-
const
|
|
474
|
+
const isGroupStatusAudio = !!(message?.groupStatusMessageV2?.message?.audioMessage);
|
|
475
|
+
const mediaType = isGroupStatusAudio ? undefined : getMediaType(normalizedMsg || message);
|
|
475
476
|
if (mediaType) {
|
|
476
477
|
extraAttrs['mediatype'] = mediaType;
|
|
477
478
|
}
|
|
@@ -489,6 +490,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
489
490
|
to: jid,
|
|
490
491
|
id: msgId,
|
|
491
492
|
type: getMessageType(message),
|
|
493
|
+
...(extraAttrs || {}),
|
|
492
494
|
...(additionalAttributes || {})
|
|
493
495
|
},
|
|
494
496
|
content: binaryNodeContent
|
|
@@ -912,7 +914,9 @@ export const makeMessagesSocket = (config) => {
|
|
|
912
914
|
if (normalizedMessage.eventMessage) {
|
|
913
915
|
return 'event';
|
|
914
916
|
}
|
|
915
|
-
|
|
917
|
+
// Audio wrapped in groupStatusMessageV2 → type "text" (Baileys behavior)
|
|
918
|
+
const isGroupStatusAudio = !!(message?.groupStatusMessageV2?.message?.audioMessage);
|
|
919
|
+
if (!isGroupStatusAudio && getMediaType(normalizedMessage) !== '') {
|
|
916
920
|
return 'media';
|
|
917
921
|
}
|
|
918
922
|
return 'text';
|
package/lib/Utils/messages.js
CHANGED
|
@@ -104,6 +104,19 @@ export const prepareWAMessageMedia = async (message, options) => {
|
|
|
104
104
|
logger?.info({ key: cacheableKey }, 'Preparing raw media for newsletter');
|
|
105
105
|
const { filePath, fileSha256, fileLength } = await getRawMediaUploadData(uploadData.media, options.mediaTypeOverride || mediaType, logger);
|
|
106
106
|
const fileSha256B64 = fileSha256.toString('base64');
|
|
107
|
+
// Generate thumbnail for image/video before uploading (filePath still exists)
|
|
108
|
+
if ((mediaType === 'image' || mediaType === 'video') && !uploadData.jpegThumbnail) {
|
|
109
|
+
try {
|
|
110
|
+
const { thumbnail, originalImageDimensions } = await generateThumbnail(filePath, mediaType, options);
|
|
111
|
+
uploadData.jpegThumbnail = thumbnail;
|
|
112
|
+
if (!uploadData.width && originalImageDimensions) {
|
|
113
|
+
uploadData.width = originalImageDimensions.width;
|
|
114
|
+
uploadData.height = originalImageDimensions.height;
|
|
115
|
+
}
|
|
116
|
+
} catch (e) {
|
|
117
|
+
logger?.warn({ err: e }, 'failed to generate thumbnail for newsletter media');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
107
120
|
const { mediaUrl, directPath } = await options.upload(filePath, {
|
|
108
121
|
fileEncSha256B64: fileSha256B64,
|
|
109
122
|
mediaType: mediaType,
|