kage-baileys 25.3.24 → 25.3.25
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/WAProto/index.js +2 -57
- package/extras/WAProto/E2E/E2E.proto +4 -0
- package/package.json +2 -2
package/WAProto/index.js
CHANGED
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* Fixed WAProto entrypoint for kage-baileys.
|
|
4
|
-
* Missing generated index.js + shape differences between the old monolithic
|
|
5
|
-
* WAProto and the new split protos under extras/WAProto.
|
|
6
|
-
*
|
|
7
|
-
* Also applies permanent Audio Sticker support (field 134 audioStickerMessage
|
|
8
|
-
* on Message + field 26 audioMessage on StickerMessage) so plugins such as
|
|
9
|
-
* stickeraudio / audiosticker / Tensura-style audioSticker can encode the
|
|
10
|
-
* combined message without conflicting runtime hacks.
|
|
11
|
-
*
|
|
12
|
-
* Compatible with:
|
|
13
|
-
* - kage native audio-sticker util (field 134)
|
|
14
|
-
* - Tensura / Mahiru audioSticker.js patches (field 1074 wire tag = field 134)
|
|
15
|
-
* Sets both __audioStickerKagePatchedV3 and __mahiruAudioStickerPatched so
|
|
16
|
-
* external patches skip and do not double-encode.
|
|
17
|
-
*/
|
|
18
2
|
const raw = require('../extras/WAProto');
|
|
19
3
|
let proto = raw.proto || raw;
|
|
20
4
|
|
|
21
|
-
// ---------- Normalize namespaces so legacy Baileys code keeps working ----------
|
|
22
|
-
|
|
23
|
-
// 1. Message lives under E2E in the new protos
|
|
24
5
|
if (proto.E2E && proto.E2E.Message && !proto.Message) {
|
|
25
6
|
proto.Message = proto.E2E.Message;
|
|
26
7
|
}
|
|
27
8
|
|
|
28
|
-
// 2. HistorySyncType location differs
|
|
29
9
|
const histType =
|
|
30
10
|
(proto.HistorySync && proto.HistorySync.HistorySync && proto.HistorySync.HistorySync.HistorySyncType) ||
|
|
31
11
|
(proto.HistorySync && proto.HistorySync.HistorySyncType) ||
|
|
@@ -41,44 +21,27 @@ if (histType) {
|
|
|
41
21
|
}
|
|
42
22
|
}
|
|
43
23
|
|
|
44
|
-
// 3. Common other aliases that appear in Baileys code
|
|
45
24
|
if (proto.E2E) {
|
|
46
25
|
if (proto.E2E.WebMessageInfo && !proto.WebMessageInfo) {
|
|
47
26
|
proto.WebMessageInfo = proto.E2E.WebMessageInfo;
|
|
48
27
|
}
|
|
49
28
|
}
|
|
50
29
|
|
|
51
|
-
// Apply original field-name compatibility patches
|
|
52
30
|
try {
|
|
53
31
|
require('./compat.cjs')(proto);
|
|
54
32
|
} catch (_) {}
|
|
55
33
|
|
|
56
|
-
// ---------------------------------------------------------------------------
|
|
57
|
-
// Audio Sticker support (permanent, idempotent, dual-flag for Tensura/Mahiru)
|
|
58
|
-
// Protobuf tags:
|
|
59
|
-
// Message.audioStickerMessage = 134 → tag 1074 (length-delimited)
|
|
60
|
-
// StickerMessage.audioMessage = 26 → tag 210 (length-delimited)
|
|
61
|
-
// The generated E2E.js lags behind WAProto.proto; this ensures encode /
|
|
62
|
-
// fromObject always handle the fields used by audio-sticker plugins.
|
|
63
|
-
// ---------------------------------------------------------------------------
|
|
64
34
|
function applyAudioStickerSupport(p) {
|
|
65
35
|
const M = p && p.Message;
|
|
66
36
|
if (!M) return;
|
|
67
|
-
|
|
68
|
-
// Already applied completely by this module
|
|
69
37
|
if (M.__kageAudioStickerEncodeComplete) {
|
|
70
38
|
M.__audioStickerKagePatchedV3 = true;
|
|
71
39
|
M.__mahiruAudioStickerPatched = true;
|
|
72
40
|
M.__audioStickerPatched = true;
|
|
73
41
|
return;
|
|
74
42
|
}
|
|
43
|
+
if (!M.StickerMessage || !M.AudioMessage || !M.FutureProofMessage) return;
|
|
75
44
|
|
|
76
|
-
if (!M.StickerMessage || !M.AudioMessage || !M.FutureProofMessage) {
|
|
77
|
-
// Classes missing → leave untouched so normal stickers still work
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// --- StickerMessage.encode: append audioMessage (field 26 / tag 210) ---
|
|
82
45
|
const previousStickerEncode = M.StickerMessage.encode;
|
|
83
46
|
M.StickerMessage.encode = function (message, writer) {
|
|
84
47
|
const hasAudio = message && Object.prototype.hasOwnProperty.call(message, 'audioMessage');
|
|
@@ -87,7 +50,6 @@ function applyAudioStickerSupport(p) {
|
|
|
87
50
|
try {
|
|
88
51
|
const result = previousStickerEncode.call(this, message, writer);
|
|
89
52
|
if (audio) {
|
|
90
|
-
// field 26, wire type 2 → tag 210
|
|
91
53
|
M.AudioMessage.encode(audio, result.uint32(210).fork()).ldelim();
|
|
92
54
|
}
|
|
93
55
|
return result;
|
|
@@ -96,7 +58,6 @@ function applyAudioStickerSupport(p) {
|
|
|
96
58
|
}
|
|
97
59
|
};
|
|
98
60
|
|
|
99
|
-
// --- StickerMessage.fromObject: accept audioMessage ---
|
|
100
61
|
if (typeof M.StickerMessage.fromObject === 'function') {
|
|
101
62
|
const previousStickerFromObject = M.StickerMessage.fromObject;
|
|
102
63
|
M.StickerMessage.fromObject = function (object) {
|
|
@@ -110,34 +71,24 @@ function applyAudioStickerSupport(p) {
|
|
|
110
71
|
};
|
|
111
72
|
}
|
|
112
73
|
|
|
113
|
-
// Ensure prototype property exists (for hasOwnProperty / toObject paths)
|
|
114
74
|
if (!Object.prototype.hasOwnProperty.call(M.StickerMessage.prototype, 'audioMessage')) {
|
|
115
75
|
M.StickerMessage.prototype.audioMessage = null;
|
|
116
76
|
}
|
|
117
77
|
|
|
118
|
-
// --- Message.encode: emit audioStickerMessage (field 134 / tag 1074) ---
|
|
119
78
|
const previousMessageEncode = M.encode;
|
|
120
79
|
M.encode = function (message, writer) {
|
|
121
80
|
const hasAudioSticker = message && Object.prototype.hasOwnProperty.call(message, 'audioStickerMessage');
|
|
122
81
|
const hasSticker = message && Object.prototype.hasOwnProperty.call(message, 'stickerMessage');
|
|
123
82
|
const audioSticker = hasAudioSticker ? message.audioStickerMessage : null;
|
|
124
83
|
const stickerMessage = hasSticker ? message.stickerMessage : null;
|
|
125
|
-
|
|
126
84
|
if (hasAudioSticker) {
|
|
127
85
|
delete message.audioStickerMessage;
|
|
128
|
-
// Prefer the nested sticker inside audioStickerMessage when present
|
|
129
|
-
// (Tensura/Mahiru payload puts sticker under audioStickerMessage.message)
|
|
130
86
|
if (hasSticker) delete message.stickerMessage;
|
|
131
87
|
}
|
|
132
|
-
|
|
133
88
|
try {
|
|
134
89
|
const result = previousMessageEncode.call(this, message, writer);
|
|
135
90
|
if (audioSticker) {
|
|
136
|
-
|
|
137
|
-
M.FutureProofMessage.encode(
|
|
138
|
-
audioSticker,
|
|
139
|
-
result.uint32(1074).fork()
|
|
140
|
-
).ldelim();
|
|
91
|
+
M.FutureProofMessage.encode(audioSticker, result.uint32(1074).fork()).ldelim();
|
|
141
92
|
}
|
|
142
93
|
return result;
|
|
143
94
|
} finally {
|
|
@@ -146,14 +97,12 @@ function applyAudioStickerSupport(p) {
|
|
|
146
97
|
}
|
|
147
98
|
};
|
|
148
99
|
|
|
149
|
-
// --- Message.fromObject: accept audioStickerMessage ---
|
|
150
100
|
if (typeof M.fromObject === 'function') {
|
|
151
101
|
const previousMessageFromObject = M.fromObject;
|
|
152
102
|
M.fromObject = function (object) {
|
|
153
103
|
const message = previousMessageFromObject.call(this, object);
|
|
154
104
|
if (object && object.audioStickerMessage) {
|
|
155
105
|
const inner = object.audioStickerMessage.message || object.audioStickerMessage;
|
|
156
|
-
// Preserve nested stickerMessage.audioMessage if present (Tensura path)
|
|
157
106
|
if (
|
|
158
107
|
inner &&
|
|
159
108
|
inner.stickerMessage &&
|
|
@@ -167,7 +116,6 @@ function applyAudioStickerSupport(p) {
|
|
|
167
116
|
message.audioStickerMessage = M.FutureProofMessage.fromObject
|
|
168
117
|
? M.FutureProofMessage.fromObject({ message: inner })
|
|
169
118
|
: { message: inner };
|
|
170
|
-
// Match Tensura behavior: drop top-level sticker when audio sticker is set
|
|
171
119
|
if (message.stickerMessage && inner && inner.stickerMessage) {
|
|
172
120
|
delete message.stickerMessage;
|
|
173
121
|
}
|
|
@@ -180,10 +128,8 @@ function applyAudioStickerSupport(p) {
|
|
|
180
128
|
M.prototype.audioStickerMessage = null;
|
|
181
129
|
}
|
|
182
130
|
|
|
183
|
-
// Dual flags: kage native + Tensura/Mahiru style so external patches skip
|
|
184
131
|
M.__audioStickerKagePatchedV3 = true;
|
|
185
132
|
M.__mahiruAudioStickerPatched = true;
|
|
186
|
-
M.__audioStickerPatched = true;
|
|
187
133
|
M.__tensuraAudioStickerPatched = true;
|
|
188
134
|
M.__audioStickerPatched = true;
|
|
189
135
|
M.__kageAudioStickerEncodeComplete = true;
|
|
@@ -192,7 +138,6 @@ function applyAudioStickerSupport(p) {
|
|
|
192
138
|
try {
|
|
193
139
|
applyAudioStickerSupport(proto);
|
|
194
140
|
} catch (err) {
|
|
195
|
-
// Never break loading of WAProto because of the optional audio-sticker patch
|
|
196
141
|
if (typeof console !== 'undefined' && console.warn) {
|
|
197
142
|
console.warn('[kage-baileys/WAProto] Audio Sticker patch skipped:', err && err.message);
|
|
198
143
|
}
|
|
@@ -729,6 +729,7 @@ message Message {
|
|
|
729
729
|
optional StatusQuestionAnswerMessage statusQuestionAnswerMessage = 105;
|
|
730
730
|
optional FutureProofMessage questionReplyMessage = 106;
|
|
731
731
|
optional QuestionResponseMessage questionResponseMessage = 107;
|
|
732
|
+
optional FutureProofMessage audioStickerMessage = 134;
|
|
732
733
|
message AlbumMessage {
|
|
733
734
|
optional uint32 expectedImageCount = 2;
|
|
734
735
|
optional uint32 expectedVideoCount = 3;
|
|
@@ -1908,6 +1909,9 @@ message Message {
|
|
|
1908
1909
|
optional bool isLottie = 21;
|
|
1909
1910
|
optional string accessibilityLabel = 22;
|
|
1910
1911
|
optional Message.MediaKeyDomain mediaKeyDomain = 23;
|
|
1912
|
+
optional int32 premium = 24;
|
|
1913
|
+
optional string emojis = 25;
|
|
1914
|
+
optional AudioMessage audioMessage = 26;
|
|
1911
1915
|
}
|
|
1912
1916
|
message StickerPackMessage {
|
|
1913
1917
|
optional string stickerPackId = 1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kage-baileys",
|
|
3
|
-
"version": "25.3.
|
|
4
|
-
"description": "Kage Baileys
|
|
3
|
+
"version": "25.3.25",
|
|
4
|
+
"description": "Kage Baileys, la mejor Baileys de 2026.]",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kage-baileys",
|
|
7
7
|
"baileys",
|