@builderbot/provider-meta 1.4.2-alpha.1 → 1.4.2-alpha.6

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/dist/index.cjs CHANGED
@@ -25450,9 +25450,12 @@ const processIncomingMessage = async ({ messageId, messageTimestamp, pushName, m
25450
25450
  break;
25451
25451
  }
25452
25452
  case 'sticker': {
25453
+ const stickerUrl = await getMediaUrl(version, message.sticker?.id, numberId, jwtToken);
25453
25454
  responseObj = {
25454
25455
  type: message.type,
25455
25456
  from: message.from,
25457
+ url: stickerUrl ?? fileData?.url,
25458
+ fileData,
25456
25459
  to,
25457
25460
  id: message.sticker.id,
25458
25461
  body: bot.utils.generateRefProvider('_event_media_'),
@@ -25694,6 +25697,7 @@ async function downloadFile(url, Token) {
25694
25697
  }
25695
25698
  catch (error) {
25696
25699
  console.error(error.message);
25700
+ throw error;
25697
25701
  }
25698
25702
  }
25699
25703
 
@@ -25976,8 +25980,8 @@ class MetaProvider extends bot.ProviderClass {
25976
25980
  if (mimeType.includes('video'))
25977
25981
  return this.sendVideo(to, fileDownloaded, text, context);
25978
25982
  if (mimeType.includes('audio')) {
25979
- const fileOpus = await bot.utils.convertAudio(mediaInput, 'mp3');
25980
- return this.sendAudio(to, fileOpus, context);
25983
+ // sendAudio handles conversion to OGG/Opus automatically
25984
+ return this.sendAudio(to, mediaInput, context);
25981
25985
  }
25982
25986
  return this.sendFile(to, mediaInput, text, context);
25983
25987
  };
@@ -26377,7 +26381,7 @@ class MetaProvider extends bot.ProviderClass {
26377
26381
  /**
26378
26382
  * Send an audio message by uploading a local file
26379
26383
  * @param to - Recipient phone number
26380
- * @param pathVideo - Local path to the audio file (supports mp3, m4a, aac, amr, ogg with opus codec)
26384
+ * @param pathVideo - Local path to the audio file (supports mp3, m4a, aac, amr, ogg - auto-converts to ogg/opus)
26381
26385
  * @param context - Optional message ID to reply to
26382
26386
  * @returns Promise with the API response
26383
26387
  * @throws Error if pathVideo is null
@@ -26388,16 +26392,15 @@ class MetaProvider extends bot.ProviderClass {
26388
26392
  to = parseMetaNumber(to);
26389
26393
  if (!pathVideo)
26390
26394
  throw new Error(`MEDIA_INPUT_NULL_: ${pathVideo}`);
26391
- const formData = new FormData();
26395
+ let audioPath = pathVideo;
26392
26396
  const mimeType = mime.lookup(pathVideo);
26393
- if (['audio/ogg'].includes(mimeType)) {
26394
- console.log([
26395
- `Format (${mimeType}) not supported, you should use`,
26396
- `https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#supported-media-types`,
26397
- ].join('\n'));
26397
+ // Auto-convert to OGG/Opus if not already in that format (required for voice notes)
26398
+ if (!mimeType?.includes('ogg') && !mimeType?.includes('opus')) {
26399
+ audioPath = await bot.utils.convertAudio(pathVideo, 'opus');
26398
26400
  }
26399
- formData.append('file', require$$6.createReadStream(pathVideo), {
26400
- contentType: mimeType,
26401
+ const formData = new FormData();
26402
+ formData.append('file', require$$6.createReadStream(audioPath), {
26403
+ contentType: 'audio/ogg',
26401
26404
  });
26402
26405
  formData.append('messaging_product', 'whatsapp');
26403
26406
  const { data: { id: mediaId }, } = await axios.post(`${URL}/${this.globalVendorArgs.version}/${this.globalVendorArgs.numberId}/media`, formData, {
@@ -26412,6 +26415,7 @@ class MetaProvider extends bot.ProviderClass {
26412
26415
  type: 'audio',
26413
26416
  audio: {
26414
26417
  id: mediaId,
26418
+ voice: true, // Sends as voice note (PTT) instead of audio file
26415
26419
  },
26416
26420
  };
26417
26421
  if (context)
@@ -264,7 +264,7 @@ declare class MetaProvider extends ProviderClass<MetaInterface> implements MetaI
264
264
  /**
265
265
  * Send an audio message by uploading a local file
266
266
  * @param to - Recipient phone number
267
- * @param pathVideo - Local path to the audio file (supports mp3, m4a, aac, amr, ogg with opus codec)
267
+ * @param pathVideo - Local path to the audio file (supports mp3, m4a, aac, amr, ogg - auto-converts to ogg/opus)
268
268
  * @param context - Optional message ID to reply to
269
269
  * @returns Promise with the API response
270
270
  * @throws Error if pathVideo is null
@@ -1 +1 @@
1
- {"version":3,"file":"downloadFile.d.ts","sourceRoot":"","sources":["../../src/utils/downloadFile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAG1C;;;;GAIG;AACH,QAAA,MAAM,gBAAgB,GAAU,UAAU,aAAa,KAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAO7G,CAAA;AAED,iBAAe,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBtG;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"downloadFile.d.ts","sourceRoot":"","sources":["../../src/utils/downloadFile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAG1C;;;;GAIG;AACH,QAAA,MAAM,gBAAgB,GAAU,UAAU,aAAa,KAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAO7G,CAAA;AAED,iBAAe,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBtG;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"processIncomingMsg.d.ts","sourceRoot":"","sources":["../../src/utils/processIncomingMsg.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEvF,eAAO,MAAM,sBAAsB,GAAU,wGAW1C,qBAAqB,KAAG,OAAO,CAAC,OAAO,CA4KzC,CAAA"}
1
+ {"version":3,"file":"processIncomingMsg.d.ts","sourceRoot":"","sources":["../../src/utils/processIncomingMsg.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEvF,eAAO,MAAM,sBAAsB,GAAU,wGAW1C,qBAAqB,KAAG,OAAO,CAAC,OAAO,CA+KzC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builderbot/provider-meta",
3
- "version": "1.4.2-alpha.1",
3
+ "version": "1.4.2-alpha.6",
4
4
  "description": "> TODO: description",
5
5
  "author": "vicente1992 <vic_ortiz20@hotmail.es>",
6
6
  "homepage": "https://github.com/vicente1992/bot-whatsapp#readme",
@@ -38,7 +38,7 @@
38
38
  "queue-promise": "^2.2.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@builderbot/bot": "^1.4.2-alpha.1",
41
+ "@builderbot/bot": "^1.4.2-alpha.6",
42
42
  "@jest/globals": "^30.2.0",
43
43
  "@rollup/plugin-commonjs": "^29.0.0",
44
44
  "@rollup/plugin-json": "^6.1.0",
@@ -61,5 +61,5 @@
61
61
  "tslib": "^2.6.2",
62
62
  "tsm": "^2.3.0"
63
63
  },
64
- "gitHead": "0e51f341c67b873fe1eb0cffa6ff0355ef7ef048"
64
+ "gitHead": "c141dedbefba1d3297062966d9f02f89e83c4092"
65
65
  }