@vanzxy/baileys 1.3.8 → 1.3.9
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/NOTICE.md +41 -0
- package/lib/Utils/MessageBuilder.js +2297 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/rich-message-utils.js +32 -7
- package/package.json +7 -2
- package/LICENSE +0 -23
package/lib/Utils/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export * from './link-preview.js';
|
|
|
17
17
|
export * from './event-buffer.js';
|
|
18
18
|
export * from './process-message.js';
|
|
19
19
|
export * from './rich-message-utils.js';
|
|
20
|
+
export * from './MessageBuilder.js';
|
|
20
21
|
export * from './message-retry-manager.js';
|
|
21
22
|
export * from './browser-utils.js';
|
|
22
23
|
export * from './companion-reg-client-utils.js';
|
|
@@ -11,6 +11,23 @@ import { CodeHighlightType, RichSubMessageType } from '../Types/RichType.js';
|
|
|
11
11
|
import { proto } from '../../WAProto/index.js';
|
|
12
12
|
import { unixTimestampSeconds } from './generics.js';
|
|
13
13
|
const NOOP = new Set([]);
|
|
14
|
+
// Vanz@Fix (bug 40 / inline image): AIRichResponseInlineImageMetadata.imageUrl is a nested
|
|
15
|
+
// AIRichResponseImageURL message (imagePreviewUrl/imageHighResUrl/sourceUrl), NOT a plain string.
|
|
16
|
+
// Passing a raw string made protobufjs silently encode an empty embedded message (no throw),
|
|
17
|
+
// so the image URL data was dropped on the wire and the image never rendered.
|
|
18
|
+
const toImageUrlObject = (url) => {
|
|
19
|
+
if (!url)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (typeof url === 'object')
|
|
22
|
+
return { imagePreviewUrl: url.imagePreviewUrl || url.url, imageHighResUrl: url.imageHighResUrl || url.url, sourceUrl: url.sourceUrl || url.url };
|
|
23
|
+
return { imagePreviewUrl: url, imageHighResUrl: url, sourceUrl: url };
|
|
24
|
+
};
|
|
25
|
+
const IMAGE_ALIGNMENT = { leading: 0, trailing: 1, center: 2 };
|
|
26
|
+
const toImageAlignment = (alignment) => {
|
|
27
|
+
if (typeof alignment === 'number')
|
|
28
|
+
return alignment;
|
|
29
|
+
return IMAGE_ALIGNMENT[String(alignment || 'center').toLowerCase()] ?? IMAGE_ALIGNMENT.center;
|
|
30
|
+
};
|
|
14
31
|
export const tokenizeCode = (code, language = 'javascript') => {
|
|
15
32
|
const keywords = LANGUAGE_KEYWORDS[language] || NOOP;
|
|
16
33
|
const blocks = [];
|
|
@@ -75,14 +92,22 @@ export const toUnified = (submessages, uuid) => ({
|
|
|
75
92
|
}
|
|
76
93
|
};
|
|
77
94
|
case RichSubMessageType.INLINE_IMAGE:
|
|
78
|
-
// Vanz@Fix (bug 40):
|
|
95
|
+
// Vanz@Fix (bug 40, round 2): imageUrl is now a real AIRichResponseImageURL
|
|
96
|
+
// object (imagePreviewUrl/imageHighResUrl/sourceUrl) instead of a bare string
|
|
97
|
+
// that protobufjs silently dropped on encode. alignment is mapped back to its
|
|
98
|
+
// enum name (matches how the compiled proto's toObject() renders other enums).
|
|
79
99
|
const imgMeta = submessage.imageMetadata;
|
|
100
|
+
const ALIGNMENT_NAME = ['AI_RICH_RESPONSE_IMAGE_LAYOUT_LEADING_ALIGNED', 'AI_RICH_RESPONSE_IMAGE_LAYOUT_TRAILING_ALIGNED', 'AI_RICH_RESPONSE_IMAGE_LAYOUT_CENTER_ALIGNED'];
|
|
80
101
|
return {
|
|
81
102
|
view_model: {
|
|
82
103
|
primitive: {
|
|
83
|
-
image_url:
|
|
104
|
+
image_url: {
|
|
105
|
+
image_preview_url: imgMeta?.imageUrl?.imagePreviewUrl || '',
|
|
106
|
+
image_high_res_url: imgMeta?.imageUrl?.imageHighResUrl || '',
|
|
107
|
+
source_url: imgMeta?.imageUrl?.sourceUrl || ''
|
|
108
|
+
},
|
|
84
109
|
image_text: imgMeta?.imageText || '',
|
|
85
|
-
alignment: imgMeta?.alignment
|
|
110
|
+
alignment: ALIGNMENT_NAME[imgMeta?.alignment ?? 2],
|
|
86
111
|
tap_link_url: imgMeta?.tapLinkUrl || '',
|
|
87
112
|
__typename: 'GenAIInlineImageUXPrimitive'
|
|
88
113
|
},
|
|
@@ -167,9 +192,9 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
167
192
|
return {
|
|
168
193
|
messageType: RichSubMessageType.INLINE_IMAGE,
|
|
169
194
|
imageMetadata: {
|
|
170
|
-
imageUrl: submessage.inlineImage,
|
|
195
|
+
imageUrl: toImageUrlObject(submessage.inlineImage),
|
|
171
196
|
imageText: submessage.imageText,
|
|
172
|
-
alignment: submessage.alignment,
|
|
197
|
+
alignment: toImageAlignment(submessage.alignment),
|
|
173
198
|
tapLinkUrl: submessage.tapLinkUrl
|
|
174
199
|
}
|
|
175
200
|
};
|
|
@@ -255,9 +280,9 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
255
280
|
submessages.push({
|
|
256
281
|
messageType: RichSubMessageType.INLINE_IMAGE,
|
|
257
282
|
imageMetadata: {
|
|
258
|
-
imageUrl: inlineImage,
|
|
283
|
+
imageUrl: toImageUrlObject(inlineImage),
|
|
259
284
|
imageText,
|
|
260
|
-
alignment,
|
|
285
|
+
alignment: toImageAlignment(alignment),
|
|
261
286
|
tapLinkUrl
|
|
262
287
|
}
|
|
263
288
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanzxy/baileys",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "Enhanced Baileys fork by Vanzxy \u2014 based on @itsliaaa/baileys + @whiskeysockets/baileys with fixes for audio group status and clean media without newsletter button.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"lib/**/*",
|
|
21
21
|
"WAProto/**/*",
|
|
22
22
|
"engine-requirements.js",
|
|
23
|
-
"postinstall-banner.js"
|
|
23
|
+
"postinstall-banner.js",
|
|
24
|
+
"NOTICE.md"
|
|
24
25
|
],
|
|
25
26
|
"keywords": [
|
|
26
27
|
"automation",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"@napi-rs/image": "~1.12.0",
|
|
57
58
|
"audio-decode": "^2.2.3",
|
|
58
59
|
"better-sqlite3": "^11.0.0",
|
|
60
|
+
"fluent-ffmpeg": "^2.1.3",
|
|
59
61
|
"jimp": "^1.6.1",
|
|
60
62
|
"link-preview-js": "^3.0.0",
|
|
61
63
|
"sharp": "*"
|
|
@@ -70,6 +72,9 @@
|
|
|
70
72
|
"better-sqlite3": {
|
|
71
73
|
"optional": true
|
|
72
74
|
},
|
|
75
|
+
"fluent-ffmpeg": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
73
78
|
"jimp": {
|
|
74
79
|
"optional": true
|
|
75
80
|
},
|
package/LICENSE
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Rajeh Taher/WhiskeySockets
|
|
4
|
-
Copyright (c) 2026 Lia Wynn
|
|
5
|
-
Copyright (c) 2026 Vanzxy🍃 / VanzxyPrst🍃
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
SOFTWARE.
|