@yudzxml/baileys 7.3.3 → 7.3.5

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
@@ -77,8 +77,8 @@ import makeWASocket from '@yudzxml/baileys'
77
77
 
78
78
  ## 📚 Documentation
79
79
 
80
- - **[Official Documentation](https://guide.whiskeysockets.io/)** (Core Baileys Docs)
81
- - **[Discord Community](https://discord.gg/nqssuNjjSH)**
80
+ - **[Official Channel](https://whatsapp.com/channel/0029Vb7rkVo5q08hZXxxrY3v)**
81
+ - **[Group Community](https://chat.whatsapp.com/B9v9lXijkfPKr4QmAQgApu?mode=gi_t)**
82
82
 
83
83
  ---
84
84
 
@@ -397,4 +397,4 @@ MIT - Copyright (c) 2026 Yudzxml
397
397
 
398
398
  <div align="center">
399
399
  Made with ❤️ by Yudzxml
400
- </div>
400
+ </div>
@@ -683,66 +683,162 @@ const makeMessagesRecvSocket = (config) => {
683
683
  }
684
684
 
685
685
  const handleMexNotification = (id, node) => {
686
+ try {
686
687
  const operation = node?.attrs?.op_name
687
- const content = JSON.parse(node?.content)
688
-
688
+ if (!operation) return
689
+
690
+ // Safe JSON parse
691
+ let content = {}
692
+ try {
693
+ content = typeof node?.content === 'string'
694
+ ? JSON.parse(node.content)
695
+ : node?.content || {}
696
+ } catch (err) {
697
+ logger?.warn?.(
698
+ { err, node },
699
+ 'Failed to parse mex content'
700
+ )
701
+ return
702
+ }
703
+
689
704
  let contentPath
690
705
  let action
691
-
706
+
707
+ // Newsletter settings update
692
708
  if (operation === MexOperations.UPDATE) {
693
- contentPath = content.data[XWAPaths.METADATA_UPDATE]
694
-
709
+ contentPath =
710
+ content?.data?.[XWAPaths.METADATA_UPDATE]
711
+
712
+ if (!contentPath?.thread_metadata?.settings) return
713
+
695
714
  ev.emit('newsletter-settings.update', {
696
- id,
715
+ id,
697
716
  update: contentPath.thread_metadata.settings
698
- })
699
- } else if (operation === MexUpdatesOperations.GROUP_MEMBER_LINK) {
700
- contentPath = content.data[XWAPathsMexUpdates.GROUP_SHARING_CHANGE]
701
-
702
- ev.emit('groups.update', [{
703
- id,
704
- author: contentPath.updated_by.id,
705
- member_link_mode: contentPath.properties.member_link_mode
706
- }])
707
- } else if (operation === MexUpdatesOperations.GROUP_LIMIT_SHARING) {
708
- contentPath = content.data[XWAPathsMexUpdates.GROUP_SHARING_CHANGE]
709
-
717
+ })
718
+
719
+ return
720
+ }
721
+
722
+ // Group member link mode
723
+ if (operation === MexUpdatesOperations.GROUP_MEMBER_LINK) {
724
+ contentPath =
725
+ content?.data?.[
726
+ XWAPathsMexUpdates.GROUP_SHARING_CHANGE
727
+ ]
728
+
729
+ if (!contentPath?.properties) return
730
+
731
+ ev.emit('groups.update', [{
732
+ id,
733
+ author: contentPath?.updated_by?.id,
734
+ member_link_mode:
735
+ contentPath?.properties?.member_link_mode
736
+ }])
737
+
738
+ return
739
+ }
740
+
741
+ // Group limit sharing
742
+ if (operation === MexUpdatesOperations.GROUP_LIMIT_SHARING) {
743
+ contentPath =
744
+ content?.data?.[
745
+ XWAPathsMexUpdates.GROUP_SHARING_CHANGE
746
+ ]
747
+
748
+ const limitSharing =
749
+ contentPath?.properties?.limit_sharing
750
+
751
+ if (!limitSharing) return
752
+
710
753
  ev.emit('limit-sharing.update', {
711
- id,
712
- author: contentPath.updated_by?.pn ? contentPath.updated_by.pn : contentPath.updated_by.id,
713
- action: `${contentPath.properties.limit_sharing.limit_sharing_enabled ? 'on' : 'off'}`,
714
- trigger: contentPath.properties.limit_sharing.limit_sharing_trigger,
715
- update_time: contentPath.update_time
716
- })
717
- } else if (operation === MexUpdatesOperations.OWNER_COMMUNITY) {
718
- contentPath = content.data[XWAPathsMexUpdates.COMMUNITY_OWNER_CHANGE]
719
-
754
+ id,
755
+ author:
756
+ contentPath?.updated_by?.pn ||
757
+ contentPath?.updated_by?.id,
758
+ action:
759
+ limitSharing?.limit_sharing_enabled
760
+ ? 'on'
761
+ : 'off',
762
+ trigger:
763
+ limitSharing?.limit_sharing_trigger,
764
+ update_time:
765
+ contentPath?.update_time
766
+ })
767
+
768
+ return
769
+ }
770
+
771
+ // Community owner update
772
+ if (operation === MexUpdatesOperations.OWNER_COMMUNITY) {
773
+ contentPath =
774
+ content?.data?.[
775
+ XWAPathsMexUpdates.COMMUNITY_OWNER_CHANGE
776
+ ]
777
+
778
+ const roleUpdate =
779
+ contentPath?.role_updates?.[0]
780
+
781
+ if (!roleUpdate) return
782
+
720
783
  ev.emit('community-owner.update', {
721
- id,
722
- author: contentPath.updated_by?.pn ? contentPath.updated_by.pn : contentPath.updated_by.id,
723
- user: contentPath.role_updates[0].user?.pn ? contentPath.role_updates[0].user.pn : contentPath.role_updates[0].user.jid,
724
- new_role: contentPath.role_updates[0].new_role,
725
- update_time: contentPath.update_time
726
- })
784
+ id,
785
+ author:
786
+ contentPath?.updated_by?.pn ||
787
+ contentPath?.updated_by?.id,
788
+ user:
789
+ roleUpdate?.user?.pn ||
790
+ roleUpdate?.user?.jid,
791
+ new_role:
792
+ roleUpdate?.new_role,
793
+ update_time:
794
+ contentPath?.update_time
795
+ })
796
+
797
+ return
798
+ }
799
+
800
+ // Promote / Demote fallback
801
+ if (operation === MexOperations.PROMOTE) {
802
+ action = 'promote'
803
+ contentPath =
804
+ content?.data?.[XWAPaths.PROMOTE]
805
+ } else if (operation === MexOperations.DEMOTE) {
806
+ action = 'demote'
807
+ contentPath =
808
+ content?.data?.[XWAPaths.DEMOTE]
727
809
  } else {
728
-
729
- if (operation === MexOperations.PROMOTE) {
730
- action = 'promote'
731
- contentPath = content.data[XWAPaths.PROMOTE]
732
- } else {
733
- action = 'demote'
734
- contentPath = content.data[XWAPaths.DEMOTE]
735
- }
736
-
737
- ev.emit('newsletter-participants.update', {
738
- id,
739
- author: contentPath.actor.pn,
740
- user: contentPath.user.pn,
741
- new_role: contentPath.user_new_role,
742
- action
743
- })
810
+ return
744
811
  }
812
+
813
+ if (!contentPath?.actor || !contentPath?.user) {
814
+ logger?.debug?.(
815
+ { operation, content },
816
+ 'Missing promote/demote contentPath'
817
+ )
818
+ return
819
+ }
820
+
821
+ ev.emit('newsletter-participants.update', {
822
+ id,
823
+ author:
824
+ contentPath?.actor?.pn ||
825
+ contentPath?.actor?.id,
826
+ user:
827
+ contentPath?.user?.pn ||
828
+ contentPath?.user?.id,
829
+ new_role:
830
+ contentPath?.user_new_role,
831
+ action
832
+ })
833
+
834
+ } catch (err) {
835
+ // Jangan bikin baileys mati
836
+ logger?.error?.(
837
+ { err, node, id },
838
+ 'handleMexNotification crashed'
839
+ )
745
840
  }
841
+ }
746
842
 
747
843
  const processNotification = async (node) => {
748
844
  const result = {}
@@ -19,7 +19,8 @@ const {
19
19
  promises,
20
20
  createReadStream,
21
21
  createWriteStream,
22
- writeFileSync
22
+ writeFileSync,
23
+ existsSync
23
24
  } = require("fs")
24
25
  const {
25
26
  parseBuffer,
@@ -445,28 +446,60 @@ async function convertToOpusBuffer(buffer, logger) {
445
446
  }
446
447
  }
447
448
 
449
+
448
450
  async function convertToMp4Buffer(buffer, logger) {
451
+ const tmp = join(__dirname, '../src', `${Date.now()}.tmp`)
452
+ const out = `${tmp}.mp4`
453
+ const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
454
+ const { spawn } = require('child_process')
455
+
449
456
  try {
450
- const { PassThrough } = require('stream');
451
- const ff = require('fluent-ffmpeg');
452
- return await new Promise((resolve, reject) => {
453
- const inStream = new PassThrough();
454
- const outStream = new PassThrough();
455
- const chunks = [];
456
- inStream.end(buffer);
457
- ff(inStream)
458
- .videoCodec('libx264')
459
- .audioCodec('aac')
460
- .format('mp4')
461
- .outputOptions(['-preset', 'veryfast', '-crf', '23', '-movflags', 'faststart', '-map_metadata', '-1'])
457
+ await promises.writeFile(tmp, buffer)
458
+
459
+ await new Promise((resolve, reject) => {
460
+ spawn(ffmpegPath, [
461
+ '-y',
462
+ '-i', tmp,
463
+ '-c:v', 'libx264',
464
+ '-c:a', 'aac',
465
+ '-preset', 'veryfast',
466
+ '-crf', '23',
467
+ '-movflags', 'faststart',
468
+ '-map_metadata', '-1',
469
+ '-f', 'mp4',
470
+ out
471
+ ])
462
472
  .on('error', reject)
463
- .on('end', () => resolve(Buffer.concat(chunks)))
464
- .pipe(outStream, { end: true });
465
- outStream.on('data', c => chunks.push(c));
466
- });
473
+ .on('close', code => {
474
+ if (code !== 0) {
475
+ return reject(
476
+ new Error(`FFmpeg exited with code ${code}`)
477
+ )
478
+ }
479
+ resolve()
480
+ })
481
+ })
482
+
483
+ const result = await promises.readFile(out)
484
+
485
+ await promises.unlink(tmp)
486
+ await promises.unlink(out)
487
+
488
+ return result
467
489
  } catch (e) {
468
- logger?.debug(e);
469
- throw e;
490
+ logger?.debug?.(e)
491
+
492
+ try {
493
+ if (existsSync(tmp)) {
494
+ await promises.unlink(tmp)
495
+ }
496
+
497
+ if (existsSync(out)) {
498
+ await promises.unlink(out)
499
+ }
500
+ } catch {}
501
+
502
+ throw e
470
503
  }
471
504
  }
472
505
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yudzxml/baileys",
3
- "version": "7.3.3",
3
+ "version": "7.3.5",
4
4
  "description": "WhatsApp API Modification By Yudzxml",
5
5
  "keywords": [
6
6
  "whatsapp",
@@ -12,25 +12,28 @@
12
12
  "automation",
13
13
  "multi-device"
14
14
  ],
15
+
15
16
  "homepage": "https://github.com/Yudzxml/Baileys",
17
+
16
18
  "bugs": {
17
- "url": "https://github.com/Yudzxml/Baileys/issues"
19
+ "url": "https://github.com/Yudzxml/Baileys/issues"
18
20
  },
21
+
19
22
  "repository": {
20
23
  "type": "git",
21
24
  "url": "https://github.com/Yudzxml/Baileys.git"
22
25
  },
23
- "publishConfig": {
24
- "registry": "https://registry.npmjs.org"
25
- },
26
+
26
27
  "license": "MIT",
27
28
  "author": "Yudzxml",
29
+
28
30
  "main": "lib/index.js",
29
31
  "files": [
30
32
  "lib/*",
31
33
  "WAProto/*",
32
34
  "engine-requirements.js"
33
35
  ],
36
+
34
37
  "scripts": {
35
38
  "changelog:last": "conventional-changelog -p angular -r 2",
36
39
  "changelog:preview": "conventional-changelog -p angular -u",
@@ -41,6 +44,7 @@
41
44
  "release": "release-it",
42
45
  "test": "jest"
43
46
  },
47
+
44
48
  "dependencies": {
45
49
  "@hapi/boom": "^9.1.3",
46
50
  "@adiwajshing/keyed-db": "^0.2.4",
@@ -60,6 +64,7 @@
60
64
  "qrcode-terminal": "^0.12.0",
61
65
  "ws": "^8.13.0"
62
66
  },
67
+
63
68
  "devDependencies": {
64
69
  "@types/jest": "^29.5.14",
65
70
  "@types/node": "^16.0.0",
@@ -79,19 +84,24 @@
79
84
  "typedoc-plugin-markdown": "4.4.2",
80
85
  "typescript": "^5.8.2"
81
86
  },
87
+
82
88
  "peerDependencies": {
83
- "jimp": "^0.22.12",
89
+ "jimp": "^0.22.12",
84
90
  "sharp": "*"
85
91
  },
92
+
86
93
  "peerDependenciesMeta": {
87
94
  "jimp": {
88
95
  "optional": true
89
96
  }
90
97
  },
98
+
91
99
  "packageManager": "yarn@1.22.19",
100
+
92
101
  "engines": {
93
102
  "node": ">=20.0.0"
94
103
  },
104
+
95
105
  "directories": {
96
106
  "lib": "lib"
97
107
  }