@nuiisweety/baileys 0.1.14 → 0.1.16

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.
@@ -545,37 +545,6 @@ const prepareNativeFlowButtons = (message) => {
545
545
  else if (hasOptionalProperty(button, 'sections') && !!button.sections) {
546
546
  return { name: 'single_select', buttonParamsJson: JSON.stringify({ title: buttonText || '📋 Select', sections: button.sections, icon: buttonIcon }) };
547
547
  }
548
- else if (hasOptionalProperty(button, 'catalog') && !!button.catalog) {
549
- return { name: 'cta_catalog', buttonParamsJson: JSON.stringify({ display_text: buttonText || '🛍️ Catalog', business_phone_number: button.catalog, icon: buttonIcon }) };
550
- }
551
- else if (hasOptionalProperty(button, 'reminder') && button.reminder === true) {
552
- return { name: 'cta_reminder', buttonParamsJson: JSON.stringify({ display_text: buttonText || '⏰ Remind Me', icon: buttonIcon }) };
553
- }
554
- else if (hasOptionalProperty(button, 'cancelReminder') && button.cancelReminder === true) {
555
- return { name: 'cta_cancel_reminder', buttonParamsJson: JSON.stringify({ display_text: buttonText || '❌ Cancel Reminder', icon: buttonIcon }) };
556
- }
557
- else if (hasOptionalProperty(button, 'address') && button.address === true) {
558
- return { name: 'address_message', buttonParamsJson: JSON.stringify({ display_text: buttonText || '📍 Share Address', icon: buttonIcon }) };
559
- }
560
- else if (hasOptionalProperty(button, 'location') && button.location === true) {
561
- return { name: 'send_location', buttonParamsJson: JSON.stringify({ display_text: buttonText || '📍 Send Location', icon: buttonIcon }) };
562
- }
563
- else if (hasOptionalProperty(button, 'webview') && !!button.webview) {
564
- return { name: 'open_webview', buttonParamsJson: JSON.stringify({ title: buttonText || '🌐 Open', link: { in_app_webview: button.inAppWebview !== false, url: button.webview }, icon: buttonIcon }) };
565
- }
566
- else if (hasOptionalProperty(button, 'productId') && !!button.productId) {
567
- return { name: 'mpm', buttonParamsJson: JSON.stringify({ display_text: buttonText || '🛒 View Product', product_id: button.productId, icon: buttonIcon }) };
568
- }
569
- else if (hasOptionalProperty(button, 'transactionId') && !!button.transactionId) {
570
- return { name: 'wa_payment_transaction_details', buttonParamsJson: JSON.stringify({ display_text: buttonText || '💳 Payment Details', transaction_id: button.transactionId, icon: buttonIcon }) };
571
- }
572
- else if (hasOptionalProperty(button, 'catalogProduct') && !!button.catalogProduct) {
573
- return { name: 'automated_greeting_message_view_catalog', buttonParamsJson: JSON.stringify({ display_text: buttonText || '🛍️ View Catalog', business_phone_number: button.catalogProduct.bizPhone, catalog_product_id: button.catalogProduct.productId, icon: buttonIcon }) };
574
- }
575
- else if (hasOptionalProperty(button, 'flow') && !!button.flow) {
576
- const f = button.flow;
577
- return { name: 'galaxy_message', buttonParamsJson: JSON.stringify({ mode: f.mode || 'published', flow_message_version: f.flowMessageVersion || '3', flow_token: f.flowToken, flow_id: f.flowId, flow_cta: buttonText || f.flowCta || '▶️ Open Flow', flow_action: f.flowAction || 'navigate', flow_action_payload: f.flowActionPayload, flow_metadata: f.flowMetadata, icon: buttonIcon }) };
578
- }
579
548
  return button;
580
549
  }),
581
550
  messageParamsJson: JSON.stringify(messageParamsJson),
@@ -950,80 +919,6 @@ export const generateWAMessageContent = async (message, options) => {
950
919
  }
951
920
  };
952
921
  }
953
- else if (hasNonNullishProperty(message, 'orderStatus')) {
954
- const os = message.orderStatus;
955
- if (!os.image) {
956
- throw new Boom('"image" wajib diisi untuk orderStatus', { statusCode: 400 });
957
- }
958
- let imageInput = os.image;
959
- if (typeof imageInput === 'string' && !imageInput.startsWith('http://') && !imageInput.startsWith('https://')) {
960
- imageInput = await fs.readFile(imageInput);
961
- }
962
- const media = await prepareWAMessageMedia({ image: imageInput }, options);
963
- m = {
964
- viewOnceMessage: {
965
- message: {
966
- messageContextInfo: {
967
- deviceListMetadata: {},
968
- deviceListMetadataVersion: 2
969
- },
970
- interactiveMessage: proto.Message.InteractiveMessage.create({
971
- header: {
972
- title: os.title || 'Status Pesanan',
973
- hasMediaAttachment: true,
974
- ...media
975
- },
976
- body: { text: os.text || 'Silakan cek status pesanan Anda.' },
977
- footer: { text: os.footer || '' },
978
- nativeFlowMessage: {
979
- buttons: [{
980
- name: 'order_status',
981
- buttonParamsJson: JSON.stringify({
982
- reference_id: os.referenceId || 'ORDER-001',
983
- order: {
984
- status: os.status || 'PROCESSING',
985
- subtotal: {
986
- value: os.subtotalValue || 0,
987
- offset: os.subtotalOffset || 100
988
- },
989
- tax: {
990
- value: os.taxValue || 0,
991
- offset: os.taxOffset || 100
992
- },
993
- currency: os.currency || 'IDR'
994
- }
995
- })
996
- }]
997
- }
998
- })
999
- }
1000
- }
1001
- };
1002
- }
1003
- else if (hasNonNullishProperty(message, 'productList')) {
1004
- let thumbnail = null;
1005
- if (message.thumbnail) {
1006
- const { imageMessage } = await prepareWAMessageMedia({ image: message.thumbnail }, options);
1007
- thumbnail = imageMessage;
1008
- }
1009
- m = {
1010
- listMessage: {
1011
- title: message.title,
1012
- buttonText: message.buttonText || 'Lihat Produk',
1013
- footerText: message.footer,
1014
- description: message.text,
1015
- productListInfo: {
1016
- productSections: message.productList,
1017
- headerImage: {
1018
- productId: message.productList?.[0]?.products?.[0]?.productId,
1019
- jpegThumbnail: thumbnail?.jpegThumbnail || null
1020
- },
1021
- businessOwnerJid: message.businessOwnerJid
1022
- },
1023
- listType: proto.Message.ListMessage.ListType.PRODUCT_LIST
1024
- }
1025
- };
1026
- }
1027
922
  else if (hasNonNullishProperty(message, 'buttonsMessage')) {
1028
923
  // Direct buttonsMessage passthrough — supports headerType 6 (locationMessage), etc.
1029
924
  const btnMsg = { ...message.buttonsMessage };
@@ -1276,74 +1171,6 @@ export const generateWAMessageContent = async (message, options) => {
1276
1171
  }
1277
1172
  m = { interactiveMessage };
1278
1173
  }
1279
- else if (hasNonNullishProperty(message, 'shop')) {
1280
- const interactiveMessage = {
1281
- shopStorefrontMessage: {
1282
- surface: message.shop.surface || 1,
1283
- id: message.shop.id,
1284
- messageVersion: 1
1285
- }
1286
- };
1287
- if (hasOptionalProperty(message, 'caption')) {
1288
- // Media header mode — m already contains mediaMessage from chain 1 else block
1289
- const mediaKey = Object.keys(m)[0]; // e.g. 'videoMessage', 'imageMessage'
1290
- interactiveMessage.header = {
1291
- title: message.title || '',
1292
- subtitle: message.subtitle || '',
1293
- hasMediaAttachment: true,
1294
- [mediaKey]: m[mediaKey]
1295
- };
1296
- interactiveMessage.body = { text: message.caption };
1297
- }
1298
- else if (hasOptionalProperty(message, 'text')) {
1299
- interactiveMessage.body = { text: message.text };
1300
- if (hasOptionalProperty(message, 'title')) {
1301
- interactiveMessage.header = {
1302
- title: message.title,
1303
- subtitle: message.subtitle || null,
1304
- hasMediaAttachment: false
1305
- };
1306
- }
1307
- }
1308
- if (hasOptionalProperty(message, 'footer')) {
1309
- interactiveMessage.footer = { text: message.footer };
1310
- }
1311
- m = { interactiveMessage };
1312
- }
1313
- else if (hasNonNullishProperty(message, 'collection')) {
1314
- const interactiveMessage = {
1315
- collectionMessage: {
1316
- bizJid: message.collection.bizJid,
1317
- id: message.collection.id,
1318
- messageVersion: message.collection.version || 1
1319
- }
1320
- };
1321
- if (hasOptionalProperty(message, 'caption')) {
1322
- // Media header mode
1323
- const mediaKey = Object.keys(m)[0];
1324
- interactiveMessage.header = {
1325
- title: message.title || '',
1326
- subtitle: message.subtitle || '',
1327
- hasMediaAttachment: true,
1328
- [mediaKey]: m[mediaKey]
1329
- };
1330
- interactiveMessage.body = { text: message.caption };
1331
- }
1332
- else if (hasOptionalProperty(message, 'text')) {
1333
- interactiveMessage.body = { text: message.text };
1334
- if (hasOptionalProperty(message, 'title')) {
1335
- interactiveMessage.header = {
1336
- title: message.title,
1337
- subtitle: message.subtitle || null,
1338
- hasMediaAttachment: false
1339
- };
1340
- }
1341
- }
1342
- if (hasOptionalProperty(message, 'footer')) {
1343
- interactiveMessage.footer = { text: message.footer };
1344
- }
1345
- m = { interactiveMessage };
1346
- }
1347
1174
  else if (hasNonNullishProperty(message, 'requestPaymentFrom')) {
1348
1175
  const requestPaymentMessage = {
1349
1176
  amount: {
@@ -676,7 +676,7 @@ const makeProductSection = (data) => {
676
676
  return {
677
677
  sub: {
678
678
  messageType: RichSubMessageType.TEXT,
679
- messageText: '[ CANNOT_LOAD_PRODUCT ]'
679
+ messageText: ''
680
680
  },
681
681
  section: isMultiple
682
682
  ? {
@@ -721,7 +721,7 @@ const makePostSection = (data) => {
721
721
  return {
722
722
  sub: {
723
723
  messageType: RichSubMessageType.TEXT,
724
- messageText: '[ CANNOT_LOAD_POST ]'
724
+ messageText: ''
725
725
  },
726
726
  section: {
727
727
  view_model: {
@@ -825,7 +825,6 @@ export const prepareRichResponseMessage = (content) => {
825
825
  /* ── mode flat (convenience fields) ── */
826
826
  } else {
827
827
  if (headerText) submessages.push(makeTextSub(headerText));
828
- if (contentText) submessages.push(makeTextSub(contentText));
829
828
 
830
829
  if (code) submessages.push(makeCodeSub(code, language || 'javascript'));
831
830
  if (table) submessages.push(makeTableSub(table, title, noHeading));
@@ -843,6 +842,7 @@ export const prepareRichResponseMessage = (content) => {
843
842
  if (source) { if (!extraSections) extraSections = []; extraSections.push(makeSourceSection(source)); }
844
843
  if (richProduct) pushRich(makeProductSection(richProduct));
845
844
  if (richPost) pushRich(makePostSection(richPost));
845
+ if (contentText) submessages.push(makeTextSub(contentText)); // ← setelah produk/post, tampil di bawah card
846
846
  if (tip) pushRich(makeTipSub(tip));
847
847
  if (suggest) { if (!extraSections) extraSections = []; extraSections.push(makeSuggestSection(suggest)); }
848
848
 
@@ -598,8 +598,13 @@ const makeVideoSub = (videoUrl) => {
598
598
  });
599
599
  return {
600
600
  sub: {
601
- messageType: RichSubMessageType.TEXT,
602
- messageText: '[ CANNOT_LOAD_VIDEO ]'
601
+ messageType: RichSubMessageType.DYNAMIC,
602
+ dynamicMetadata: {
603
+ type: 1,
604
+ version: 1,
605
+ url: parsed[0]?.url || '',
606
+ loopCount: 0
607
+ }
603
608
  },
604
609
  sections: parsed.map(({ url, duration }) => ({
605
610
  view_model: {
@@ -873,10 +878,17 @@ export const prepareRichResponseMessage = (content) => {
873
878
  }
874
879
 
875
880
  /* build unifiedResponse JSON — gabungkan sections dari submessages + extraSections */
876
- const baseUnified = toUnified(submessages);
881
+ // Pisahkan footerSubs (teks setelah media) agar selalu muncul SETELAH extraSections (video/image)
882
+ const footerSubMessages = footerText ? [makeTextSub(footerText)] : [];
883
+ // Hapus footerText dari submessages jika sudah ada (sudah di-push sebelumnya)
884
+ const mainSubmessages = footerText
885
+ ? submessages.filter(s => !(s.messageType === RichSubMessageType.TEXT && s.messageText === footerText))
886
+ : submessages;
887
+ const baseUnified = toUnified(mainSubmessages);
888
+ const footerSections = footerSubMessages.map(buildUnifiedSection);
877
889
  const unified = extraSections && extraSections.length > 0
878
- ? { ...baseUnified, sections: [...baseUnified.sections, ...extraSections] }
879
- : baseUnified;
890
+ ? { ...baseUnified, sections: [...baseUnified.sections, ...extraSections, ...footerSections] }
891
+ : { ...baseUnified, sections: [...baseUnified.sections, ...footerSections] };
880
892
 
881
893
  const richResponseMessage = proto.AIRichResponseMessage.create({
882
894
  submessages,
@@ -887,7 +899,6 @@ export const prepareRichResponseMessage = (content) => {
887
899
  contextInfo: {
888
900
  isForwarded: true,
889
901
  forwardingScore: 1,
890
- forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' },
891
902
  forwardOrigin: 4
892
903
  }
893
904
  });
@@ -955,7 +966,6 @@ const buildRichContextInfo = (quoted) => {
955
966
  const ctxInfo = {
956
967
  isForwarded: true,
957
968
  forwardingScore: 1,
958
- forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' },
959
969
  forwardOrigin: 4,
960
970
  };
961
971
  if (quoted?.key) {
@@ -1104,7 +1114,7 @@ export const captureUnifiedResponse = (msg) => {
1104
1114
  // ── Link ──────────────────────────────────────────────────
1105
1115
 
1106
1116
  export const generateLinkContent = (text, links, quoted, options = {}) => {
1107
- const { footer, botJid = '867051314767696@bot', forwardingScore = 3, citations = [], proofs = [] } = options;
1117
+ const { footer, forwardingScore = 3, citations = [], proofs = [] } = options;
1108
1118
  const subs = [];
1109
1119
  const fullText = footer ? `${text}${footer}` : text;
1110
1120
  subs.push({ messageType: RichSubMessageType.TEXT, messageText: fullText });
@@ -1120,7 +1130,6 @@ export const generateLinkContent = (text, links, quoted, options = {}) => {
1120
1130
  const base64Data = Buffer.from(JSON.stringify({ response_id: randomUUID(), sections })).toString('base64');
1121
1131
  const ctxInfo = buildRichContextInfo(quoted);
1122
1132
  ctxInfo.forwardingScore = forwardingScore;
1123
- ctxInfo.forwardedAiBotMessageInfo = { botJid };
1124
1133
  ctxInfo.botMessageSharingInfo = { forwardScore: forwardingScore };
1125
1134
  const messageContextInfo = { messageSecret: randomBytes(32) };
1126
1135
  if (citations.length > 0 || proofs.length > 0) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nuiisweety/baileys",
3
3
  "type": "module",
4
- "version": "0.1.14",
5
- "description": "A WebSockets library for interacting with WhatsApp Web — forked STRICTLY from @whiskeysockets/baileys only, NOT from any other baileys fork. Modified by NuiiSweety.",
4
+ "version": "0.1.16",
5
+ "description": "A WebSockets library for interacting with WhatsApp Web — forked STRICTLY from @whiskeysockets/baileys only, NOT from any other baileys fork. Modified by NuiiS4TORU.",
6
6
  "keywords": [
7
7
  "whatsapp",
8
8
  "automation"
@@ -12,7 +12,7 @@
12
12
  "url": "git@github.com:WhiskeySockets/Baileys.git"
13
13
  },
14
14
  "license": "MIT",
15
- "author": "NuiiSweety (based on WhiskeySockets/Baileys)",
15
+ "author": "NuiiS4TORU (based on WhiskeySockets/Baileys)",
16
16
  "main": "lib/index.js",
17
17
  "types": "lib/index.d.ts",
18
18
  "files": [