@lordmega/baileys 0.3.21 โ 0.3.23
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 -1
- package/lib/Utils/messages.js +14 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1490,7 +1490,7 @@ sock.ev.on('settings.update', (update) => {})
|
|
|
1490
1490
|
|
|
1491
1491
|
A lightweight, modular WhatsApp bot built on this library โ includes group management, moderation, quiz games, and utility tools.
|
|
1492
1492
|
|
|
1493
|
-
๐๐ป [MegaBot MD](https://github.com/
|
|
1493
|
+
๐๐ป [MegaBot MD](https://github.com/LORDMEGA-MD/MegaBot)
|
|
1494
1494
|
|
|
1495
1495
|
### ๐ฆ Fork Base
|
|
1496
1496
|
|
package/lib/Utils/messages.js
CHANGED
|
@@ -36,14 +36,10 @@ const mediaAnnotation = [
|
|
|
36
36
|
{ x: 20.840980529785156, y: -47.80188751220703 }
|
|
37
37
|
],
|
|
38
38
|
newsletter: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Buffer.from('313230333633343034303036363434313339406e6577736c6574746572', 'hex').toString(),
|
|
42
|
-
newsletterName: process.env.NEWSLETTER_NAME ||
|
|
43
|
-
Buffer.from('f09d96b2f09d978df09d96baf09d978bf09d96bff09d96baf09d9785f09d9785', 'hex').toString(),
|
|
39
|
+
newsletterJid: '120363427176654579@newsletter',
|
|
40
|
+
newsletterName: 'MEGA-BAILEYS',
|
|
44
41
|
contentType: proto.ContextInfo.ForwardedNewsletterMessageInfo.ContentType.UPDATE,
|
|
45
|
-
accessibilityText:
|
|
46
|
-
'@itsliaaa/baileys'
|
|
42
|
+
accessibilityText: '@MEGA-BAILEYS'
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
];
|
|
@@ -95,6 +91,7 @@ export const prepareWAMessageMedia = async (message, options) => {
|
|
|
95
91
|
...message,
|
|
96
92
|
media: message[mediaType]
|
|
97
93
|
};
|
|
94
|
+
|
|
98
95
|
if (uploadData.image || uploadData.video) {
|
|
99
96
|
uploadData.annotations = mediaAnnotation;
|
|
100
97
|
}
|
|
@@ -469,7 +466,7 @@ const prepareNativeFlowButtons = (message) => {
|
|
|
469
466
|
Object.assign(messageParamsJson, {
|
|
470
467
|
limited_time_offer: {
|
|
471
468
|
text: message.offerText || LIBRARY_NAME,
|
|
472
|
-
url: message.offerUrl || DONATE_URL,
|
|
469
|
+
url: message.offerUrl || DONATE_URL,
|
|
473
470
|
copy_code: message.offerCode,
|
|
474
471
|
expiration_time: message.offerExpiration
|
|
475
472
|
}
|
|
@@ -728,8 +725,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
728
725
|
m.groupInviteMessage.caption = message.groupInvite.text;
|
|
729
726
|
m.groupInviteMessage.groupJid = message.groupInvite.jid;
|
|
730
727
|
m.groupInviteMessage.groupName = message.groupInvite.subject;
|
|
731
|
-
//TODO: use built-in interface and get disappearing mode info etc.
|
|
732
|
-
//TODO: cache / use store!?
|
|
733
728
|
if (options.getProfilePicUrl) {
|
|
734
729
|
const pfpUrl = await options.getProfilePicUrl(message.groupInvite.jid, 'preview');
|
|
735
730
|
if (pfpUrl) {
|
|
@@ -814,7 +809,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
814
809
|
m.eventMessage.joinLink = (message.event.call === 'audio' ? CALL_AUDIO_PREFIX : CALL_VIDEO_PREFIX) + token;
|
|
815
810
|
}
|
|
816
811
|
m.messageContextInfo = {
|
|
817
|
-
// encKey
|
|
818
812
|
messageSecret: message.event.messageSecret || randomBytes(32)
|
|
819
813
|
};
|
|
820
814
|
m.eventMessage.name = message.event.name;
|
|
@@ -846,7 +840,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
846
840
|
allowAddOption: message.poll.canAddOption ?? false
|
|
847
841
|
};
|
|
848
842
|
if (message.poll.toAnnouncementGroup) {
|
|
849
|
-
// poll v2 is for community announcement groups (single select and multiple)
|
|
850
843
|
m.pollCreationMessageV2 = pollCreationMessage;
|
|
851
844
|
}
|
|
852
845
|
else {
|
|
@@ -856,7 +849,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
856
849
|
throw new Boom('No "correctAnswer" provided for quiz', { statusCode: 400 });
|
|
857
850
|
}
|
|
858
851
|
m.pollCreationMessageV5 = {
|
|
859
|
-
// Lia@Note 08-02-26 --- quiz for newsletter only
|
|
860
852
|
...pollCreationMessage,
|
|
861
853
|
correctAnswer: {
|
|
862
854
|
optionName: message.poll.correctAnswer.toString()
|
|
@@ -866,16 +858,13 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
866
858
|
};
|
|
867
859
|
}
|
|
868
860
|
else if (message.poll.selectableCount === 1) {
|
|
869
|
-
//poll v3 is for single select polls
|
|
870
861
|
m.pollCreationMessageV3 = pollCreationMessage;
|
|
871
862
|
}
|
|
872
863
|
else {
|
|
873
|
-
// poll for multiple choice polls
|
|
874
864
|
m.pollCreationMessage = pollCreationMessage;
|
|
875
865
|
}
|
|
876
866
|
}
|
|
877
867
|
m.messageContextInfo = {
|
|
878
|
-
// encKey
|
|
879
868
|
messageSecret: message.poll.messageSecret || randomBytes(32)
|
|
880
869
|
};
|
|
881
870
|
}
|
|
@@ -1047,7 +1036,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1047
1036
|
};
|
|
1048
1037
|
m = { listMessage };
|
|
1049
1038
|
}
|
|
1050
|
-
// Lia@Note 03-02-26 --- This message type is shown on WhatsApp Web/Desktop and iOS (I guess ๏ฝกโ โโ โฟโ โโ ๏ฝก). On Android, it only appears in newsletter (so far เฒฅโ โฟโ เฒฅ)
|
|
1051
1039
|
else if (hasNonNullishProperty(message, 'templateButtons')) {
|
|
1052
1040
|
const hydratedTemplate = {
|
|
1053
1041
|
hydratedButtons: message.templateButtons.map((button, i) => {
|
|
@@ -1097,7 +1085,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1097
1085
|
if (hasOptionalProperty(message, 'footer')) {
|
|
1098
1086
|
hydratedTemplate.hydratedFooterText = message.footer;
|
|
1099
1087
|
}
|
|
1100
|
-
hydratedTemplate.templateId = message.id || 'template-' + Date.now();
|
|
1088
|
+
hydratedTemplate.templateId = message.id || 'template-' + Date.now();
|
|
1101
1089
|
m = {
|
|
1102
1090
|
templateMessage: {
|
|
1103
1091
|
hydratedFourRowTemplate: hydratedTemplate,
|
|
@@ -1269,7 +1257,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1269
1257
|
}
|
|
1270
1258
|
m = { invoiceMessage };
|
|
1271
1259
|
}
|
|
1272
|
-
// Lia@Changes 31-01-26 --- Add direct externalAdReply access
|
|
1260
|
+
// Lia@Changes 31-01-26 --- Add direct externalAdReply access
|
|
1273
1261
|
if (hasOptionalProperty(message, 'externalAdReply') && !!message.externalAdReply) {
|
|
1274
1262
|
const messageType = Object.keys(m)[0];
|
|
1275
1263
|
const key = m[messageType];
|
|
@@ -1278,7 +1266,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1278
1266
|
throw new Boom('Thumbnail must in buffer type', { statusCode: 400 });
|
|
1279
1267
|
}
|
|
1280
1268
|
if (!content.url || typeof content.url !== 'string') {
|
|
1281
|
-
content.url = DONATE_URL;
|
|
1269
|
+
content.url = DONATE_URL;
|
|
1282
1270
|
}
|
|
1283
1271
|
const externalAdReply = {
|
|
1284
1272
|
...content,
|
|
@@ -1364,12 +1352,12 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1364
1352
|
// Lia@Changes 02-02-26 --- Add "interactiveAsTemplate" boolean to wrap interactiveMessage into templateMessage
|
|
1365
1353
|
else if (hasOptionalProperty(message, 'interactiveAsTemplate') && !!message.interactiveAsTemplate) {
|
|
1366
1354
|
if (!m.interactiveMessage) {
|
|
1367
|
-
throw new Boom('Invalid message type for template', { statusCode: 400 });
|
|
1355
|
+
throw new Boom('Invalid message type for template', { statusCode: 400 });
|
|
1368
1356
|
}
|
|
1369
1357
|
m = {
|
|
1370
1358
|
templateMessage: {
|
|
1371
1359
|
interactiveMessageTemplate: m.interactiveMessage,
|
|
1372
|
-
templateId: message.id || 'template-' + Date.now()
|
|
1360
|
+
templateId: message.id || 'template-' + Date.now()
|
|
1373
1361
|
}
|
|
1374
1362
|
};
|
|
1375
1363
|
delete message.interactiveAsTemplate;
|
|
@@ -1428,7 +1416,7 @@ export const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
1428
1416
|
const { quoted, userJid } = options;
|
|
1429
1417
|
if (quoted) {
|
|
1430
1418
|
const participant = quoted.key.fromMe
|
|
1431
|
-
? userJid
|
|
1419
|
+
? userJid
|
|
1432
1420
|
: quoted.participant || quoted.key.participant || quoted.key.remoteJid;
|
|
1433
1421
|
let quotedMsg = normalizeMessageContent(quoted.message);
|
|
1434
1422
|
const msgType = getContentType(quotedMsg);
|
|
@@ -1465,7 +1453,6 @@ export const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
1465
1453
|
innerMessage[key].contextInfo = {
|
|
1466
1454
|
...(innerMessage[key].contextInfo || {}),
|
|
1467
1455
|
expiration: options.ephemeralExpiration || WA_DEFAULT_EPHEMERAL
|
|
1468
|
-
//ephemeralSettingTimestamp: options.ephemeralOptions.eph_setting_ts?.toString()
|
|
1469
1456
|
};
|
|
1470
1457
|
}
|
|
1471
1458
|
// Lia@Changes 30-01-26 --- Add deviceListMetadata inside messageContextInfo for private chat
|
|
@@ -1486,7 +1473,7 @@ export const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
1486
1473
|
message: message,
|
|
1487
1474
|
messageTimestamp: timestamp,
|
|
1488
1475
|
messageStubParameters: [],
|
|
1489
|
-
participant: isJidGroup(jid) || isJidStatusBroadcast(jid) ? userJid : undefined,
|
|
1476
|
+
participant: isJidGroup(jid) || isJidStatusBroadcast(jid) ? userJid : undefined,
|
|
1490
1477
|
status: WAMessageStatus.PENDING
|
|
1491
1478
|
};
|
|
1492
1479
|
return WAProto.WebMessageInfo.fromObject(messageJSON);
|
|
@@ -1731,7 +1718,7 @@ const REUPLOAD_REQUIRED_STATUS = [410, 404];
|
|
|
1731
1718
|
export const downloadMediaMessage = async (message, type, options, ctx) => {
|
|
1732
1719
|
const result = await downloadMsg().catch(async (error) => {
|
|
1733
1720
|
if (ctx &&
|
|
1734
|
-
typeof error?.status === 'number' &&
|
|
1721
|
+
typeof error?.status === 'number' &&
|
|
1735
1722
|
REUPLOAD_REQUIRED_STATUS.includes(error.status)) {
|
|
1736
1723
|
ctx.logger.info({ key: message.key }, 'sending reupload media request...');
|
|
1737
1724
|
// request reupload
|
|
@@ -1860,4 +1847,4 @@ export const shouldIncludeBizBinaryNode = (message) => !!(message.buttonsMessage
|
|
|
1860
1847
|
message.templateMessage ||
|
|
1861
1848
|
(message.interactiveMessage &&
|
|
1862
1849
|
message.interactiveMessage.nativeFlowMessage));
|
|
1863
|
-
//# sourceMappingURL=messages.js.map
|
|
1850
|
+
//# sourceMappingURL=messages.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lordmega/baileys",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.23",
|
|
4
4
|
"description": "Enhanced Baileys v7 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|