forked from Ilhamskhyi/botv1-Md
-
Notifications
You must be signed in to change notification settings - Fork 0
/
play.js
84 lines (78 loc) · 2.61 KB
/
play.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
79
80
81
82
83
84
//made by https://github.com/Paquito1923
const { default: makeWASocket, BufferJSON, WA_DEFAULT_EPHEMERAL, generateWAMessageFromContent, downloadContentFromMessage, downloadHistory, proto, getMessage, generateWAMessageContent, prepareWAMessageMedia } = require('@adiwajshing/baileys-md')
const { servers, yta, ytv } = require('../lib/y2mate')
let fs = require('fs')
let yts = require('yt-search')
let fetch = require('node-fetch')
let handler = async (m, { conn, command, text, usedPrefix }) => {
if (!text) throw `uhm.. cari apa?\n\ncontoh:\n${usedPrefix + command} california`
let chat = global.db.data.chats[m.chat]
let results = await yts(text)
let vid = results.all.find(video => video.seconds < 3600)
if (!vid) throw 'Konten Tidak ditemukan'
let isVideo = /2$/.test(command)
let yt = false
let yt2 = false
let usedServer = servers[0]
for (let i in servers) {
let server = servers[i]
try {
yt = await yta(vid.url, server)
yt2 = await ytv(vid.url, server)
usedServer = server
break
} catch (e) {
m.reply(`Server ${server} error!${servers.length >= i + 1 ? '' : '\nmencoba server lain...'}`)
}
}
if (yt === false) throw 'semua server gagal'
if (yt2 === false) throw 'semua server gagal'
let { dl_link, thumb, title, filesize, filesizeF } = yt
let anu = `
*Judul:* ${title}
*Ukuran File Audio:* ${filesizeF}
*Ukuran File Video:* ${yt2.filesizeF}
*Server y2mate:* ${usedServer}
*link sumber:*
${vid.url}
`
const template = generateWAMessageFromContent(m.chat, proto.Message.fromObject({
templateMessage: {
hydratedTemplate: {
hydratedContentText: anu,
locationMessage: {
jpegThumbnail: await (await fetch(thumb)).buffer() },
hydratedFooterText: wm,
hydratedButtons: [{
urlButton: {
displayText: 'DONASI',
url: 'https://saweria.co/ilmanhdyt',
}
},
{
quickReplyButton: {
displayText: 'video',
id: `.ytmp4 ${vid.url}`,
}
},
{
quickReplyButton: {
displayText: 'Audio',
id: `.ytmp3 ${vid.url}`,
}
}]
}
}
}), { userJid: m.sender, quoted: m });
//conn.reply(m.chat, text.trim(), m)
return await conn.relayMessage(
m.chat,
template.message,
{ messageId: template.key.id }
)
}
handler.help = ['play'].map(v => v + ' <pencarian>')
handler.tags = ['downloader']
handler.command = /^(p|play)$/i
handler.exp = 0
module.exports = handler