@ryuu-reinzz/haruka-lib 3.2.6 → 3.3.0

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.
Files changed (2) hide show
  1. package/main/socket.js +93 -10
  2. package/package.json +1 -1
package/main/socket.js CHANGED
@@ -28,6 +28,89 @@ export default function addProperty(socket, baileys) {
28
28
  } = baileys;
29
29
 
30
30
  Object.assign(socket, {
31
+ sendStickerPack: async (jid, packData, options = {}) => {
32
+ try {
33
+ const {
34
+ name,
35
+ publisher,
36
+ description,
37
+ cover,
38
+ stickers
39
+ } = packData;
40
+ const quoted = options.quoted || null;
41
+
42
+ const mediaMessage = await prepareWAMessageMedia({
43
+ document: cover,
44
+ mimetype: 'image/webp',
45
+ fileName: 'cover.webp'
46
+ }, {
47
+ upload: sock.waUploadToServer
48
+ });
49
+ const docInfo = mediaMessage.documentMessage;
50
+ if (!docInfo) throw new Error("Gagal mengunggah gambar cover.");
51
+
52
+ const uploadedStickers = [];
53
+
54
+ for (const s of stickers) {
55
+ const stickerMessage = await prepareWAMessageMedia({
56
+ document: s.data,
57
+ mimetype: 'image/webp',
58
+ fileName: 'sticker.webp'
59
+ }, {
60
+ upload: sock.waUploadToServer
61
+ });
62
+
63
+ const sDoc = stickerMessage.documentMessage;
64
+ if (sDoc) {
65
+ uploadedStickers.push({
66
+ fileLength: sDoc.fileLength,
67
+ fileSha256: sDoc.fileSha256,
68
+ fileEncSha256: sDoc.fileEncSha256,
69
+ mediaKey: sDoc.mediaKey,
70
+ directPath: sDoc.directPath,
71
+ mediaKeyTimestamp: sDoc.mediaKeyTimestamp || Math.floor(Date.now() / 1000).toString(),
72
+ });
73
+ }
74
+ }
75
+
76
+ const stickerPackId = generateMessageID();
77
+
78
+ const stickerPackMessage = {
79
+ stickerPackId: stickerPackId,
80
+ name: name,
81
+ publisher: publisher,
82
+ packDescription: description || '',
83
+
84
+ stickers: uploadedStickers,
85
+
86
+ fileLength: docInfo.fileLength,
87
+ fileSha256: docInfo.fileSha256,
88
+ fileEncSha256: docInfo.fileEncSha256,
89
+ mediaKey: docInfo.mediaKey,
90
+ directPath: docInfo.directPath,
91
+ mediaKeyTimestamp: docInfo.mediaKeyTimestamp || Math.floor(Date.now() / 1000).toString(),
92
+
93
+ trayIconFileName: `${stickerPackId}.webp`,
94
+ imageDataHash: docInfo.fileSha256.toString('base64'),
95
+ stickerPackSize: docInfo.fileLength,
96
+ stickerPackOrigin: 'THIRD_PARTY',
97
+ contextInfo: options.contextInfo || (quoted ? {
98
+ stanzaId: quoted.key.id,
99
+ participant: quoted.key.participant || quoted.key.remoteJid,
100
+ quotedMessage: quoted.message
101
+ } : {})
102
+ };
103
+
104
+ return await sock.relayMessage(jid, {
105
+ stickerPackMessage
106
+ }, {});
107
+
108
+ } catch (err) {
109
+ console.error('❌ Error in sendStickerPack wrapper:', err);
110
+ throw err;
111
+ }
112
+ },
113
+
31
114
  sendCard: async (jid, options = {}) => {
32
115
  const {
33
116
  text = "",
@@ -122,9 +205,9 @@ export default function addProperty(socket, baileys) {
122
205
  },
123
206
 
124
207
  sendSticker: async (jid, options = {}, other = {}) => {
125
- const {
126
- contextInfo = {}
127
- } = options;
208
+ const {
209
+ contextInfo = {}
210
+ } = options;
128
211
  try {
129
212
  if (!options.sticker)
130
213
  throw new Error('Please enter the path or buffer of the sticker.')
@@ -285,13 +368,13 @@ export default function addProperty(socket, baileys) {
285
368
  videoMessage: preparedMedia.videoMessage,
286
369
  };
287
370
  } else if (document) {
288
- if (!fileName) throw new Error("fileName requiered");
289
- if (!mimetype) throw new Error("mimetype requiered");
290
- const mediaInput = {
291
- document: document,
292
- fileName: fileName,
293
- mimetype: mimetype
294
- };
371
+ if (!fileName) throw new Error("fileName requiered");
372
+ if (!mimetype) throw new Error("mimetype requiered");
373
+ const mediaInput = {
374
+ document: document,
375
+ fileName: fileName,
376
+ mimetype: mimetype
377
+ };
295
378
  const preparedMedia = await prepareWAMessageMedia(mediaInput, {
296
379
  upload: socket.waUploadToServer,
297
380
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryuu-reinzz/haruka-lib",
3
- "version": "3.2.6",
3
+ "version": "3.3.0",
4
4
  "description": "Library extra for bot WhatsApp",
5
5
  "main": "main/index.js",
6
6
  "type": "module",