@builderbot/provider-meta 1.4.2-alpha.2 → 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
@@ -25980,8 +25980,8 @@ class MetaProvider extends bot.ProviderClass {
25980
25980
  if (mimeType.includes('video'))
25981
25981
  return this.sendVideo(to, fileDownloaded, text, context);
25982
25982
  if (mimeType.includes('audio')) {
25983
- const fileOpus = await bot.utils.convertAudio(mediaInput, 'mp3');
25984
- return this.sendAudio(to, fileOpus, context);
25983
+ // sendAudio handles conversion to OGG/Opus automatically
25984
+ return this.sendAudio(to, mediaInput, context);
25985
25985
  }
25986
25986
  return this.sendFile(to, mediaInput, text, context);
25987
25987
  };
@@ -26381,7 +26381,7 @@ class MetaProvider extends bot.ProviderClass {
26381
26381
  /**
26382
26382
  * Send an audio message by uploading a local file
26383
26383
  * @param to - Recipient phone number
26384
- * @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)
26385
26385
  * @param context - Optional message ID to reply to
26386
26386
  * @returns Promise with the API response
26387
26387
  * @throws Error if pathVideo is null
@@ -26392,16 +26392,15 @@ class MetaProvider extends bot.ProviderClass {
26392
26392
  to = parseMetaNumber(to);
26393
26393
  if (!pathVideo)
26394
26394
  throw new Error(`MEDIA_INPUT_NULL_: ${pathVideo}`);
26395
- const formData = new FormData();
26395
+ let audioPath = pathVideo;
26396
26396
  const mimeType = mime.lookup(pathVideo);
26397
- if (['audio/ogg'].includes(mimeType)) {
26398
- console.log([
26399
- `Format (${mimeType}) not supported, you should use`,
26400
- `https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#supported-media-types`,
26401
- ].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');
26402
26400
  }
26403
- formData.append('file', require$$6.createReadStream(pathVideo), {
26404
- contentType: mimeType,
26401
+ const formData = new FormData();
26402
+ formData.append('file', require$$6.createReadStream(audioPath), {
26403
+ contentType: 'audio/ogg',
26405
26404
  });
26406
26405
  formData.append('messaging_product', 'whatsapp');
26407
26406
  const { data: { id: mediaId }, } = await axios.post(`${URL}/${this.globalVendorArgs.version}/${this.globalVendorArgs.numberId}/media`, formData, {
@@ -26416,6 +26415,7 @@ class MetaProvider extends bot.ProviderClass {
26416
26415
  type: 'audio',
26417
26416
  audio: {
26418
26417
  id: mediaId,
26418
+ voice: true, // Sends as voice note (PTT) instead of audio file
26419
26419
  },
26420
26420
  };
26421
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builderbot/provider-meta",
3
- "version": "1.4.2-alpha.2",
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.2",
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": "f11fc19dba603564f37c9c5a84a4c6ba3d37a1c6"
64
+ "gitHead": "c141dedbefba1d3297062966d9f02f89e83c4092"
65
65
  }