@nuiisweety/baileys 0.1.13 → 0.1.14

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 CHANGED
@@ -7,7 +7,7 @@
7
7
  *Fork dari [`@whiskeysockets/baileys`](https://github.com/WhiskeySockets/Baileys) v7.0.0-rc11*
8
8
  *dikembangkan dengan sepenuh hati oleh **NuiiS4TORU***
9
9
 
10
- [![npm version](https://img.shields.io/badge/npm-0.1.13-pink?style=flat-square&logo=npm)](https://www.npmjs.com/package/@nuiisweety/baileys)
10
+ [![npm version](https://img.shields.io/badge/npm-0.1.14-pink?style=flat-square&logo=npm)](https://www.npmjs.com/package/@nuiisweety/baileys)
11
11
  [![license](https://img.shields.io/badge/license-MIT-lavender?style=flat-square)](LICENSE)
12
12
  [![based on](https://img.shields.io/badge/based%20on-@whiskeysockets%2Fbaileys-orchid?style=flat-square)](https://github.com/WhiskeySockets/Baileys)
13
13
 
@@ -950,6 +950,80 @@ export const generateWAMessageContent = async (message, options) => {
950
950
  }
951
951
  };
952
952
  }
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
+ }
953
1027
  else if (hasNonNullishProperty(message, 'buttonsMessage')) {
954
1028
  // Direct buttonsMessage passthrough — supports headerType 6 (locationMessage), etc.
955
1029
  const btnMsg = { ...message.buttonsMessage };
@@ -1210,25 +1284,26 @@ export const generateWAMessageContent = async (message, options) => {
1210
1284
  messageVersion: 1
1211
1285
  }
1212
1286
  };
1213
- if (hasOptionalProperty(message, 'text')) {
1214
- interactiveMessage.body = { text: message.text };
1215
- }
1216
- else if (hasOptionalProperty(message, 'caption')) {
1217
- const isValidHeader = hasValidInteractiveHeader(m);
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'
1218
1290
  interactiveMessage.header = {
1219
1291
  title: message.title || '',
1220
1292
  subtitle: message.subtitle || '',
1221
- hasMediaAttachment: isValidHeader
1293
+ hasMediaAttachment: true,
1294
+ [mediaKey]: m[mediaKey]
1222
1295
  };
1223
1296
  interactiveMessage.body = { text: message.caption };
1224
- Object.assign(interactiveMessage.header, m);
1225
1297
  }
1226
- if (hasOptionalProperty(message, 'title') && !hasOptionalProperty(message, 'caption')) {
1227
- interactiveMessage.header = {
1228
- title: message.title,
1229
- subtitle: message.subtitle || null,
1230
- hasMediaAttachment: false
1231
- };
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
+ }
1232
1307
  }
1233
1308
  if (hasOptionalProperty(message, 'footer')) {
1234
1309
  interactiveMessage.footer = { text: message.footer };
@@ -1243,106 +1318,32 @@ export const generateWAMessageContent = async (message, options) => {
1243
1318
  messageVersion: message.collection.version || 1
1244
1319
  }
1245
1320
  };
1246
- if (hasOptionalProperty(message, 'text')) {
1247
- interactiveMessage.body = { text: message.text };
1248
- }
1249
- else if (hasOptionalProperty(message, 'caption')) {
1250
- const isValidHeader = hasValidInteractiveHeader(m);
1321
+ if (hasOptionalProperty(message, 'caption')) {
1322
+ // Media header mode
1323
+ const mediaKey = Object.keys(m)[0];
1251
1324
  interactiveMessage.header = {
1252
1325
  title: message.title || '',
1253
1326
  subtitle: message.subtitle || '',
1254
- hasMediaAttachment: isValidHeader
1327
+ hasMediaAttachment: true,
1328
+ [mediaKey]: m[mediaKey]
1255
1329
  };
1256
1330
  interactiveMessage.body = { text: message.caption };
1257
- Object.assign(interactiveMessage.header, m);
1258
1331
  }
1259
- if (hasOptionalProperty(message, 'title') && !hasOptionalProperty(message, 'caption')) {
1260
- interactiveMessage.header = {
1261
- title: message.title,
1262
- subtitle: message.subtitle || null,
1263
- hasMediaAttachment: false
1264
- };
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
+ }
1265
1341
  }
1266
1342
  if (hasOptionalProperty(message, 'footer')) {
1267
1343
  interactiveMessage.footer = { text: message.footer };
1268
1344
  }
1269
1345
  m = { interactiveMessage };
1270
1346
  }
1271
- else if (hasNonNullishProperty(message, 'orderStatus')) {
1272
- const os = message.orderStatus;
1273
- if (!os.image) {
1274
- throw new Boom('"image" wajib diisi untuk orderStatus', { statusCode: 400 });
1275
- }
1276
- let imageInput = os.image;
1277
- if (typeof imageInput === 'string' && !imageInput.startsWith('http://') && !imageInput.startsWith('https://')) {
1278
- const { promises: fsPromises } = await import('fs');
1279
- imageInput = await fsPromises.readFile(imageInput);
1280
- }
1281
- const media = await prepareWAMessageMedia({ image: imageInput }, options);
1282
- m = {
1283
- viewOnceMessage: {
1284
- message: {
1285
- messageContextInfo: {
1286
- deviceListMetadata: {},
1287
- deviceListMetadataVersion: 2
1288
- },
1289
- interactiveMessage: proto.Message.InteractiveMessage.create({
1290
- header: {
1291
- title: os.title || 'Status Pesanan',
1292
- hasMediaAttachment: true,
1293
- ...media
1294
- },
1295
- body: { text: os.text || 'Silakan cek status pesanan Anda.' },
1296
- footer: { text: os.footer || '' },
1297
- nativeFlowMessage: {
1298
- buttons: [{
1299
- name: 'order_status',
1300
- buttonParamsJson: JSON.stringify({
1301
- reference_id: os.referenceId || 'ORDER-001',
1302
- order: {
1303
- status: os.status || 'PROCESSING',
1304
- subtotal: {
1305
- value: os.subtotalValue || 0,
1306
- offset: os.subtotalOffset || 100
1307
- },
1308
- tax: {
1309
- value: os.taxValue || 0,
1310
- offset: os.taxOffset || 100
1311
- },
1312
- currency: os.currency || 'IDR'
1313
- }
1314
- })
1315
- }]
1316
- }
1317
- })
1318
- }
1319
- }
1320
- };
1321
- }
1322
- else if (hasNonNullishProperty(message, 'productList')) {
1323
- let thumbnail = null;
1324
- if (message.thumbnail) {
1325
- const { imageMessage } = await prepareWAMessageMedia({ image: message.thumbnail }, options);
1326
- thumbnail = imageMessage;
1327
- }
1328
- m = {
1329
- listMessage: {
1330
- title: message.title,
1331
- buttonText: message.buttonText || 'Lihat Produk',
1332
- footerText: message.footer,
1333
- description: message.text,
1334
- productListInfo: {
1335
- productSections: message.productList,
1336
- headerImage: {
1337
- productId: message.productList?.[0]?.products?.[0]?.productId,
1338
- jpegThumbnail: thumbnail?.jpegThumbnail || null
1339
- },
1340
- businessOwnerJid: message.businessOwnerJid
1341
- },
1342
- listType: proto.Message.ListMessage.ListType.PRODUCT_LIST
1343
- }
1344
- };
1345
- }
1346
1347
  else if (hasNonNullishProperty(message, 'requestPaymentFrom')) {
1347
1348
  const requestPaymentMessage = {
1348
1349
  amount: {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nuiisweety/baileys",
3
3
  "type": "module",
4
- "version": "0.1.13",
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.",
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.",
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": "© NuiiS4TORU (based on WhiskeySockets/Baileys)",
15
+ "author": "NuiiSweety (based on WhiskeySockets/Baileys)",
16
16
  "main": "lib/index.js",
17
17
  "types": "lib/index.d.ts",
18
18
  "files": [