bintzge-baileys 2.0.5 → 2.0.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/lib/Socket/{bintzge.d.ts → Bintz.d.ts} +33 -20
- package/lib/Socket/{bintzge.js → Bintz.js} +104 -4
- package/lib/Socket/messages-recv.js +1085 -1091
- package/lib/Socket/messages-send.js +13 -34
- package/lib/index.js +1 -3
- package/package.json +4 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proto } from '../../WAProto';
|
|
2
2
|
|
|
3
|
-
declare namespace
|
|
3
|
+
declare namespace alip {
|
|
4
4
|
interface MediaUploadOptions {
|
|
5
5
|
fileEncSha256?: Buffer;
|
|
6
6
|
mediaType?: string;
|
|
@@ -34,7 +34,14 @@ declare namespace kikyy {
|
|
|
34
34
|
isAiSticker?: boolean;
|
|
35
35
|
isLottie?: boolean;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
interface StickerPack {
|
|
38
|
+
stickers: (Buffer | { data: Buffer })[];
|
|
39
|
+
cover: Buffer;
|
|
40
|
+
name: string;
|
|
41
|
+
publisher: string;
|
|
42
|
+
packId?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
interface PaymentMessage {
|
|
39
46
|
amount: number;
|
|
40
47
|
currency?: string;
|
|
@@ -157,7 +164,7 @@ declare namespace kikyy {
|
|
|
157
164
|
[key: string]: any;
|
|
158
165
|
}
|
|
159
166
|
|
|
160
|
-
|
|
167
|
+
interface MessageContent {
|
|
161
168
|
requestPaymentMessage?: PaymentMessage;
|
|
162
169
|
productMessage?: ProductMessage;
|
|
163
170
|
interactiveMessage?: InteractiveMessage;
|
|
@@ -165,9 +172,11 @@ declare namespace kikyy {
|
|
|
165
172
|
eventMessage?: EventMessage;
|
|
166
173
|
pollResultMessage?: PollResultMessage;
|
|
167
174
|
groupStatusMessage?: GroupStatusMessage;
|
|
175
|
+
stickerPack?: StickerPack; // <--- Tambah ini
|
|
168
176
|
sender?: string;
|
|
169
177
|
}
|
|
170
178
|
|
|
179
|
+
|
|
171
180
|
interface MessageOptions {
|
|
172
181
|
quoted?: proto.IWebMessageInfo;
|
|
173
182
|
filter?: boolean;
|
|
@@ -189,65 +198,69 @@ declare namespace kikyy {
|
|
|
189
198
|
}
|
|
190
199
|
}
|
|
191
200
|
|
|
192
|
-
declare class
|
|
201
|
+
declare class alip {
|
|
193
202
|
constructor(
|
|
194
|
-
utils:
|
|
195
|
-
waUploadToServer:
|
|
203
|
+
utils: alip.Utils,
|
|
204
|
+
waUploadToServer: alip.WAMediaUploadFunction,
|
|
196
205
|
relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
|
|
197
206
|
);
|
|
198
207
|
|
|
199
|
-
detectType(content:
|
|
208
|
+
detectType(content: alip.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'GROUP_STORY' | 'STICKER_PACK' | null;
|
|
200
209
|
|
|
201
210
|
handlePayment(
|
|
202
|
-
content: { requestPaymentMessage:
|
|
211
|
+
content: { requestPaymentMessage: alip.PaymentMessage },
|
|
203
212
|
quoted?: proto.IWebMessageInfo
|
|
204
213
|
): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
|
|
205
|
-
|
|
214
|
+
handleStickerPack(
|
|
215
|
+
content: { stickerPack: alip.StickerPack },
|
|
216
|
+
jid: string,
|
|
217
|
+
quoted?: proto.IWebMessageInfo
|
|
218
|
+
): Promise<{ stickerPackMessage: any }>;
|
|
206
219
|
handleProduct(
|
|
207
|
-
content: { productMessage:
|
|
220
|
+
content: { productMessage: alip.ProductMessage },
|
|
208
221
|
jid: string,
|
|
209
222
|
quoted?: proto.IWebMessageInfo
|
|
210
223
|
): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
|
|
211
224
|
|
|
212
225
|
handleInteractive(
|
|
213
|
-
content: { interactiveMessage:
|
|
226
|
+
content: { interactiveMessage: alip.InteractiveMessage },
|
|
214
227
|
jid: string,
|
|
215
228
|
quoted?: proto.IWebMessageInfo
|
|
216
229
|
): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
|
|
217
230
|
|
|
218
231
|
handleAlbum(
|
|
219
|
-
content: { albumMessage:
|
|
232
|
+
content: { albumMessage: alip.AlbumItem[] },
|
|
220
233
|
jid: string,
|
|
221
234
|
quoted?: proto.IWebMessageInfo
|
|
222
235
|
): Promise<any>;
|
|
223
236
|
|
|
224
237
|
handleEvent(
|
|
225
|
-
content: { eventMessage:
|
|
238
|
+
content: { eventMessage: alip.EventMessage },
|
|
226
239
|
jid: string,
|
|
227
240
|
quoted?: proto.IWebMessageInfo
|
|
228
241
|
): Promise<any>;
|
|
229
242
|
|
|
230
243
|
handlePollResult(
|
|
231
|
-
content: { pollResultMessage:
|
|
244
|
+
content: { pollResultMessage: alip.PollResultMessage },
|
|
232
245
|
jid: string,
|
|
233
246
|
quoted?: proto.IWebMessageInfo
|
|
234
247
|
): Promise<any>;
|
|
235
248
|
|
|
236
249
|
handleGroupStory(
|
|
237
|
-
content: { groupStatusMessage:
|
|
250
|
+
content: { groupStatusMessage: alip.GroupStatusMessage },
|
|
238
251
|
jid: string,
|
|
239
252
|
quoted?: proto.IWebMessageInfo
|
|
240
253
|
): Promise<any>;
|
|
241
254
|
|
|
242
255
|
buildMessageContent(
|
|
243
256
|
content: any,
|
|
244
|
-
opts?:
|
|
257
|
+
opts?: alip.WAMessageContentGenerationOptions
|
|
245
258
|
): Promise<any>;
|
|
246
259
|
|
|
247
|
-
utils:
|
|
260
|
+
utils: alip.Utils;
|
|
248
261
|
relayMessage: (jid: string, content: any, options?: any) => Promise<any>;
|
|
249
|
-
waUploadToServer:
|
|
250
|
-
bail:
|
|
262
|
+
waUploadToServer: alip.WAMediaUploadFunction;
|
|
263
|
+
bail: alip.BailUtils;
|
|
251
264
|
}
|
|
252
265
|
|
|
253
|
-
export =
|
|
266
|
+
export = alip;
|
|
@@ -2,7 +2,7 @@ const WAProto = require('../../WAProto').proto;
|
|
|
2
2
|
const crypto = require('crypto');
|
|
3
3
|
const Utils_1 = require("../Utils");
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class alip {
|
|
6
6
|
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
7
7
|
this.utils = utils;
|
|
8
8
|
this.relayMessage = relayMessageFn
|
|
@@ -23,8 +23,108 @@ class kikyy {
|
|
|
23
23
|
if (content.eventMessage) return 'EVENT';
|
|
24
24
|
if (content.pollResultMessage) return 'POLL_RESULT';
|
|
25
25
|
if (content.groupStatusMessage) return 'GROUP_STORY';
|
|
26
|
+
if (content.stickerPack) return 'STICKER_PACK';
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
29
|
+
async handleStickerPack(content, jid, quoted) {
|
|
30
|
+
const packData = content.stickerPack;
|
|
31
|
+
const axios = require('axios');
|
|
32
|
+
const crypto = require('crypto');
|
|
33
|
+
const stickerMessages = [];
|
|
34
|
+
let coverSticker = null;
|
|
35
|
+
let trayIconSticker = null;
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < Math.min(packData.stickers.length, 20); i++) {
|
|
38
|
+
try {
|
|
39
|
+
const sticker = packData.stickers[i];
|
|
40
|
+
let stickerBuffer;
|
|
41
|
+
|
|
42
|
+
if (sticker.url) {
|
|
43
|
+
const response = await axios.get(sticker.url, {
|
|
44
|
+
responseType: 'arraybuffer',
|
|
45
|
+
timeout: 20000
|
|
46
|
+
});
|
|
47
|
+
stickerBuffer = Buffer.from(response.data);
|
|
48
|
+
} else if (sticker.data) {
|
|
49
|
+
stickerBuffer = sticker.data;
|
|
50
|
+
} else {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const media = await this.utils.prepareWAMessageMedia(
|
|
55
|
+
{ sticker: stickerBuffer },
|
|
56
|
+
{ upload: this.waUploadToServer }
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
if (media.stickerMessage) {
|
|
60
|
+
// Simpan cover dan tray icon (sticker pertama)
|
|
61
|
+
if (i === 0) {
|
|
62
|
+
coverSticker = media.stickerMessage;
|
|
63
|
+
trayIconSticker = media.stickerMessage;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Push sticker object (bukan wrapper)
|
|
67
|
+
stickerMessages.push(media.stickerMessage);
|
|
68
|
+
}
|
|
69
|
+
} catch (err) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!coverSticker || stickerMessages.length === 0) {
|
|
75
|
+
throw new Error('No valid stickers found');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const packId = packData.packId || crypto.randomUUID();
|
|
79
|
+
const now = Math.floor(Date.now() / 1000);
|
|
80
|
+
const totalSize = stickerMessages.reduce((acc, msg) => {
|
|
81
|
+
return acc + (msg.fileLength?.low || 0);
|
|
82
|
+
}, 0);
|
|
83
|
+
|
|
84
|
+
// Generate imageDataHash dari cover sticker
|
|
85
|
+
const imageDataHash = coverSticker.fileSha256 ?
|
|
86
|
+
Buffer.from(coverSticker.fileSha256).toString('base64') : '';
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
stickerPackMessage: {
|
|
90
|
+
stickers: stickerMessages, // Langsung array stickerMessage
|
|
91
|
+
stickerPackId: packId, // Bukan packId
|
|
92
|
+
name: packData.name || "Sticker Pack",
|
|
93
|
+
publisher: packData.publisher || "",
|
|
94
|
+
fileLength: coverSticker.fileLength || { low: totalSize, high: 0, unsigned: true },
|
|
95
|
+
fileSha256: coverSticker.fileSha256,
|
|
96
|
+
fileEncSha256: coverSticker.fileEncSha256,
|
|
97
|
+
mediaKey: coverSticker.mediaKey,
|
|
98
|
+
directPath: coverSticker.directPath,
|
|
99
|
+
contextInfo: {
|
|
100
|
+
mentionedJid: [],
|
|
101
|
+
groupMentions: []
|
|
102
|
+
},
|
|
103
|
+
mediaKeyTimestamp: coverSticker.mediaKeyTimestamp || now,
|
|
104
|
+
|
|
105
|
+
// Tray icon (pakai cover sticker)
|
|
106
|
+
trayIconFileName: `${packId}.png`,
|
|
107
|
+
trayIconDirectPath: coverSticker.directPath,
|
|
108
|
+
trayIconFileLength: coverSticker.fileLength,
|
|
109
|
+
trayIconSha256: coverSticker.fileSha256,
|
|
110
|
+
trayIconEncSha256: coverSticker.fileEncSha256,
|
|
111
|
+
trayIconMediaKey: coverSticker.mediaKey,
|
|
112
|
+
trayIconMediaKeyTimestamp: coverSticker.mediaKeyTimestamp || now,
|
|
113
|
+
|
|
114
|
+
// Thumbnail (beda dari tray icon di contoh asli)
|
|
115
|
+
thumbnailDirectPath: coverSticker.directPath,
|
|
116
|
+
thumbnailSha256: coverSticker.fileSha256,
|
|
117
|
+
thumbnailEncSha256: coverSticker.fileEncSha256,
|
|
118
|
+
thumbnailHeight: 512,
|
|
119
|
+
thumbnailWidth: 512,
|
|
120
|
+
|
|
121
|
+
// Field tambahan yang ada di contoh asli
|
|
122
|
+
imageDataHash: imageDataHash,
|
|
123
|
+
stickerPackSize: { low: totalSize, high: 0, unsigned: true },
|
|
124
|
+
stickerPackOrigin: 2 // Origin 2, bukan 1
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
28
128
|
|
|
29
129
|
async handlePayment(content, quoted) {
|
|
30
130
|
const data = content.requestPaymentMessage;
|
|
@@ -384,8 +484,8 @@ class kikyy {
|
|
|
384
484
|
participant: jid,
|
|
385
485
|
remoteJid: "status@broadcast",
|
|
386
486
|
forwardedNewsletterMessageInfo: {
|
|
387
|
-
newsletterName: "
|
|
388
|
-
newsletterJid: "
|
|
487
|
+
newsletterName: "BintzGE",
|
|
488
|
+
newsletterJid: "120363364987398307@newsletter",
|
|
389
489
|
serverMessageId: 1
|
|
390
490
|
}
|
|
391
491
|
},
|
|
@@ -477,4 +577,4 @@ class kikyy {
|
|
|
477
577
|
}
|
|
478
578
|
}
|
|
479
579
|
|
|
480
|
-
module.exports =
|
|
580
|
+
module.exports = alip;
|