@ryuu-reinzz/baileys 5.3.0 → 5.4.1-beta.1
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 +18 -0
- package/lib/Utils/browser-utils.js +84 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -473,6 +473,24 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
473
473
|
sock.sendMessage(jid, content, options)
|
|
474
474
|
```
|
|
475
475
|
|
|
476
|
+
### Interactive Buttons — `sock.sendButton(jid, content, options)`
|
|
477
|
+
|
|
478
|
+
> Injected into the socket by `@ryuu-reinzz/luna-lib` (`addProperty`). Sends native flow buttons with an optional media header (`image`/`video`/`document`/`location`/`product`).
|
|
479
|
+
|
|
480
|
+
> [!WARNING]
|
|
481
|
+
> When a media header (`image`, `video`, `document`, `location`, `product`) is provided, the text shown under the media **must** be passed via the **`caption`** parameter — **not** `text`. Using `text` together with media makes the button message fail/error on WhatsApp's side.
|
|
482
|
+
|
|
483
|
+
```ts
|
|
484
|
+
await sock.sendButton(jid, {
|
|
485
|
+
caption: 'Choose an option below:', // image is present → use caption, not text
|
|
486
|
+
footer: '© Example',
|
|
487
|
+
buttons: [
|
|
488
|
+
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Menu', id: '.menu' }) }
|
|
489
|
+
],
|
|
490
|
+
image: 'https://example.com/banner.jpg'
|
|
491
|
+
}, { quoted: m })
|
|
492
|
+
```
|
|
493
|
+
|
|
476
494
|
### Non-Media Messages
|
|
477
495
|
|
|
478
496
|
#### Text Message
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { platform, release } from 'os';
|
|
2
2
|
import { proto } from '../../WAProto/index.js';
|
|
3
|
+
|
|
3
4
|
const PLATFORM_MAP = {
|
|
4
5
|
aix: 'AIX',
|
|
5
6
|
darwin: 'Mac OS',
|
|
@@ -8,21 +9,91 @@ const PLATFORM_MAP = {
|
|
|
8
9
|
freebsd: 'FreeBSD',
|
|
9
10
|
openbsd: 'OpenBSD',
|
|
10
11
|
sunos: 'Solaris',
|
|
11
|
-
linux:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
linux: 'Linux',
|
|
13
|
+
ubuntu: 'Ubuntu',
|
|
14
|
+
ios: 'iOS',
|
|
15
|
+
baileys: 'Baileys',
|
|
16
|
+
chromeos: 'Chrome OS',
|
|
17
|
+
tizen: 'Tizen',
|
|
18
|
+
watchos: 'watchOS',
|
|
19
|
+
wearos: 'Wear OS',
|
|
20
|
+
harmonyos: 'HarmonyOS',
|
|
21
|
+
kaios: 'KaiOS',
|
|
22
|
+
smarttv: 'Smart TV',
|
|
23
|
+
raspberrypi: 'Raspberry Pi OS',
|
|
24
|
+
symbian: 'Symbian',
|
|
25
|
+
blackberry: 'Blackberry OS',
|
|
26
|
+
windowsphone: 'Windows Phone'
|
|
15
27
|
};
|
|
28
|
+
|
|
29
|
+
const PLATFORM_VERSIONS = {
|
|
30
|
+
ubuntu: '22.04.4',
|
|
31
|
+
darwin: '18.5',
|
|
32
|
+
win32: '10.0.22631',
|
|
33
|
+
android: '14.0.0',
|
|
34
|
+
freebsd: '13.2',
|
|
35
|
+
openbsd: '7.3',
|
|
36
|
+
sunos: '11',
|
|
37
|
+
linux: '6.5',
|
|
38
|
+
ios: '18.2',
|
|
39
|
+
baileys: '6.5.0',
|
|
40
|
+
chromeos: '117.0.5938.132',
|
|
41
|
+
tizen: '6.5',
|
|
42
|
+
watchos: '10.1',
|
|
43
|
+
wearos: '4.1',
|
|
44
|
+
harmonyos: '4.0.0',
|
|
45
|
+
kaios: '3.1',
|
|
46
|
+
smarttv: '23.3.1',
|
|
47
|
+
raspberrypi: '11 (Bullseye)',
|
|
48
|
+
symbian: '3',
|
|
49
|
+
blackberry: '10.3.3',
|
|
50
|
+
windowsphone: '8.1'
|
|
51
|
+
};
|
|
52
|
+
|
|
16
53
|
export const Browsers = {
|
|
17
|
-
ubuntu: browser => ['Ubuntu', browser, '
|
|
18
|
-
macOS: browser => ['Mac OS', browser, '
|
|
19
|
-
baileys: browser => ['Baileys', browser, '
|
|
20
|
-
windows: browser => ['Windows', browser, '
|
|
21
|
-
|
|
22
|
-
|
|
54
|
+
ubuntu: browser => ['Ubuntu', browser, PLATFORM_VERSIONS['ubuntu']],
|
|
55
|
+
macOS: browser => ['Mac OS', browser, PLATFORM_VERSIONS['darwin']],
|
|
56
|
+
baileys: browser => ['Baileys', browser, PLATFORM_VERSIONS['baileys']],
|
|
57
|
+
windows: browser => ['Windows', browser, PLATFORM_VERSIONS['win32']],
|
|
58
|
+
linux: browser => ['Linux', browser, PLATFORM_VERSIONS['linux']],
|
|
59
|
+
solaris: browser => ['Solaris', browser, PLATFORM_VERSIONS['sunos']],
|
|
60
|
+
iOS: browser => ['iOS', browser, PLATFORM_VERSIONS['ios']],
|
|
61
|
+
android: apiLevel => [apiLevel, 'Android', ''],
|
|
62
|
+
androidCompanion: apiLevel => [apiLevel, 'Android', ''],
|
|
63
|
+
kaiOS: browser => ['KaiOS', browser, PLATFORM_VERSIONS['kaios']],
|
|
64
|
+
chromeOS: browser => ['Chrome OS', browser, PLATFORM_VERSIONS['chromeos']],
|
|
65
|
+
appropriate: browser => {
|
|
66
|
+
const os = platform();
|
|
67
|
+
const platformName = PLATFORM_MAP[os] || 'Unknown OS';
|
|
68
|
+
return [platformName, browser, PLATFORM_VERSIONS[os] || release()];
|
|
69
|
+
},
|
|
70
|
+
custom: (os, browser, version) => {
|
|
71
|
+
const platformName = PLATFORM_MAP[os.toLowerCase()] || os;
|
|
72
|
+
return [platformName, browser, version || PLATFORM_VERSIONS[os] || 'latest'];
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const isAndroidBrowser = browser => {
|
|
77
|
+
return browser[1]?.toUpperCase() === 'ANDROID';
|
|
23
78
|
};
|
|
24
|
-
|
|
79
|
+
|
|
80
|
+
export const getPlatformId = browser => {
|
|
25
81
|
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
26
|
-
|
|
82
|
+
if (platformType !== undefined) {
|
|
83
|
+
return platformType.toString();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (browser.toUpperCase() === 'ANDROID') {
|
|
87
|
+
const androidPhone = proto.DeviceProps.PlatformType['ANDROID_PHONE'];
|
|
88
|
+
if (androidPhone !== undefined) {
|
|
89
|
+
return androidPhone.toString();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (proto.DeviceProps.PlatformType.CHROME || 1).toString();
|
|
27
94
|
};
|
|
28
|
-
|
|
95
|
+
|
|
96
|
+
export const getPlatformDisplayName = browser => {
|
|
97
|
+
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
98
|
+
return platformType !== undefined ? browser : 'Chrome';
|
|
99
|
+
};
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"require": "./lib/index.cjs"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
|
-
"version": "5.
|
|
11
|
+
"version": "5.4.1-beta.1",
|
|
12
12
|
"description": "A WebSockets library for interacting with WhatsApp Web",
|
|
13
13
|
"keywords": [
|
|
14
14
|
"whatsapp",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@cacheable/node-cache": "^1.4.0",
|
|
31
|
-
"@ryuu-reinzz/luna-lib": "4.
|
|
31
|
+
"@ryuu-reinzz/luna-lib": "4.3.0",
|
|
32
32
|
"@hapi/boom": "^9.1.3",
|
|
33
33
|
"async-mutex": "^0.5.0",
|
|
34
34
|
"better-sqlite3": "^12.5.0",
|