jagproject 5.7.9 → 5.8.2
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 +14 -15
- package/lib/Utils/messages-media.js +104 -25
- package/lib/index.js +11 -8
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -488,31 +488,30 @@ Jika teks dan media digabung, hanya satu yang akan dikirim tergantung prioritas
|
|
|
488
488
|
|
|
489
489
|
### Kirim teks ke status WhatsApp
|
|
490
490
|
```javascript
|
|
491
|
-
await conn.upswgc("
|
|
492
|
-
text: "Halo dunia! ini teks status 📢"
|
|
493
|
-
})
|
|
491
|
+
await conn.upswgc(m.chat, { text: "Halo dari upswgc versi final!" })
|
|
494
492
|
```
|
|
495
493
|
|
|
496
494
|
### Kirim gambar ke status WhatsApp
|
|
497
495
|
```javascript
|
|
498
|
-
await conn.upswgc(
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
})
|
|
496
|
+
await conn.upswgc(m.chat, {
|
|
497
|
+
image: { url: "https://m.media-amazon.com/images/S/pv-target-images/f75db71efd62ea2eff81bd7cc01c44a9344b4ac18615ab71a80f58459ddf8791.jpg" },
|
|
498
|
+
caption : "apasi"
|
|
499
|
+
});
|
|
500
|
+
|
|
502
501
|
```
|
|
503
502
|
### Kirim video ke status WhatsApp
|
|
504
503
|
```javascript
|
|
505
|
-
await conn.upswgc(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
})
|
|
504
|
+
await conn.upswgc(m.chat, {
|
|
505
|
+
video: { url: "https://m.media-amazon.com/images/S/pv-target-images/f75db71efd62ea2eff81bd7cc01c44a9344b4ac18615ab71a80f58459ddf8791.jpg" },
|
|
506
|
+
caption : "apasi"
|
|
507
|
+
});
|
|
509
508
|
```
|
|
510
509
|
### Kirim audio (voice note) ke status WhatsApp
|
|
511
510
|
```javascript
|
|
512
|
-
await conn.upswgc(
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
})
|
|
511
|
+
await conn.upswgc(m.chat, {
|
|
512
|
+
audio: { url: "https://cdn.yupra.my.id/yp/xkv99g06.opus" },
|
|
513
|
+
caption : "apasi"
|
|
514
|
+
});
|
|
516
515
|
```
|
|
517
516
|
|
|
518
517
|
`[!TIP]
|
|
@@ -365,48 +365,126 @@ async function getAudioDuration(buffer) {
|
|
|
365
365
|
}
|
|
366
366
|
return metadata.format.duration;
|
|
367
367
|
}
|
|
368
|
+
// Ganti / tempelkan seluruh function getAudioWaveform berikut
|
|
368
369
|
async function getAudioWaveform(buffer, logger) {
|
|
369
370
|
try {
|
|
370
|
-
|
|
371
|
+
// prefer ffmpeg-based robust extraction (supports opus/ogg/mp3/m4a etc.)
|
|
372
|
+
const { PassThrough } = require('stream');
|
|
373
|
+
const ffmpeg = require('fluent-ffmpeg');
|
|
374
|
+
// try to use ffmpeg-static if available (bundled binary)
|
|
375
|
+
try {
|
|
376
|
+
const ffmpegPath = require('ffmpeg-static');
|
|
377
|
+
if (ffmpegPath) {
|
|
378
|
+
ffmpeg.setFfmpegPath(ffmpegPath);
|
|
379
|
+
}
|
|
380
|
+
} catch (e) {
|
|
381
|
+
// ffmpeg-static not installed — hope system ffmpeg exists in PATH
|
|
382
|
+
logger?.debug?.('ffmpeg-static not available, relying on system ffmpeg');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// normalize input to Buffer
|
|
371
386
|
let audioData;
|
|
372
387
|
if (Buffer.isBuffer(buffer)) {
|
|
373
388
|
audioData = buffer;
|
|
389
|
+
} else if (typeof buffer === 'string') {
|
|
390
|
+
// path given
|
|
391
|
+
const fs = require('fs');
|
|
392
|
+
audioData = await (async () => {
|
|
393
|
+
if (fs.existsSync(buffer)) return fs.readFileSync(buffer);
|
|
394
|
+
// otherwise try to read as URL/stream via toBuffer helper if available
|
|
395
|
+
return await exports.toBuffer(buffer);
|
|
396
|
+
})();
|
|
397
|
+
} else {
|
|
398
|
+
audioData = await exports.toBuffer(buffer);
|
|
374
399
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
400
|
+
|
|
401
|
+
// convert to raw PCM 16-bit signed little endian mono using ffmpeg in-memory
|
|
402
|
+
return await new Promise((resolve, reject) => {
|
|
403
|
+
try {
|
|
404
|
+
const chunks = [];
|
|
405
|
+
const inputStream = new PassThrough();
|
|
406
|
+
inputStream.end(audioData);
|
|
407
|
+
|
|
408
|
+
// pipe ffmpeg -> raw PCM signed 16 bit LE, mono, 16000/44100 sample rate doesn't matter much
|
|
409
|
+
ffmpeg(inputStream)
|
|
410
|
+
.format('s16le')
|
|
411
|
+
.audioChannels(1)
|
|
412
|
+
.audioFrequency(16000)
|
|
413
|
+
.noVideo()
|
|
414
|
+
.on('error', (err) => {
|
|
415
|
+
logger?.debug?.('ffmpeg waveform error', err?.message || err);
|
|
416
|
+
// fallback: try a simpler approach using audio-decode if available
|
|
417
|
+
try {
|
|
418
|
+
(async () => {
|
|
419
|
+
const { default: decoder } = await eval('import("audio-decode")');
|
|
420
|
+
const audioBuf = await exports.toBuffer(audioData);
|
|
421
|
+
const audioDecoded = await decoder(audioBuf);
|
|
422
|
+
const raw = audioDecoded.getChannelData(0);
|
|
423
|
+
const result = normalizeToUint8(raw);
|
|
424
|
+
resolve(result);
|
|
425
|
+
})();
|
|
426
|
+
} catch (e) {
|
|
427
|
+
reject(err);
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
.on('end', () => {
|
|
431
|
+
try {
|
|
432
|
+
const buffer = Buffer.concat(chunks);
|
|
433
|
+
// buffer contains 16-bit signed PCM little endian
|
|
434
|
+
// convert to Float32 array (-1..1) first
|
|
435
|
+
const samples = new Int16Array(buffer.buffer, buffer.byteOffset, Math.floor(buffer.length / 2));
|
|
436
|
+
const floatSamples = new Float32Array(samples.length);
|
|
437
|
+
for (let i = 0; i < samples.length; i++) {
|
|
438
|
+
floatSamples[i] = samples[i] / 32768; // normalize int16 to [-1,1]
|
|
439
|
+
}
|
|
440
|
+
const result = normalizeToUint8(floatSamples);
|
|
441
|
+
resolve(result);
|
|
442
|
+
} catch (e) {
|
|
443
|
+
reject(e);
|
|
444
|
+
}
|
|
445
|
+
})
|
|
446
|
+
.pipe()
|
|
447
|
+
.on('data', (c) => chunks.push(c));
|
|
448
|
+
} catch (e) {
|
|
449
|
+
reject(e);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
} catch (e) {
|
|
453
|
+
logger?.debug?.(e);
|
|
454
|
+
return undefined;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// helper: normalize float array (-1..1) into Uint8Array (0..100 per bar)
|
|
459
|
+
function normalizeToUint8(data, samples = 64) {
|
|
460
|
+
try {
|
|
461
|
+
const blockSize = Math.floor(data.length / samples) || 1;
|
|
462
|
+
const filtered = [];
|
|
387
463
|
for (let i = 0; i < samples; i++) {
|
|
388
|
-
|
|
464
|
+
let blockStart = i * blockSize;
|
|
389
465
|
let sum = 0;
|
|
390
|
-
for (let j = 0; j < blockSize; j++) {
|
|
391
|
-
sum
|
|
466
|
+
for (let j = 0; j < blockSize && (blockStart + j) < data.length; j++) {
|
|
467
|
+
sum += Math.abs(data[blockStart + j]);
|
|
392
468
|
}
|
|
393
|
-
|
|
469
|
+
filtered.push(sum / blockSize);
|
|
394
470
|
}
|
|
395
|
-
const
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
catch (e) {
|
|
401
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('Failed to generate waveform: ' + e);
|
|
471
|
+
const max = Math.max(...filtered) || 1;
|
|
472
|
+
const normalized = filtered.map(v => Math.floor((v / max) * 100));
|
|
473
|
+
return new Uint8Array(normalized);
|
|
474
|
+
} catch (e) {
|
|
475
|
+
return undefined;
|
|
402
476
|
}
|
|
403
477
|
}
|
|
478
|
+
|
|
404
479
|
const toReadable = (buffer) => {
|
|
405
480
|
const readable = new stream_1.Readable({ read: () => { } });
|
|
406
481
|
readable.push(buffer);
|
|
407
482
|
readable.push(null);
|
|
408
483
|
return readable;
|
|
409
484
|
};
|
|
485
|
+
// ================================================================
|
|
486
|
+
// Tambahan utilitas media (opsional, jika Wileyss punya bawaan sendiri biarkan bagian bawah tetap ada)
|
|
487
|
+
// ================================================================
|
|
410
488
|
exports.toReadable = toReadable;
|
|
411
489
|
const toBuffer = async (stream) => {
|
|
412
490
|
const chunks = [];
|
|
@@ -876,4 +954,5 @@ const MEDIA_RETRY_STATUS_MAP = {
|
|
|
876
954
|
};
|
|
877
955
|
function __importStar(arg0) {
|
|
878
956
|
throw new Error('Function not implemented.');
|
|
879
|
-
}
|
|
957
|
+
}
|
|
958
|
+
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
+
////
|
|
1
2
|
"use strict";
|
|
2
3
|
|
|
3
4
|
const chalk = require("chalk");
|
|
4
|
-
const gradient = require("gradient-string");
|
|
5
5
|
|
|
6
|
-
console.log();
|
|
6
|
+
console.log(chalk.yellow("⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘"));
|
|
7
|
+
console.log(chalk.magentaBright.bold("꧁⎝ 𓆩༺ Baileys Jagoan project ༻𓆪 ⎠꧂\n"));
|
|
7
8
|
console.log(
|
|
8
|
-
chalk.
|
|
9
|
+
chalk.whiteBright(
|
|
10
|
+
chalk.bgBlue("Ingin beli Script atau panel premium? ke 6282252509320.")
|
|
11
|
+
)
|
|
9
12
|
);
|
|
10
|
-
|
|
11
|
-
console.log();
|
|
12
13
|
console.log(
|
|
13
|
-
chalk.
|
|
14
|
-
|
|
14
|
+
chalk.black(
|
|
15
|
+
chalk.bgMagenta("Update permanen.. gak usah pusing error..!!! 😱\n")
|
|
15
16
|
)
|
|
16
17
|
);
|
|
17
|
-
console.log();
|
|
18
|
+
console.log(chalk.red("Youtube: ") + chalk.greenBright("@jagoanproject"));
|
|
19
|
+
console.log(chalk.yellow("⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘\n"));
|
|
20
|
+
|
|
18
21
|
|
|
19
22
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
23
|
if (k2 === undefined) k2 = k;
|