-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathunvoice.js
78 lines (67 loc) · 3.46 KB
/
unvoice.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const Aqua = require('../events');
const {MessageType,Mimetype} = require('@adiwajshing/baileys');
const fs = require('fs');
const ffmpeg = require('fluent-ffmpeg');
const {execFile} = require('child_process');
const cwebp = require('cwebp-bin');
const Config = require('../config');
const Language = require('../language');
const Lang = Language.getString('unvoice'); // Language support
if (Config.WORKTYPE == 'private') {
Aqua.addCommand({pattern: 'unvoice', fromMe: true, desc: Lang.UV_DESC, deleteCommand: false}, (async (message, match) => {
if (message.reply_message === false) return await message.sendMessage(Lang.UV_REPLY);
var downloading = await message.client.sendMessage(message.jid,Lang.UV_PROC,MessageType.text);
var location = await message.client.downloadAndSaveMediaMessage({
key: {
remoteJid: message.reply_message.jid,
id: message.reply_message.id
},
message: message.reply_message.data.quotedMessage
});
ffmpeg(location)
.format('mp3')
.save('output.mp3')
.on('end', async () => {
await message.sendMessage(fs.readFileSync('output.mp3'), MessageType.audio, {mimetype: Mimetype.mp4Audio, ptt: true});
});
return await message.client.deleteMessage(message.jid, {id: downloading.key.id, remoteJid: message.jid, fromMe: true})
}));
}
else if (Config.WORKTYPE == 'public') {
Aqua.addCommand({pattern: 'unvoice', fromMe: false, desc: Lang.UV_DESC, deleteCommand: false}, (async (message, match) => {
if (message.reply_message === false) return await message.sendMessage(Lang.UV_REPLY);
var downloading = await message.client.sendMessage(message.jid,Lang.UV_PROC,MessageType.text);
var location = await message.client.downloadAndSaveMediaMessage({
key: {
remoteJid: message.reply_message.jid,
id: message.reply_message.id
},
message: message.reply_message.data.quotedMessage
});
ffmpeg(location)
.format('mp3')
.save('output.mp3')
.on('end', async () => {
await message.sendMessage(fs.readFileSync('output.mp3'), MessageType.audio, {mimetype: Mimetype.mp4Audio, ptt: true});
});
return await message.client.deleteMessage(message.jid, {id: downloading.key.id, remoteJid: message.jid, fromMe: true})
}));
Aqua.addCommand({pattern: 'unvoice', fromMe: true, desc: Lang.UV_DESC, dontAddCommandList: true, deleteCommand: false}, (async (message, match) => {
if (message.reply_message === false) return await message.sendMessage(Lang.UV_REPLY);
var downloading = await message.client.sendMessage(message.jid,Lang.UV_PROC,MessageType.text);
var location = await message.client.downloadAndSaveMediaMessage({
key: {
remoteJid: message.reply_message.jid,
id: message.reply_message.id
},
message: message.reply_message.data.quotedMessage
});
ffmpeg(location)
.format('mp3')
.save('output.mp3')
.on('end', async () => {
await message.sendMessage(fs.readFileSync('output.mp3'), MessageType.audio, {mimetype: Mimetype.mp4Audio, ptt: true});
});
return await message.client.deleteMessage(message.jid, {id: downloading.key.id, remoteJid: message.jid, fromMe: true})
}));
}