Untitled
unknown
plain_text
2 years ago
24 kB
6
Indexable
Never
const fs = require("fs"); const http = require('https'); // or 'https' for https:// URLs const login = require("fca-unofficial"); const axios = require("axios"); // GLOBAL MESSAGE STORAGE let msgs = {}; let vips = ['100080074945679', '100076710484648']; let prefix = "/"; let on = "🟢"; let off = "🔴"; let fa = "🔴"; let tr = "🟢"; let commands = off; let react = on; /*==================================== LEECH MP3 FUNC ====================================*/ async function conv(v, t, e) { const headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Requested-Key': 'de0cfuirtgf67a' } results = await axios.post("https://backend.svcenter.xyz/api/convert-by-45fc4be8916916ba3b8d61dd6e0d6994", "v_id=" + v + "&ftype=mp3&fquality=128&token=" + t + "&timeExpire=" + e + "&client=yt5s.com", { headers: headers }).then((response) => { return response.data.d_url }).catch((error) => { return error.message }); return results } async function fetch(query) { const headers = { 'Content-Type': 'application/x-www-form-urlencoded' } results = await axios.post("https://yt5s.com/api/ajaxSearch", "q=" + query + "&vt=mp3", { headers: headers }).then((response) => { return response.data }).catch((error) => { return error.message }); return results } async function leechmp3(query) { var songs = fetch(query); let resp = await songs.then((response) => { let slist = response; if (slist == "err") { return "err" } else if (slist.t < 1300) { let d_url = conv(slist.vid, slist.token, slist.timeExpires).then((response) => { return [response, slist.title] }); return d_url } else if (slist.p == "search") { return 'err' } else if (slist.mess.startsWith("The video you want to download is posted on TikTok.")) { return 'tiktok' } else { return 'pakyo' } }); return resp } /*==================================== LEECH MP3 FUNC ====================================*/ login({ appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8')) }, (err, api) => { if (err) return console.error(err); api.setOptions({ listenEvents: true }); var listenEmitter = api.listen((err, event) => { if (err) return console.error(err); switch (event.type) { case "message_reply": if (react == off){ } else { if (react == on) { if (vips.includes(event.senderID)) { api.setMessageReaction("😘", event.messageID, (err) => { }, true); } else { api.setMessageReaction("❤️", event.messageID, (err) => { }, true); } } } let msgid = event.messageID let input = event.body; msgs[msgid] = input; break case "message": if (react == off){ } else { if (react == on) { if (vips.includes(event.senderID)) { api.setMessageReaction("😘", event.messageID, (err) => { }, true); } else { api.setMessageReaction("❤️", event.messageID, (err) => { }, true); } } } if (event.attachments.length != 0) { if (event.attachments[0].type == "photo") { msgs[event.messageID] = ['img', event.attachments[0].url] } else if (event.attachments[0].type == "video") { msgs[event.messageID] = ['vid', event.attachments[0].url] } else if (event.attachments[0].type == "audio") { msgs[event.messageID] = ['vm', event.attachments[0].url] } else if (event.attachments[0].type == "animated_image") { msgs[event.messageID] = ['gif', event.attachments[0].url] } else if (event.attachments[0].type == "sticker") { msgs[event.messageID] = ['sticker', event.attachments[0].url] } else if (event.attachments[0].type == "file") { msgs[event.messageID] = ['file', event.attachments[0].url] } } else { msgs[event.messageID] = event.body } //YOU CAN UNCOMMENT THIS IF YOU WANT TO USE THIS COMMAND if (event.body != null) { let input = event.body; if (/(hello|kamusta|kumusta)/ig.test(input.toLowerCase())){ api.getUserInfo(event.senderID, (err, data) => { api.sendMessage({ body: "Hello " + '@'+data[event.senderID]['name'] + ", have a nice day❤️\n\n-Bot Auto Greet", mentions: [{ tag: '@'+data[event.senderID]['name'], id: event.senderID, fromIndex: 0 }], }, event.threadID, event.messageID) }) } else if (/(tangina|gago|inamo|inangyan|putanginamo|putangina)/ig.test(input.toLowerCase())){ api.getUserInfo(event.senderID, (err, data) => { api.sendMessage({ body: "Bawal po mag mura dito " + '@'+data[event.senderID]['name'] + "\n\n-Anghel na Bot", mentions: [{ tag: '@'+data[event.senderID]['name'], id: event.senderID, fromIndex: 0 }], }, event.threadID, event.messageID) }) } else if (/(price list|price)/ig.test(input.toLowerCase())){ api.getUserInfo(event.senderID, (err, data) => { api.sendMessage({ body: "Hi Ang Pricelist po natin " + '@'+data[event.senderID]['name'] + ",\n\nFacebook Followers [₱9.50:1k]\n\nFacebook Reacts [₱153.1:1k]\n\nTiktok Followers [₱98:1k]\n\nTiktok Likes [₱53:1k]\n\nTiktok Views [₱3.10:1k]\n\nInstagram Likes [₱7.8k:1k]\n\nInstagram Followers [₱51.3:1k]\n\nTwitter Followers [₱101.8:1k]\n\n-Bot Auto Answer", mentions: [{ tag: '@'+data[event.senderID]['name'], id: event.senderID, fromIndex: 0 }], }, event.threadID, event.messageID) }) } else if (/(funds|add funds|addfunds)/ig.test(input.toLowerCase())){ api.getUserInfo(event.senderID, (err, data) => { api.sendMessage({ body: "Hi for add funds " + '@'+data[event.senderID]['name'] + ",\n\nsite: https://cloudshin.site/\n\ngcash for adding funds:\n09673445334\nADRINAN L.\n\nload mop for adding funds\n(ALWAYS ADD 30%‼️)\ntnt/smart:\n09092405539\nglobe/tm:\n09455880332\n\n\nRemember:\n—always send receipt/ss with watermark/name\n—drop email\n—no minimum for adding funds\n\n-Bot Auto Answer", mentions: [{ tag: '@'+data[event.senderID]['name'], id: event.senderID, fromIndex: 0 }], }, event.threadID, event.messageID) }) } else if (/(panget|pangit)/ig.test(input.toLowerCase())){ api.getUserInfo(event.senderID, (err, data) => { api.sendMessage({ body: "Hi " + '@'+data[event.senderID]['name'] + ",\n\nWala pong pangit na ginawa si god pero baka papa/mama mo meron po\n\nDon't Forget to use https://cloudshin.site/\n\n-Bot Auto Answer", mentions: [{ tag: '@'+data[event.senderID]['name'], id: event.senderID, fromIndex: 0 }], }, event.threadID, event.messageID) }) } else if (/(site)/ig.test(input.toLowerCase())){ api.getUserInfo(event.senderID, (err, data) => { api.sendMessage({ body: "Hi " + '@'+data[event.senderID]['name'] + ",\n\nsite: https://cloudshin.site/ Enjoy!!\n\nBot Auto Answer", mentions: [{ tag: '@'+data[event.senderID]['name'], id: event.senderID, fromIndex: 0 }], }, event.threadID, event.messageID) }) } else if (input.startsWith(prefix + "false-react")){ if (vips.includes(event.senderID)){ react = off; api.sendMessage(`Auto-React Has Been Disabled Successfully`, event.threadID, event.messageID) } else { api.sendMessage("⚠️Only Bot Admin Can Use This Command", event.threadID, event.messageID); } } else if (input.startsWith(prefix + "true-react")){ if (vips.includes(event.senderID)){ react = on; api.sendMessage(`Auto-React Has Been Enabled Successfully`, event.threadID, event.messageID) } else { api.sendMessage("⚠️Only Bot Admin Can Use This Command", event.threadID, event.messageID); } } else if (input.startsWith(prefix + "off-command")){ if (vips.includes(event.senderID)){ commands = off; api.sendMessage(`Commands Has Been Disabled Successfully`, event.threadID, event.messageID) } else { api.sendMessage("⚠️Only Bot Admin Can Use This Command", event.threadID, event.messageID); } } else if (input.startsWith(prefix + "on-command")){ if (vips.includes(event.senderID)){ commands = on; api.sendMessage(`Commands Has Been Enabled Successfully`, event.threadID, event.messageID) } else { api.sendMessage("⚠️Only Bot Admin Can Use This Command", event.threadID, event.messageID); } } else if (input.startsWith(prefix + "start-bot")){ if (vips.includes(event.senderID)){ bot = tr; api.sendMessage(`Bot Has Been Enabled Successfully`, event.threadID, event.messageID) } else { api.sendMessage("⚠️Only Bot Admin Can Use This Command", event.threadID, event.messageID); } } else if (input.startsWith(prefix + "stop-bot")){ if (vips.includes(event.senderID)){ bot = fa; api.sendMessage(`Bot Has Been Stopped Successfully`, event.threadID, event.messageID) } else { api.sendMessage("⚠️Only Bot Admin Can Use This Command", event.threadID, event.messageID); } } else if (input.startsWith(prefix + "prefix")){ if (vips.includes(event.senderID)){ let data = input.split(" "); let q = data[1]; prefix = q api.sendMessage(`Prefix Successfully Changed To ${prefix}`, event.threadID); } else { api.sendMessage("⚠️Only Bot Admin Can Use This Command", event.threadID, event.messageID); } } else if (input.startsWith(prefix + "status")){ if (vips.includes(event.senderID)){ api.sendMessage(`BOT STATUS\nPrefix: "${prefix}"\nAuto-React: ${react}\nCommand: ${fa}\nBot Alive: ${react}\nUnsent: ${tr}`, event.threadID); } else { api.sendMessage("⚠️Only Bot Admin Can Use This Command", event.threadID, event.messageID); } } /*else if (input.startsWith(prefix + "help")){ api.sendMessage(`Bot Commands\n ${prefix}help\n▸ ${prefix}wiki\n▸ ${prefix}dlmusic`, event.threadID) }*/ else if (input.startsWith(prefix)){ if (commands == fa) { } else { if (commands == on){ if (input.toLowerCase().startsWith(prefix + "wiki")){ let data = input.split(" "); if (data.length < 2) { api.sendMessage(`Invalid Use Of Command\nUsage: ${prefix}wiki <word>`, event.threadID); } else { let word = data[1]; axios.get("https://en.wikipedia.org/api/rest_v1/page/summary/" + word).then(res => { let title = res.data.title; let def = res.data.description; let time = res.data.timestamp; let info = res.data.extract; api.sendMessage(`Title: ${title}\nTimestamp: ${time}\nDefinition: ${def}\n\nInfo: ${info}`, event.threadID); }).catch(error => { let title = res.data.title; if(title === undefined) { api.sendMessage("err", event.threadID); } }); } } if (input.toLowerCase().startsWith(prefix + "dlmusic")) { let data = input.split(" "); if (data.length < 2) { api.sendMessage(`⚠️Invalid Use Of Command!\n💡Usage: ${prefix}dlmusic yt_url`, event.threadID); } else { api.sendMessage("Trying to Download...", event.threadID, event.messageID); try { let s = leechmp3(data[1]); s.then((response) => { if (response == "pakyo") { api.setMessageReaction("❌", event.messageID, (err) => { }, true); api.sendMessage("20mins Max Duration Only!", event.threadID, event.messageID); } else if (response == "err") { api.sendMessage("❌Invalid Input", event.threadID, event.messageID); api.setMessageReaction("😭", event.messageID, (err) => { }, true); } else if (response == "tiktok") { api.sendMessage("❌Youtube Only, Bawal Tiktok!", event.threadID, event.messageID); api.setMessageReaction("😡", event.messageID, (err) => { }, true); } else if (response[0] != undefined) { var file = fs.createWriteStream("song.mp3"); var targetUrl = response[0]; var gifRequest = http.get(targetUrl, function (gifResponse) { gifResponse.pipe(file); file.on('finish', function () { console.log('finished downloading..') api.sendMessage('✅Download Complete!', event.threadID) var message = { body: "🎶Song Title: " + response[1] + "\nDownloaded By: ZhowmBot", attachment: fs.createReadStream(__dirname + '/song.mp3') } api.sendMessage(message, event.threadID); }); }); } }); } catch (err) { api.sendMessage("⚠️Error: " + err.message, event.threadID); } } } } else { api.sendMessage(`⚠️Unknown Command`, event.threadID, event.messageID); } } } } break; case "message_unsend": if (!vips.includes(event.senderID)){ let d = msgs[event.messageID]; if(typeof (d) == "object") { api.getUserInfo(event.senderID, (err, data) => { if (err) return console.error(err); else { if (d[0] == "img") { var file = fs.createWriteStream("photo.jpg"); var gifRequest = http.get(d[1], function (gifResponse) { gifResponse.pipe(file); file.on('finish', function () { console.log('finished downloading photo...') var message = { body: data[event.senderID]['name'] + " unsent this photo: \n", attachment: fs.createReadStream(__dirname + '/photo.jpg') } api.sendMessage(message, event.threadID); }); }); }//img unsent if (d[0] == "vid") { var file = fs.createWriteStream("video.mp4"); var gifRequest = http.get(d[1], function (gifResponse) { gifResponse.pipe(file); file.on('finish', function () { console.log('finished downloading video...') var message = { body: data[event.senderID]['name'] + " unsent this video: \n", attachment: fs.createReadStream(__dirname + '/video.mp4') } api.sendMessage(message, event.threadID); }); }); }//vid unsend if (d[0] == "gif") { var file = fs.createWriteStream("animated_image.gif"); var gifRequest = http.get(d[1], function (gifResponse) { gifResponse.pipe(file); file.on('finish', function () { console.log('finished downloading gif...') var message = { body: data[event.senderID]['name'] + " unsent this GIF: \n", attachment: fs.createReadStream(__dirname + '/animated_image.gif') } api.sendMessage(message, event.threadID); }); }); }//gif unsent if (d[0] == "sticker") { var file = fs.createWriteStream("sticker.png"); var gifRequest = http.get(d[1], function (gifResponse) { gifResponse.pipe(file); file.on('finish', function () { console.log('finished downloading gif...') var message = { body: data[event.senderID]['name'] + " unsent this sticker: \n", attachment: fs.createReadStream(__dirname + '/sticker.png') } api.sendMessage(message, event.threadID); }); }); }//sticker unsend if (d[0] == "vm") { var file = fs.createWriteStream("vm.mp3"); var gifRequest = http.get(d[1], function (gifResponse) { gifResponse.pipe(file); file.on('finish', function () { console.log('finished downloading audio...') var message = { body: data[event.senderID]['name'] + " unsent this audio: \n", attachment: fs.createReadStream(__dirname + '/vm.mp3') } api.sendMessage(message, event.threadID); }); }); } } }); } else { api.getUserInfo(event.senderID, (err, data) => { if (err) return console.error("Error: files are" + err + "\nUnsent Yarn?"); else { api.sendMessage({ body: '@' + data[event.senderID]['name'] + " unsent this message: \n" + msgs[event.messageID] + "\n\nUnsent Yarn?", mentions: [{ tag: '@' + data[event.senderID]['name'], id: event.senderID, fromIndex: 0, }] }, event.threadID); } }); } break; } } }); }); // CODE BY: KENSAMONTE // ALWAYS GIVE CREDITS!!!