MCPcopy
hub / github.com/mruniquehacker/Knightbot-MD / downloadMediaMessage

Function downloadMediaMessage

commands/tag.js:6–15  ·  view source on GitHub ↗
(message, mediaType)

Source from the content-addressed store, hash-verified

4const path = require('path');
5
6async function downloadMediaMessage(message, mediaType) {
7 const stream = await downloadContentFromMessage(message, mediaType);
8 let buffer = Buffer.from([]);
9 for await (const chunk of stream) {
10 buffer = Buffer.concat([buffer, chunk]);
11 }
12 const filePath = path.join(__dirname, '../temp/', `${Date.now()}.${mediaType}`);
13 fs.writeFileSync(filePath, buffer);
14 return filePath;
15}
16
17async function tagCommand(sock, chatId, senderId, messageText, replyMessage, message) {
18 const { isSenderAdmin, isBotAdmin } = await isAdmin(sock, chatId, senderId);

Callers 5

stickercropCommandFunction · 0.70
tagCommandFunction · 0.70
stickerCommandFunction · 0.70
blurCommandFunction · 0.70
takeCommandFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected