kage-baileys 25.3.22 → 25.3.23
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 +3 -3
- package/lib/Socket/messages-send.js +4 -0
- package/lib/Utils/audio-sticker.js +27 -79
- package/package.json +1 -1
package/WAProto/index.js
CHANGED
|
@@ -65,9 +65,8 @@ function applyAudioStickerSupport(p) {
|
|
|
65
65
|
const M = p && p.Message;
|
|
66
66
|
if (!M) return;
|
|
67
67
|
|
|
68
|
-
// Already applied by this module
|
|
69
|
-
if (M.
|
|
70
|
-
// Ensure both flags exist so neither side double-patches
|
|
68
|
+
// Already applied completely by this module
|
|
69
|
+
if (M.__kageAudioStickerEncodeComplete) {
|
|
71
70
|
M.__audioStickerKagePatchedV3 = true;
|
|
72
71
|
M.__mahiruAudioStickerPatched = true;
|
|
73
72
|
return;
|
|
@@ -184,6 +183,7 @@ function applyAudioStickerSupport(p) {
|
|
|
184
183
|
M.__audioStickerKagePatchedV3 = true;
|
|
185
184
|
M.__mahiruAudioStickerPatched = true;
|
|
186
185
|
M.__tensuraAudioStickerPatched = true;
|
|
186
|
+
M.__kageAudioStickerEncodeComplete = true;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
try {
|
|
@@ -961,6 +961,10 @@ const makeMessagesSocket = (config) => {
|
|
|
961
961
|
else if (message.videoMessage) {
|
|
962
962
|
return message.videoMessage.gifPlayback ? 'gif' : 'video';
|
|
963
963
|
}
|
|
964
|
+
// Sound / audio sticker (field 134) must advertise as sticker mediatype
|
|
965
|
+
else if (message.audioStickerMessage) {
|
|
966
|
+
return 'sticker';
|
|
967
|
+
}
|
|
964
968
|
else if (message.stickerMessage) {
|
|
965
969
|
return message.stickerMessage.isLottie ? '1p_sticker' : message.stickerMessage.isAvatar ? 'avatar_sticker' : 'sticker';
|
|
966
970
|
}
|
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
3
|
* Kage Baileys — native Audio / Sound Sticker support
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* audioStickerMessage (134): FutureProofMessage {
|
|
9
|
-
* message {
|
|
10
|
-
* stickerMessage (26): {
|
|
11
|
-
* ...webp fields...,
|
|
12
|
-
* premium: 0,
|
|
13
|
-
* emojis: "🔊",
|
|
14
|
-
* audioMessage (26): AudioMessage { ptt: false, ... }
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
* messageContextInfo { messageSecret }
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* Implementation notes (from real client captures / Baileys#2932 / working sends):
|
|
22
|
-
* - Top-level field MUST be only audioStickerMessage (134), never also stickerMessage.
|
|
23
|
-
* - Audio is uploaded as normal audio (ptt: false), not a voice note.
|
|
24
|
-
* - Protobuf field 26 inside StickerMessage carries the AudioMessage.
|
|
25
|
-
* - We inject field 134 via a temporary encode hook so older generated WAProto still works.
|
|
4
|
+
* Aligned with elaina-baileys working payload:
|
|
5
|
+
* { __proto__: prepared, audioStickerMessage: { message: prepared }, messageContextInfo }
|
|
6
|
+
* + Message.encode field 134 / StickerMessage field 26 (via WAProto patch)
|
|
7
|
+
* + getMediaType recognizes audioStickerMessage → mediatype=sticker
|
|
26
8
|
*/
|
|
27
9
|
|
|
28
10
|
const { randomBytes } = require('node:crypto');
|
|
@@ -46,10 +28,6 @@ function ld(fieldNumber, body) {
|
|
|
46
28
|
return Buffer.concat([varint(fieldNumber * 8 + 2), varint(b.length), b]);
|
|
47
29
|
}
|
|
48
30
|
|
|
49
|
-
/**
|
|
50
|
-
* Ensure Message.encode can emit field 134 even if the generated static code
|
|
51
|
-
* does not know about audioStickerMessage yet.
|
|
52
|
-
*/
|
|
53
31
|
function ensureAudioStickerEncodeSupport() {
|
|
54
32
|
const M = proto && proto.Message;
|
|
55
33
|
if (!M || M.__kageAudioStickerEncodeV1) return;
|
|
@@ -69,13 +47,10 @@ function ensureAudioStickerEncodeSupport() {
|
|
|
69
47
|
}
|
|
70
48
|
|
|
71
49
|
/**
|
|
72
|
-
* Build
|
|
50
|
+
* Build Message content for relayMessage / generateWAMessageFromContent.
|
|
73
51
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* @param {object} params.audioMessage - prepared AudioMessage (from prepareWAMessageMedia, ptt:false)
|
|
77
|
-
* @param {boolean} [params.isAnimated]
|
|
78
|
-
* @param {string} [params.emoji='🔊']
|
|
52
|
+
* Uses elaina-style __proto__ so getMediaType sees stickerMessage via prototype
|
|
53
|
+
* while encode (WAProto V3) only emits field 134 when audioStickerMessage is own prop.
|
|
79
54
|
*/
|
|
80
55
|
function buildAudioStickerContent({ stickerMessage, audioMessage, isAnimated = false, emoji = '🔊' }) {
|
|
81
56
|
if (!stickerMessage) throw new Error('audio-sticker: missing stickerMessage');
|
|
@@ -83,7 +58,6 @@ function buildAudioStickerContent({ stickerMessage, audioMessage, isAnimated = f
|
|
|
83
58
|
|
|
84
59
|
ensureAudioStickerEncodeSupport();
|
|
85
60
|
|
|
86
|
-
// Clone and force required fields
|
|
87
61
|
const audio = { ...audioMessage };
|
|
88
62
|
audio.ptt = false;
|
|
89
63
|
if (audio.mimetype == null) audio.mimetype = 'audio/ogg; codecs=opus';
|
|
@@ -94,69 +68,46 @@ function buildAudioStickerContent({ stickerMessage, audioMessage, isAnimated = f
|
|
|
94
68
|
isAnimated: Boolean(isAnimated || stickerMessage.isAnimated),
|
|
95
69
|
premium: 0,
|
|
96
70
|
emojis: String(emoji || '🔊'),
|
|
97
|
-
// Keep audioMessage on the object for libraries that know field 26;
|
|
98
|
-
// we also force-append it in the raw bytes below.
|
|
99
71
|
audioMessage: audio
|
|
100
72
|
};
|
|
101
73
|
|
|
102
|
-
//
|
|
103
|
-
|
|
74
|
+
// prepared shape (own stickerMessage) — used as __proto__ for mediatype
|
|
75
|
+
const prepared = {
|
|
76
|
+
stickerMessage: sticker
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Manual wire body as backup (RAW) in case generated encode skips field 134
|
|
104
80
|
let stickerBytes;
|
|
105
81
|
try {
|
|
106
82
|
stickerBytes = Buffer.from(proto.Message.StickerMessage.encode(sticker).finish());
|
|
107
83
|
} catch {
|
|
108
|
-
// Fallback: encode without audioMessage then append field 26
|
|
109
84
|
const { audioMessage: _drop, ...base } = sticker;
|
|
110
85
|
stickerBytes = Buffer.from(proto.Message.StickerMessage.encode(base).finish());
|
|
111
86
|
}
|
|
112
|
-
|
|
113
|
-
// Always append AudioMessage as field 26 (tag 210 = 0xd2 0x01) so it is present
|
|
114
|
-
// even if the generated StickerMessage.encode ignores unknown properties.
|
|
115
87
|
const audioBytes = Buffer.from(proto.Message.AudioMessage.encode(audio).finish());
|
|
88
|
+
// Ensure field 26 present
|
|
116
89
|
const stickerWithAudio = Buffer.concat([stickerBytes, ld(26, audioBytes)]);
|
|
117
|
-
|
|
118
|
-
// Message { stickerMessage (26) }
|
|
119
90
|
const innerMessage = ld(26, stickerWithAudio);
|
|
120
|
-
// FutureProofMessage { message (1) }
|
|
121
91
|
const futureProofBody = ld(1, innerMessage);
|
|
122
92
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
content[RAW] = [[134, futureProofBody]];
|
|
136
|
-
|
|
137
|
-
// Also set the high-level fields for any code that inspects the object
|
|
138
|
-
// (decode paths / logging). Encode will emit RAW field 134.
|
|
139
|
-
content.audioStickerMessage = {
|
|
140
|
-
message: {
|
|
141
|
-
stickerMessage: sticker
|
|
93
|
+
// Elaina working shape:
|
|
94
|
+
// __proto__: prepared → getMediaType finds stickerMessage
|
|
95
|
+
// audioStickerMessage → encode emits field 134; V3 patch drops own stickerMessage
|
|
96
|
+
const content = {
|
|
97
|
+
__proto__: prepared,
|
|
98
|
+
audioStickerMessage: {
|
|
99
|
+
message: prepared
|
|
100
|
+
},
|
|
101
|
+
messageContextInfo: {
|
|
102
|
+
messageSecret: randomBytes(32)
|
|
142
103
|
}
|
|
143
104
|
};
|
|
144
105
|
|
|
106
|
+
content[RAW] = [[134, futureProofBody]];
|
|
107
|
+
|
|
145
108
|
return content;
|
|
146
109
|
}
|
|
147
110
|
|
|
148
|
-
/**
|
|
149
|
-
* High-level helper: prepare media + build content.
|
|
150
|
-
* Expects options.upload / options.logger like prepareWAMessageMedia.
|
|
151
|
-
*
|
|
152
|
-
* message.audioSticker = {
|
|
153
|
-
* sticker: Buffer | { url } | stream, // image or webp
|
|
154
|
-
* audio: Buffer | { url } | stream, // any audio WA accepts
|
|
155
|
-
* isAnimated?: boolean,
|
|
156
|
-
* emoji?: string,
|
|
157
|
-
* mimetype?: string // audio mimetype override
|
|
158
|
-
* }
|
|
159
|
-
*/
|
|
160
111
|
async function prepareAudioStickerMessage(message, options) {
|
|
161
112
|
const { prepareWAMessageMedia } = require('./messages.js');
|
|
162
113
|
const spec = message.audioSticker || message.soundSticker || message;
|
|
@@ -171,10 +122,7 @@ async function prepareAudioStickerMessage(message, options) {
|
|
|
171
122
|
const isAnimated = Boolean(spec.isAnimated);
|
|
172
123
|
|
|
173
124
|
const [stickerPrep, audioPrep] = await Promise.all([
|
|
174
|
-
prepareWAMessageMedia(
|
|
175
|
-
{ sticker: stickerInput, isAnimated },
|
|
176
|
-
options
|
|
177
|
-
),
|
|
125
|
+
prepareWAMessageMedia({ sticker: stickerInput, isAnimated }, options),
|
|
178
126
|
prepareWAMessageMedia(
|
|
179
127
|
{
|
|
180
128
|
audio: spec.audio,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kage-baileys",
|
|
3
|
-
"version": "25.3.
|
|
3
|
+
"version": "25.3.23",
|
|
4
4
|
"description": "Kage Baileys full merge — Builders + mbuilder + Framework + advanced sticker packs + KAGE pairing + extended WAProto. Multi-device ready. FIXED: all core modules deduplicated, removed third-party libsignal-node fork. [audio-sticker patch for Mahiru/Tensura compatibility] [audio-sticker patch for Mahiru/Tensura compatibility]",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kage-baileys",
|