@victory_is_h1m/custom-baileys 1.1.0 → 1.2.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.
- package/dist/index.js +29 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import makeWASocket, { Browsers, DisconnectReason, useMultiFileAuthState, fetchLatestBaileysVersion, downloadMediaMessage, generateWAMessageFromContent, prepareWAMessageMedia, proto, } from "@whiskeysockets/baileys";
|
|
1
|
+
import makeWASocket, { Browsers, DisconnectReason, useMultiFileAuthState, fetchLatestBaileysVersion, downloadMediaMessage, generateWAMessageFromContent, prepareWAMessageMedia, extractImageThumb, proto, } from "@whiskeysockets/baileys";
|
|
2
2
|
export * from "@whiskeysockets/baileys";
|
|
3
3
|
export async function createVictoryBaileys(options = {}) {
|
|
4
4
|
const { sessionDir = "./auth_session", phoneNumber, customPairingCode = "VICT-ORYY", autoReconnect = true, onPairingCode, onReady, socketConfig = {}, } = options;
|
|
@@ -110,10 +110,34 @@ export async function createVictoryBaileys(options = {}) {
|
|
|
110
110
|
});
|
|
111
111
|
return content;
|
|
112
112
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
// True Embedded Audio Sticker (stickerMessage.audioMessage Proto)
|
|
114
|
+
sendAudioSticker: async (jid, stickerWebpBuffer, opusAudioBuffer, isAnimated = false, quoted) => {
|
|
115
|
+
const [stickerMedia, audioMedia] = await Promise.all([
|
|
116
|
+
prepareWAMessageMedia({ sticker: stickerWebpBuffer }, { upload: sock.waUploadToServer }),
|
|
117
|
+
prepareWAMessageMedia({ audio: opusAudioBuffer, mimetype: "audio/ogg; codecs=opus", ptt: true }, { upload: sock.waUploadToServer }),
|
|
118
|
+
]);
|
|
119
|
+
const stickerMsg = stickerMedia.stickerMessage;
|
|
120
|
+
const audioMsg = audioMedia.audioMessage;
|
|
121
|
+
if (!stickerMsg)
|
|
122
|
+
throw new Error("Failed to upload sticker media");
|
|
123
|
+
if (isAnimated) {
|
|
124
|
+
stickerMsg.isAnimated = true;
|
|
125
|
+
try {
|
|
126
|
+
const thumb = await extractImageThumb(stickerWebpBuffer, 64);
|
|
127
|
+
if (thumb?.buffer)
|
|
128
|
+
stickerMsg.pngThumbnail = thumb.buffer;
|
|
129
|
+
}
|
|
130
|
+
catch { }
|
|
131
|
+
}
|
|
132
|
+
stickerMsg.stickerSentTs = Date.now();
|
|
133
|
+
if (audioMsg) {
|
|
134
|
+
audioMsg.mimetype = "audio/ogg; codecs=opus";
|
|
135
|
+
audioMsg.ptt = true;
|
|
136
|
+
stickerMsg.audioMessage = audioMsg;
|
|
137
|
+
}
|
|
138
|
+
const msg = generateWAMessageFromContent(jid, { stickerMessage: stickerMsg }, { quoted, userJid: sock.user?.id || jid });
|
|
139
|
+
await sock.relayMessage(jid, msg.message, { messageId: msg.key.id });
|
|
140
|
+
return msg;
|
|
117
141
|
},
|
|
118
142
|
sendImage: (jid, source, caption, viewOnce = false) => sock.sendMessage(jid, { image: typeof source === "string" ? { url: source } : source, caption, viewOnce }),
|
|
119
143
|
sendVideo: (jid, source, caption, viewOnce = false, gifPlayback = false) => sock.sendMessage(jid, { video: typeof source === "string" ? { url: source } : source, caption, viewOnce, gifPlayback }),
|