-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCyberArmyvv.js
64 lines (54 loc) · 2.01 KB
/
CyberArmyvv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { downloadContentFromMessage } from '@whiskeysockets/baileys';
import fs from 'fs';
import config from '../../config.cjs';
const rvo = async (m, sock) => {
try {
console.log('Quoted message:', m.quoted);
const prefix = config.PREFIX;
const cmd = m.body.startsWith(prefix) ? m.body.slice(prefix.length).split(' ')[0].toLowerCase() : '';
const text = m.body.slice(prefix.length + cmd.length).trim();
const validCommands = ['show', 'vv', 'bonichek'];
if (!validCommands.includes(cmd)) return;
// Check if the quoted message is a view-once message
if (!m.quoted || m.quoted.type !== 'view_once' || (m.quoted.mtype !== 'imageMessage' && m.quoted.mtype !== 'videoMessage')) {
return m.reply('This is not a view once message');
}
// Extract the message and its type
const msg = m.quoted.message;
const type = Object.keys(msg)[0];
const originalCaption = msg[type].caption || '';
const newCaption = `${originalCaption}\n\n> © Powered By -BONIFHACE-MD AND HANS-MD`;
// Download the media content
const mediaStream = await downloadContentFromMessage(msg[type], type === 'imageMessage' ? 'image' : 'video');
let buffer = Buffer.from([]);
for await (const chunk of mediaStream) {
buffer = Buffer.concat([buffer, chunk]);
}
// Send the media back to the chat
if (/video/.test(type)) {
await sock.sendMessage(m.from, {
video: buffer,
caption: newCaption,
contextInfo: {
mentionedJid: [m.sender],
forwardingScore: 9999,
isForwarded: true,
}
}, { quoted: m });
} else if (/image/.test(type)) {
await sock.sendMessage(m.from, {
image: buffer,
caption: newCaption,
contextInfo: {
mentionedJid: [m.sender],
forwardingScore: 9999,
isForwarded: true,
}
}, { quoted: m });
}
} catch (e) {
console.error('Error:', e);
m.reply('An error occurred while processing the command.');
}
};
export default rvo;