@vinzsocket/baileys 3.3.1 → 3.3.13
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/lib/Utils/messages.d.ts
CHANGED
|
@@ -87,5 +87,10 @@ type DownloadMediaMessageContext = {
|
|
|
87
87
|
export declare const downloadMediaMessage: <Type extends "buffer" | "stream">(message: WAMessage, type: Type, options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Type extends "buffer" ? Buffer : Transform>;
|
|
88
88
|
/** Checks whether the given message is a media message; if it is returns the inner content */
|
|
89
89
|
export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
90
|
+
/** Builds the `<biz><interactive native_flow></interactive></biz>` additionalNodes payload required for interactive/native-flow (button, list, carousel) messages to render on WhatsApp. */
|
|
91
|
+
export declare const buildInteractiveAdditionalNodes: (jid?: string, message?: unknown, options?: {
|
|
92
|
+
name?: string;
|
|
93
|
+
v?: string;
|
|
94
|
+
}) => Array<Record<string, unknown>>;
|
|
90
95
|
export {};
|
|
91
96
|
//# sourceMappingURL=messages.d.ts.map
|
package/lib/Utils/messages.js
CHANGED
|
@@ -1237,4 +1237,43 @@ export const assertMediaContent = (content) => {
|
|
|
1237
1237
|
}
|
|
1238
1238
|
return mediaContent;
|
|
1239
1239
|
};
|
|
1240
|
+
/**
|
|
1241
|
+
* Builds the `additionalNodes` payload WhatsApp requires to recognize an
|
|
1242
|
+
* outgoing message as an interactive / native-flow message (buttons, single
|
|
1243
|
+
* & multi select lists, carousels, CTA buttons, etc).
|
|
1244
|
+
*
|
|
1245
|
+
* Without this `<biz><interactive native_flow></interactive></biz>` node
|
|
1246
|
+
* attached via `relayMessage(jid, message, { additionalNodes })`, WhatsApp's
|
|
1247
|
+
* servers silently accept the message but never render the buttons — the
|
|
1248
|
+
* message just shows up as the body text with no interactive UI.
|
|
1249
|
+
*
|
|
1250
|
+
* This mirrors the exact node shape already used internally for every
|
|
1251
|
+
* interactive send in this library (see Modded/message_builder.js), so it is
|
|
1252
|
+
* safe to reuse for any hand-built interactiveMessage/nativeFlowMessage.
|
|
1253
|
+
*
|
|
1254
|
+
* @param {string} [_jid] - kept for call-signature compatibility (e.g. `buildInteractiveAdditionalNodes(jid, message)`), currently unused
|
|
1255
|
+
* @param {object} [_message] - kept for call-signature compatibility, currently unused
|
|
1256
|
+
* @param {{ name?: string, v?: string }} [options] - override the native_flow `name`/`v` attrs if needed
|
|
1257
|
+
* @returns {Array<object>} additionalNodes array ready to pass to relayMessage
|
|
1258
|
+
*/
|
|
1259
|
+
export const buildInteractiveAdditionalNodes = (_jid, _message, options = {}) => {
|
|
1260
|
+
return [
|
|
1261
|
+
{
|
|
1262
|
+
tag: 'biz',
|
|
1263
|
+
attrs: {},
|
|
1264
|
+
content: [
|
|
1265
|
+
{
|
|
1266
|
+
tag: 'interactive',
|
|
1267
|
+
attrs: { type: 'native_flow', v: '1' },
|
|
1268
|
+
content: [
|
|
1269
|
+
{
|
|
1270
|
+
tag: 'native_flow',
|
|
1271
|
+
attrs: { v: options.v || '9', name: options.name || 'mixed' },
|
|
1272
|
+
},
|
|
1273
|
+
],
|
|
1274
|
+
},
|
|
1275
|
+
],
|
|
1276
|
+
},
|
|
1277
|
+
];
|
|
1278
|
+
};
|
|
1240
1279
|
//# sourceMappingURL=messages.js.map
|
package/lib/VoIP/audio-feeder.js
CHANGED
|
@@ -68,6 +68,14 @@ export class AudioFeeder {
|
|
|
68
68
|
this.#proc.stderr.on("data", (chunk) => {
|
|
69
69
|
process.stderr.write(`[AudioFeeder] ${chunk.toString().trim()}\n`);
|
|
70
70
|
});
|
|
71
|
+
this.#proc.on("error", (err) => {
|
|
72
|
+
// Without this handler, a missing/unspawnable ffmpeg binary (e.g.
|
|
73
|
+
// ENOENT) throws an *uncaught* 'error' event and crashes the whole
|
|
74
|
+
// bot process instead of just failing this one call's audio feed.
|
|
75
|
+
process.stderr.write(`[AudioFeeder] Gagal menjalankan ffmpeg: ${err.message}\n`);
|
|
76
|
+
process.stderr.write(`[AudioFeeder] Pastikan ffmpeg terinstal & tersedia di PATH sistem (cek dengan: ffmpeg -version).\n`);
|
|
77
|
+
this.#proc = null;
|
|
78
|
+
});
|
|
71
79
|
this.#proc.on("exit", (code) => {
|
|
72
80
|
if (code !== 0 && code !== null) {
|
|
73
81
|
process.stderr.write(`[AudioFeeder] ffmpeg exited with code=${code}\n`);
|
|
@@ -553,7 +553,21 @@ export class RelayRtcTransport {
|
|
|
553
553
|
connection.peerConnection = null;
|
|
554
554
|
};
|
|
555
555
|
#loadWrtc = () => {
|
|
556
|
-
this.#wrtcPromise ??= import("@roamhq/wrtc")
|
|
556
|
+
this.#wrtcPromise ??= import("@roamhq/wrtc")
|
|
557
|
+
.then((module) => (module.default ?? module))
|
|
558
|
+
.catch((err) => {
|
|
559
|
+
// @roamhq/wrtc is only an *optional* peer dependency, so a fresh
|
|
560
|
+
// `npm install` won't pull it in automatically. Without it there is
|
|
561
|
+
// no RTCPeerConnection available, so the relay/data-channel (i.e.
|
|
562
|
+
// the actual call audio path) can never open — surface that clearly
|
|
563
|
+
// instead of letting callers hit a generic "not a function" error.
|
|
564
|
+
this.#wrtcPromise = null;
|
|
565
|
+
throw new Error(
|
|
566
|
+
"VoIP call audio requires the '@roamhq/wrtc' package, which is not installed. " +
|
|
567
|
+
"Run `npm install @roamhq/wrtc` in your bot project, then try the call again. " +
|
|
568
|
+
`(underlying error: ${err.message})`
|
|
569
|
+
);
|
|
570
|
+
});
|
|
557
571
|
return this.#wrtcPromise;
|
|
558
572
|
};
|
|
559
573
|
}
|
|
@@ -767,7 +767,14 @@ if (typedWorkerData && (typedWorkerData.loaderCode || typedWorkerData.workerModu
|
|
|
767
767
|
catch (e) { }
|
|
768
768
|
}
|
|
769
769
|
if (!wasmLoader) {
|
|
770
|
-
|
|
770
|
+
// typedWorkerData.resourcesPath (when provided by wasm-engine.js) points at
|
|
771
|
+
// the package's `lib/` base dir, matching its own convention of appending
|
|
772
|
+
// "assets/wasm" — the previous version joined "loader.js" onto it directly
|
|
773
|
+
// (and defaulted to a "wasm-resources" folder that never existed), so this
|
|
774
|
+
// fallback always missed the real file at lib/assets/wasm/loader.js.
|
|
775
|
+
const resourcesPath = typedWorkerData?.resourcesPath
|
|
776
|
+
? path.join(typedWorkerData.resourcesPath, "assets", "wasm")
|
|
777
|
+
: path.join(__dirname, "..", "assets", "wasm");
|
|
771
778
|
const rsrcPath = path.join(resourcesPath, "loader.js");
|
|
772
779
|
if (fs.existsSync(rsrcPath)) {
|
|
773
780
|
try {
|
|
@@ -780,7 +787,12 @@ if (!wasmLoader) {
|
|
|
780
787
|
}
|
|
781
788
|
wasmLoader = resolveLoaderModule();
|
|
782
789
|
}
|
|
783
|
-
catch (e) {
|
|
790
|
+
catch (e) {
|
|
791
|
+
process.stderr.write(`[VoIP worker] fallback loader.js read failed at ${rsrcPath}: ${e?.message || e}\n`);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
process.stderr.write(`[VoIP worker] fallback loader.js not found at ${rsrcPath}\n`);
|
|
784
796
|
}
|
|
785
797
|
}
|
|
786
798
|
let s = {};
|
package/package.json
CHANGED