From ef217d2665b9b123a40552bc402f8d95489d26ae Mon Sep 17 00:00:00 2001 From: anubiskun Date: Wed, 19 Oct 2022 03:50:54 +0700 Subject: [PATCH] Update v2.2.0-core-2.5 --- anubis.js | 36 +- conf.js | 11 +- database.json | 2 +- library/conector.js | 960 ++++++++++++++------------ library/converter.js | 36 +- library/exif.js | 8 +- library/lib.js | 611 ++++++++++------ library/upload.js | 214 +++--- package.json | 29 +- plugins/__antiSipalingAnti.js | 88 +++ plugins/_antilink.js | 27 - plugins/_cmdCorection.js | 243 +++++-- plugins/_firstchat.js | 48 +- plugins/downloader.js | 168 +++-- plugins/menu.js | 20 +- plugins/mixGC.js | 207 +++--- plugins/mixGCA.js | 138 +++- plugins/mixOwner.js | 28 +- plugins/{sticker.js => mixsticker.js} | 87 +-- plugins/mixstickerfree.js | 75 ++ plugins/mixtools.js | 235 ++----- plugins/mixtoolsfree.js | 166 +++++ plugins/notesGC.js | 93 ++- plugins/template.js | 31 +- plugins/ytdl.js | 210 ++++-- 25 files changed, 2303 insertions(+), 1468 deletions(-) create mode 100644 plugins/__antiSipalingAnti.js delete mode 100644 plugins/_antilink.js rename plugins/{sticker.js => mixsticker.js} (59%) create mode 100644 plugins/mixstickerfree.js create mode 100644 plugins/mixtoolsfree.js diff --git a/anubis.js b/anubis.js index 4adc8a1..5a57943 100644 --- a/anubis.js +++ b/anubis.js @@ -6,8 +6,7 @@ */ require('./conf') - const yargs = require('yargs/yargs') - const opts = new Object(yargs(process.argv.slice(2)).exitProcess(false).parse()) + const opts = new Object(require('yargs/yargs')(process.argv.slice(2)).exitProcess(false).parse()) const { default: WAConnection ,DisconnectReason, useMultiFileAuthState, fetchLatestWaWebVersion, S_WHATSAPP_NET, makeInMemoryStore } = require('@adiwajshing/baileys') const { Boom } = require('@hapi/boom') const fs = require('fs') @@ -15,9 +14,9 @@ const _ = require('lodash') const syntaxerror = require('syntax-error') const pino = require('pino').default - const { Low, JSONFile } = require('./library/lowdb') + const { Low, JSONFileSync } = require('./library/lowdb') const mongoDB = require('./library/mongoDB') - const database = new Low(opts['test'] ? new JSONFile(`database.json`) : new mongoDB(mongoUser)) + const database = new Low(opts['test'] ? new JSONFileSync(`database.json`) : new mongoDB(mongoUser)) const store = makeInMemoryStore({ logger: pino().child({ level: 'silent', stream: 'store' }) }) const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) @@ -26,7 +25,7 @@ console.log('LOADING DATABASE...') await sleep(5000) if (database.READ) return new Promise((resolve) => setInterval(function () { (!database.READ ? (clearInterval(this), resolve(database.data == null ? loadDatabase() : database.data)) : null) }, 0.5 * 1000)) - if (database.data.users == null) { + if (database.data == null) { database.READ = true await database.read() database.READ = false @@ -97,8 +96,9 @@ auth: state, browser: [global.author,'Safari','1.0.0'], generateHighQualityLinkPreview: true, + linkPreviewImageThumbnailWidth: 200, syncFullHistory: true, - connectTimeoutMs: 1000, + connectTimeoutMs: 5000, }) anubis.db = database anubis.anubiskun = S_WHATSAPP_NET @@ -113,11 +113,11 @@ if (reason === DisconnectReason.badSession) { console.log(`Bad Session, reconnecting...`); reloadConnector(); } else if (reason === DisconnectReason.connectionClosed) { console.log("Connection closed"); reloadConnector(); } else if (reason === DisconnectReason.connectionLost) { console.log("Connection Lost from Server, reconnecting..."); reloadConnector(); } - else if (reason === DisconnectReason.connectionReplaced) { console.log("Connection Replaced, Another New Session Opened, Please Close Current Session First"); anubis.logout(); } - else if (reason === DisconnectReason.loggedOut) { console.log(`Device Logged Out, Please Scan Again And Run.`); anubis.logout(); } + else if (reason === DisconnectReason.connectionReplaced) { console.log("Connection Replaced, Another New Session Opened, Please Close Current Session First"); process.send('stop'); } + else if (reason === DisconnectReason.loggedOut) { console.log(`Device Logged Out, Please Scan Again And Run.`); delete database.data.auth[global.sesName]; await database.write(); reloadConnector(); } else if (reason === DisconnectReason.restartRequired) { console.log("Restart Required, Restarting..."); reloadConnector(); } else if (reason === DisconnectReason.timedOut) { console.log("Connection TimedOut, Reconnecting..."); reloadConnector(); } - else if (reason === DisconnectReason.multideviceMismatch) { console.log("Multi device mismatch, please scan again"); anubis.logout(); } + else if (reason === DisconnectReason.multideviceMismatch) { console.log("Multi device mismatch, please scan again"); delete database.data.auth[global.sesName]; await database.write(); reloadConnector() } else anubis.end(`Unknown DisconnectReason: ${reason}|${connection}`) } if (update.receivedPendingNotifications) { @@ -127,6 +127,19 @@ let a = await anubis.sendMessage(Owner + anubis.anubiskun, { text: 'Bot jalan ngab!' }) if (isLatest) anubis.sendMessage(Owner + anubis.anubiskun, { text: `New Update [ *anubisbot-MD* *v${version}* ]\n\n${changeLogs[0]}` }) if (a.status) console.log('BOT RUNNING!') + let prem = Object.entries(anubis.db.data.users).map(([key, value]) => {return {...value, jid: key}}).filter((v) => v.isPremium) + for (let user of prem){ + if (user.isPremium){ + if (user.premTime < (new Date() * 1)){ + anubis.db.data.users[user.jid].isPremium = false + anubis.db.data.users[user.jid].premTime = -1 + } + } + } + if (anubis.db.data.database.lastRestart){ + a = await anubis.sendMessage(Owner + anubis.anubiskun, {text: 'Aku kembali aaay! ๐Ÿ’–'}) + if (a.status) anubis.db.data.database.lastRestart = false + } }) } }) @@ -134,7 +147,7 @@ for (let i = 0; i < chatupdate.messages.length; i++) { const conn = anubisFunc(anubis, store) const anu = chatupdate.messages[i]; - if (!anu.message) return; + if (!anu.message && !anu.pushName) return; anu.message = Object.keys(anu.message)[0] === "ephemeralMessage" ? anu.message.ephemeralMessage.message : anu.message; if (anu.key && anu.key.remoteJid === "status@broadcast") return; if (anu.key.id.startsWith("BAE5") && anu.key.id.length === 16) return; @@ -152,10 +165,11 @@ anuCreds(); await database.write() }) + // require('./server.js')(anubis, store) return true } - + setTimeout(async () => { await loadDatabase() console.log('DATABASE LOADED!') diff --git a/conf.js b/conf.js index ff1a20f..1ed291e 100644 --- a/conf.js +++ b/conf.js @@ -1,16 +1,16 @@ const fs = require('fs') const path = require('path') -const yargs = require('yargs/yargs') -const opts = new Object(yargs(process.argv.slice(2)).exitProcess(false).parse()) +const opts = new Object(require('yargs/yargs')(process.argv.slice(2)).exitProcess(false).parse()) -global.botpublic = opts['test'] ? false : true // Bot Status +global.botpublic = true // Bot Status global.sesName = opts['test'] ? 'anubisTest' : 'anubisAuth' // Session Folder -global.mongoUser = 'mongodb+srv://test:test123@test.onzmz8w.mongodb.net/?retryWrites=true&w=majority' //mongo uri +global.mongoUser = opts['db'] ? (typeof opts['db'] !== 'string') ? 'mongodb+srv://test:test123@test.onzmz8w.mongodb.net/?retryWrites=true&w=majority' : opts['db'] : 'mongodb+srv://test:test123@test.onzmz8w.mongodb.net/?retryWrites=true&w=majority' global.ownerNum = ['6289653909054'] // owner number global.fla = 'https://www6.flamingtext.com/net-fu/proxy_form.cgi?&imageoutput=true&script=sketch-name&doScale=true&scaleWidth=800&scaleHeight=500&fontsize=100&fillTextType=1&fillTextPattern=Warning!&fillColor1Color=%23f2aa4c&fillColor2Color=%23f2aa4c&fillColor3Color=%23f2aa4c&fillColor4Color=%23f2aa4c&fillColor5Color=%23f2aa4c&fillColor6Color=%23f2aa4c&fillColor7Color=%23f2aa4c&fillColor8Color=%23f2aa4c&fillColor9Color=%23f2aa4c&fillColor10Color=%23f2aa4c&fillOutlineColor=%23f2aa4c&fillOutline2Color=%23f2aa4c&backgroundColor=%23101820&text=' global.thumb = fs.readFileSync('./library/intro.mp4') global.__root = path.join(__dirname, '/') global.__temp = path.join(__dirname, '/temp/') +global.lastMsg = {} global.msg = { err: "error ngab! coba hubungi owner", nUrl: "bad URL", @@ -28,9 +28,10 @@ global.mess = { global.anuCookie = { ig: '', // instagram cookies joox: '', // joox cookies + pinterest: '', // pinterest cookies soundcloud: 'iZIs9mchVcX5lhVRyQGGAYlNPVldzAoX', //soundcloud client_id } -global.pingWeb = '' +global.pingWeb = 'google.com' global.anuFooter = 'made with โค๏ธ by anubis' //footer text global.packname = 'gabut banh maknya bikin stiker!' // exif sticker package name global.author = '6289653909054 โ€ข anubis-bot' //exif sticker author diff --git a/database.json b/database.json index 9e26dfe..6f31cf5 100644 --- a/database.json +++ b/database.json @@ -1 +1 @@ -{} \ No newline at end of file +{ } \ No newline at end of file diff --git a/library/conector.js b/library/conector.js index 97defe1..217ab62 100644 --- a/library/conector.js +++ b/library/conector.js @@ -1,6 +1,8 @@ /** * anubisbot-MD https://github.com/anubiskun/anubisbot-MD * + * + * * Copyright (c) 2022 anubiskun * https://github.com/anubiskun */ @@ -8,6 +10,9 @@ let fs = require("fs"); const util = require("util"); const moment = require("moment-timezone"); +const opts = new Object( + require("yargs/yargs")(process.argv.slice(2)).exitProcess(false).parse() +); const { getBuffer, fetchJson, @@ -15,494 +20,547 @@ const { getGroupAdmins, anubisFunc, ucapan, + isNum, } = require("./lib"); -let isNum = (x) => typeof x === "number" && !isNaN(x); module.exports = { - async anuConector(chatUpdate, conn, m, store) { - const anubis = anubisFunc(conn, store); - const { isLatest, version, changeLogs } = await anubis.anuUpdate(); + async anuConector(chatUpdate, conn, m, store) { + const anubis = anubisFunc(conn, store); + const { isLatest, version, changeLogs } = await anubis.anuUpdate(); + try { + const body = + m.mtype === "conversation" + ? m.message.conversation + : m.mtype == "imageMessage" + ? m.message.imageMessage.caption + : m.mtype == "videoMessage" + ? m.message.videoMessage.caption + : m.mtype == "extendedTextMessage" + ? m.message.extendedTextMessage.text + : m.mtype == "buttonsResponseMessage" + ? m.message.buttonsResponseMessage.selectedButtonId + : m.mtype == "listResponseMessage" + ? m.message.listResponseMessage.singleSelectReply.selectedRowId + : m.mtype == "templateButtonReplyMessage" + ? m.message.templateButtonReplyMessage.selectedId + : m.mtype === "messageContextInfo" + ? m.message.buttonsResponseMessage?.selectedButtonId || + m.message.listResponseMessage?.singleSelectReply.selectedRowId || + m.text + : ""; + // var budy = typeof m.text == "string" ? m.text : ""; + const _prefx = /^[ยฐโ€ขฯ€รทร—ยถโˆ†ยฃยขโ‚ฌยฅยฎโ„ข+โœ“_/=|~!?@#%^&.ยฉ^]/gi; + // const _prefx = /^[/.!#]/gi + const prefix = _prefx.test(body) ? body.match(_prefx)[0] : ""; + const command = body + .replace(prefix, "") + .trim() + .split(/ +/) + .shift() + .toLowerCase(); + const args = body.trim().split(/ +/).slice(1); + const text = args.join(" "); + const pushname = m.pushName || "No Name"; + const botNumber = await anubis.decodeJid(anubis.user.id); + const mquo = m.quoted || m; + const quoted = + mquo.mtype == "buttonsMessage" + ? mquo[Object.keys(mquo)[1]] + : mquo.mtype == "templateMessage" + ? mquo.hydratedTemplate[Object.keys(mquo.hydratedTemplate)[1]] + : mquo.mtype == "product" + ? mquo[Object.keys(mquo)[0]] + : m.quoted + ? m.quoted + : m; + const mime = (quoted.msg || quoted).mimetype || ""; + const qmsg = quoted.msg || quoted; try { - const body = - m.mtype === "conversation" - ? m.message.conversation - : m.mtype == "imageMessage" - ? m.message.imageMessage.caption - : m.mtype == "videoMessage" - ? m.message.videoMessage.caption - : m.mtype == "extendedTextMessage" - ? m.message.extendedTextMessage.text - : m.mtype == "buttonsResponseMessage" - ? m.message.buttonsResponseMessage.selectedButtonId - : m.mtype == "listResponseMessage" - ? m.message.listResponseMessage.singleSelectReply.selectedRowId - : m.mtype == "templateButtonReplyMessage" - ? m.message.templateButtonReplyMessage.selectedId - : m.mtype === "messageContextInfo" - ? m.message.buttonsResponseMessage?.selectedButtonId || - m.message.listResponseMessage?.singleSelectReply.selectedRowId || - m.text - : ""; - // var budy = typeof m.text == "string" ? m.text : ""; - const _prefx = /^[ยฐโ€ขฯ€รทร—ยถโˆ†ยฃยขโ‚ฌยฅยฎโ„ข+โœ“_/=|~!?@#%^&.ยฉ^]/gi; - // const _prefx = /^[/.!#]/gi - const prefix = _prefx.test(body) ? body.match(_prefx)[0] : ""; - const command = body - .replace(prefix, "") - .trim() - .split(/ +/) - .shift() - .toLowerCase(); - const args = body.trim().split(/ +/).slice(1); - const text = args.join(" "); - const pushname = m.pushName || "No Name"; - const botNumber = await anubis.decodeJid(anubis.user.id); - const mquo = m.quoted || m; - const quoted = - mquo.mtype == "buttonsMessage" - ? mquo[Object.keys(mquo)[1]] - : mquo.mtype == "templateMessage" - ? mquo.hydratedTemplate[Object.keys(mquo.hydratedTemplate)[1]] - : mquo.mtype == "product" - ? mquo[Object.keys(mquo)[0]] - : m.quoted - ? m.quoted - : m; - const mime = (quoted.msg || quoted).mimetype || ""; - const qmsg = quoted.msg || quoted; - try { - if (typeof anubis.db.data.users[m.sender] !== "object") - anubis.db.data.users[m.sender] = {}; - let user = anubis.db.data.users[m.sender]; - if (!("name" in user)) user.name = anubis.getName(m.sender); - if (!("isBanned" in user)) user.isBanned = false; - if (!("isPremium" in user)) user.isPremium = false; - if (!isNum(user.limit)) user.limit = 100; - if (!("isMute" in user)) user.isMute = false; - if (!isNum(user.pc)) user.pc = -1; - if (!isNum(user.cCorect)) user.cCorect = -1; - if (!isNum(user.cUpdate)) user.cUpdate = -1; - if (!isNum(user.warn)) user.warn = 0; + if (typeof anubis.db.data.users !== "object") anubis.db.data.users = {}; + if (typeof anubis.db.data.users[m.sender] !== "object") + anubis.db.data.users[m.sender] = {}; + let user = anubis.db.data.users[m.sender]; + if (!("name" in user)) user.name = anubis.getName(m.sender); + if (user.name !== anubis.getName(m.sender)) + user.name = anubis.getName(m.sender); // update name + if (!("isBanned" in user)) user.isBanned = false; + if (!("isPremium" in user)) user.isPremium = false; + if (!isNum(user.premTime)) user.premTime = -1; + if (!isNum(user.limit)) user.limit = 50; + if (!("isMute" in user)) user.isMute = false; + if (!isNum(user.pc)) user.pc = -1; + if (!isNum(user.cCorect)) user.cCorect = -1; + if (!isNum(user.cUpdate)) user.cUpdate = -1; + if (!isNum(user.warn)) user.warn = 0; - if (m.isGroup) { - if (typeof anubis.db.data.database[m.chat] !== "object") - anubis.db.data.database[m.chat] = {}; - if (typeof anubis.db.data.chats[m.chat] !== "object") - anubis.db.data.chats[m.chat] = {}; - let chats = anubis.db.data.chats[m.chat]; - if (!("isMute" in chats)) chats.isMute = false; - if (!("isBanned" in chats)) chats.isBanned = false; - } - - if (typeof anubis.db.data.settings[botNumber] !== "object") - anubis.db.data.settings[botNumber] = {}; - let setting = anubis.db.data.settings[botNumber]; - if (!("anticall" in setting)) setting.anticall = true; - if (!("automess" in setting)) setting.automess = true; - if (!("restrict" in setting)) setting.restrict = false; - if (!("antilink" in setting)) setting.antilink = true; - if (!("jadibot" in setting)) setting.jadibot = true; - if (typeof setting.thumbnail !== "object") setting.thumbnail = {}; - if (!("buffer" in setting.thumbnail)) - setting.thumbnail.buffer = anubis.decodeBuffer(global.thumb); - if (!("thumb" in setting.thumbnail)) - setting.thumbnail.thumb = anubis.decodeBuffer( - await ( - await anubis.genThumb(global.thumb) - ).thumbnail - ); - if (!("type" in setting.thumbnail)) setting.thumbnail.type = "image"; + let database = anubis.db.data.database; + if (typeof database.note !== "object") database.note = {}; + if (!("lastRestart" in database)) database.lastRestart = false; + if (!("banUrl" in database)) database.banUrl = ["chat.whatsapp.com"]; - let others = anubis.db.data.others; - if (typeof others.vote !== "object") others.vote = []; - } catch (err) { - m.err(err, "setup database"); + if (m.isGroup) { + if (typeof database.note[m.chat] !== "object") + database.note[m.chat] = {}; + if (typeof anubis.db.data.chats[m.chat] !== "object") + anubis.db.data.chats[m.chat] = {}; + let chats = anubis.db.data.chats[m.chat]; + const gcmeta = await anubis.groupMetadata(m.chat); + if (!("name" in chats)) chats.name = gcmeta.subject; + if (chats.name !== gcmeta.subject) chats.name = gcmeta.subject; // update gc name + if (!("ismute" in chats)) chats.ismute = false; + if (!("isBanned" in chats)) chats.isBanned = false; + if (!("antiviewonce" in chats)) chats.antiviewonce = false; + if (!("antilink" in chats)) chats.antilink = false; + if (!("welcomer" in chats)) chats.welcomer = false; + if (!("banUrl" in chats)) chats.banUrl = []; } - if (m.message) { - anubis.readMessages([m.key]); - console.log( - `[ PESAN ] -> ${m.sender} \n${moment - .tz("Asia/Jakarta") - .format("HH:mm:ss")} > ${pushname} => ` + body + + if (typeof anubis.db.data.settings[botNumber] !== "object") + anubis.db.data.settings[botNumber] = {}; + let setting = anubis.db.data.settings[botNumber]; + if (!("anticall" in setting)) setting.anticall = true; + if (!("automess" in setting)) setting.automess = true; + if (!("restrict" in setting)) setting.restrict = false; + if (!("igCookie" in setting)) setting.igCookie = global.anuCookie.ig; + if (typeof setting.thumbnail !== "object") + setting.thumbnail = global.thumb; + if (!("buffer" in setting.thumbnail)) + setting.thumbnail.buffer = anubis.decodeBuffer(global.thumb); + if (!("thumb" in setting.thumbnail)) + setting.thumbnail.thumb = anubis.decodeBuffer( + (await anubis.genThumb(global.thumb)) + ? await ( + await anubis.genThumb(global.thumb) + ).thumbnail + : false ); - } + if (!("type" in setting.thumbnail)) setting.thumbnail.type = "video"; - for (let name in global.plugins) { - let plugin = global.plugins[name]; - if (!plugin) continue; - if (plugin.disabled) continue; - if (!plugin.all) continue; - if (typeof plugin.all !== "function") continue; - try { - await plugin.all.call( - this, - m, - anubis, - { - text, - command, - args, - prefix, - pushname, - }, - chatUpdate - ); - } catch (err) { - if (typeof err === "string") continue; - console.log(err); - } + let others = anubis.db.data.others; + if (typeof others.vote !== "object") others.vote = []; + } catch (err) { + m.err(err, "setup database"); + } + global.anuCookie.ig = anubis.db.data.settings[botNumber].igCookie; + if (m.message) { + anubis.readMessages([m.key]); + console.log( + `[ PESAN ] -> ${m.sender} \n${moment + .tz("Asia/Jakarta") + .format("HH:mm:ss")} > ${pushname} => ` + body + ); + } + if (00 >= moment.tz("Asia/Jakarta").format("HH")) { + // reset limit after 00:00 UTC + 07:00 Jakarta + if (00 <= moment.tz("Asia/Jakarta").format("mm")) { + let limit = Object.entries(anubis.db.data.users).map( + ([key, value]) => { + return { ...value, jid: key }; + } + ); + limit.map((v) => { + if (v.limit < 10) { + anubis.db.data.users[v.jid].limit = 10; + } + }); } + } - const isMedia = /image|video|sticker|audio/.test(mime); - const isAnubis = `6289653909054${anubis.anubiskun}`.includes(m.sender); - const itsMe = m.sender == botNumber ? true : false; - const isCmd = body.startsWith(prefix); - const groupMetadata = m.isGroup - ? await anubis.groupMetadata(m.chat).catch((e) => { - m.err(e); - }) - : ""; - const groupName = m.isGroup ? groupMetadata.subject : ""; - const participants = m.isGroup ? groupMetadata.participants : ""; - const groupAdmins = m.isGroup ? getGroupAdmins(participants) : ""; - const isBotAdmin = m.isGroup ? groupAdmins.includes(botNumber) : false; - const isAdmin = m.isGroup ? groupAdmins.includes(m.sender) : false; - m.isPremium = anubis.db.data.users[m.sender].isPremium - m.limit = (m.isPremium) ? 1 : anubis.db.data.users[m.sender].limit - global.ownerNum.forEach((Owner) => { - if (new Date() - anubis.db.data.users[m.sender].cUpdate < 3600000) - return; // count 1 hour - if (isLatest) - anubis.sendMessage(Owner + anubis.anubiskun, { - text: `New Update [ *anubisbot-MD* *v${version}* ]\n\n${changeLogs[0]}`, - }); - anubis.db.data.users[m.sender].cUpdate = new Date() * 1; - }); - const isJadibot = global["jadibot-" + m.sender.split("@")[0]] - ? global["jadibot-" + m.sender.split("@")[0]].status - : false; + const isMedia = /image|video|sticker|audio/.test(mime); + const isAnubis = `6289653909054${anubis.anubiskun}`.includes(m.sender); + const itsMe = m.sender == botNumber ? true : false; + const isCmd = body.startsWith(prefix); + const groupMetadata = m.isGroup + ? await anubis.groupMetadata(m.chat).catch((e) => { + m.err(e); + }) + : ""; + const groupName = m.isGroup ? groupMetadata.subject : ""; + const participants = m.isGroup ? groupMetadata.participants : ""; + const groupAdmins = m.isGroup ? getGroupAdmins(participants) : ""; + const isBotAdmin = m.isGroup ? groupAdmins.includes(botNumber) : false; + const isOwner = m.isGroup + ? groupMetadata.owner.includes(m.sender) + : false; + const isAdmin = m.isGroup ? groupAdmins.includes(m.sender) : false; + m.isAdmin = isAdmin; + m.isOwner = isOwner; + m.isPremium = anubis.db.data.users[m.sender].isPremium; + m.limit = m.isPremium ? 1 : anubis.db.data.users[m.sender].limit; + global.ownerNum.forEach((Owner) => { + if (new Date() - anubis.db.data.users[m.sender].cUpdate < 3600000) + return; // count 1 hour + if (isLatest) + anubis.sendMessage(Owner + anubis.anubiskun, { + text: `New Update [ *anubisbot-MD* *v${version}* ]\n\n${changeLogs[0]}`, + }); + anubis.db.data.users[m.sender].cUpdate = new Date() * 1; + }); - if (!global.botpublic) { - if (!isAnubis) return; + for (let name in global.plugins) { + let plugin = global.plugins[name]; + if (!plugin) continue; + if (plugin.disabled) continue; + if (!plugin.all) continue; + if (typeof plugin.all !== "function") continue; + try { + await plugin.all.call( + this, + m, + anubis, + { + conn, + store, + text, + command, + args, + prefix, + pushname, + opts, + }, + chatUpdate + ); + } catch (err) { + if (typeof err === "string") continue; + console.log(err); } - if (m.isBaileys) return; - if (m.chat.endsWith("broadcast")) return; - if (anubis.db.data.users[m.sender].isMute) return; + } - for (let name in global.plugins) { - let plugin = global.plugins[name]; - if (!plugin) continue; - if (plugin.disabled) continue; - if (!anubis.db.data.settings[botNumber].restrict) - if (plugin.tags && plugin.tags.includes("admin")) continue; - const str2Regex = (str) => str.replace(_prefx, "\\$&"); - let _prefix = plugin.customPrefix - ? plugin.customPrefix - : anuplug.prefix - ? anuplug.prefix - : _prefx; - let match = ( - _prefix instanceof RegExp - ? [[_prefix.exec(body), _prefix]] - : Array.isArray(_prefix) - ? _prefix.map((p) => { - let re = p instanceof RegExp ? p : new RegExp(str2Regex(p)); - return [re.exec(body), re]; - }) - : typeof _prefix === "string" - ? [ - [ - new RegExp(str2Regex(_prefix)).exec(body), - new RegExp(str2Regex(_prefix)), - ], - ] - : [[[], new RegExp()]] - ).find((p) => p[1]); - if (typeof plugin.before === "function") - if ( - await plugin.before.call(this, m, anubis, { - text, - command, - args, - prefix, - pushname, - ucapan, - botNumber, - match, - chatUpdate, - isAnubis, - itsMe, - groupMetadata, - participants, - isAdmin, - isBotAdmin, - }) - ) - continue; - if (typeof plugin !== "function") continue; - let usedPrefix = prefix; - if (usedPrefix) { - let noPrefix = body.replace(usedPrefix, ""); - let fail = plugin.fail || global.dfail; - let isAccept = - plugin.command instanceof RegExp - ? plugin.command.test(command) - : Array.isArray(plugin.command) - ? plugin.command.some((cmd) => - cmd instanceof RegExp ? cmd.test(command) : cmd === command - ) - : typeof plugin.command === "string" - ? plugin.command === command - : false; + if (!global.botpublic) { + if (!isAnubis) return; + } + if (m.isBaileys) return; + if (m.chat.endsWith("broadcast")) return; - if (!isAccept) continue; - m.plugin = name; - if (plugin.isAnubis && !isAnubis) { - fail("isAnubis", m, anubis); - continue; - } - if (plugin.private && m.isGroup && !isAnubis) { - fail("private", m, anubis); - continue; - } - if (plugin.group && !m.isGroup && !isAnubis) { - fail("group", m, anubis); - continue; - } else if (plugin.botAdmin && !isBotAdmin) { - fail("botAdmin", m, anubis); - continue; - } else if (plugin.admin && !isAdmin && !isAnubis) { - fail("admin", m, anubis); - continue; - } - if (plugin.isPremium && !isAnubis) { // for use limit ,Recommended!, separate commands in each file - anubis.db.data.users[m.sender].limit = (m.limit === 0) ? m.limit : (m.limit - 1) - if (m.limit < 1) { - anubis.sendContact(m.chat, global.ownerNum, m); - fail("isPremium", m, anubis); - continue; - } - } - if (plugin.premium && !isAnubis){ // premium only - fail("Premium", m, anubis) - continue; - } - let extra = { + // user + if (anubis.db.data.users[m.sender].isMute) return; + if (anubis.db.data.users[m.sender].isBanned) return; + // group + if (m.isGroup) { + if (anubis.db.data.chats[m.chat].ismute) return; + } + + for (let name in global.plugins) { + let plugin = global.plugins[name]; + if (!plugin) continue; + if (plugin.disabled) continue; + if (!anubis.db.data.settings[botNumber].restrict) + if (plugin.tags && plugin.tags.includes("admin")) continue; + const str2Regex = (str) => str.replace(_prefx, "\\$&"); + let _prefix = plugin.customPrefix + ? plugin.customPrefix + : anuplug.prefix + ? anuplug.prefix + : _prefx; + let match = ( + _prefix instanceof RegExp + ? [[_prefix.exec(body), _prefix]] + : Array.isArray(_prefix) + ? _prefix.map((p) => { + let re = p instanceof RegExp ? p : new RegExp(str2Regex(p)); + return [re.exec(body), re]; + }) + : typeof _prefix === "string" + ? [ + [ + new RegExp(str2Regex(_prefix)).exec(body), + new RegExp(str2Regex(_prefix)), + ], + ] + : [[[], new RegExp()]] + ).find((p) => p[1]); + if (typeof plugin.before === "function") + if ( + await plugin.before.call(this, m, anubis, { conn, store, - match, - usedPrefix, - noPrefix, - args, - command, text, - mime, - qmsg, - chatUpdate, - fetchJson, - getSizeMedia, - getBuffer, + command, + args, + prefix, pushname, + ucapan, botNumber, - groupName, + match, + chatUpdate, + isAnubis, + itsMe, groupMetadata, participants, isAdmin, isBotAdmin, - isMedia, - isJadibot, - isAnubis, - itsMe, - isCmd, - }; - try { - anubis.sendPresenceUpdate("composing", m.chat); - await plugin.call(this, m, anubis, extra); - } catch (err) { - m.error = err; - m.err(err); - } finally { - if (typeof plugin.after === "function") { - try { - await plugin.after.call(this, m, anubis, extra); - } catch (err) { - m.err(err); - console.log(err); - } - } + }) + ) + continue; + if (typeof plugin !== "function") continue; + let usedPrefix = prefix; + if (usedPrefix) { + let noPrefix = body.replace(usedPrefix, ""); + let fail = plugin.fail || global.dfail; + let isAccept = + plugin.command instanceof RegExp + ? plugin.command.test(command) + : Array.isArray(plugin.command) + ? plugin.command.some((cmd) => + cmd instanceof RegExp ? cmd.test(command) : cmd === command + ) + : typeof plugin.command === "string" + ? plugin.command === command + : false; + + if (!isAccept) continue; + m.plugin = name; + if (plugin.isAnubis && !isAnubis) { + fail("isAnubis", m, anubis); + continue; + } + if (plugin.private && m.isGroup && !isAnubis) { + fail("private", m, anubis); + continue; + } + if (plugin.group && !m.isGroup && !isAnubis) { + fail("group", m, anubis); + continue; + } else if (plugin.botAdmin && !isBotAdmin) { + fail("botAdmin", m, anubis); + continue; + } else if (plugin.admin && !isAdmin && !isAnubis) { + fail("admin", m, anubis); + continue; + } + if (plugin.isPremium && !isAnubis) { + // for use limit ,Recommended!, separate commands in each file + anubis.db.data.users[m.sender].limit = + m.limit === 0 ? m.limit : m.limit - 1; + if (m.limit < 1) { + anubis.sendContact(m.chat, global.ownerNum, m); + fail("isPremium", m, anubis); + continue; } - break; } - } - } catch (err) { - m.err(err); - console.log(err); - } finally { - let stats = anubis.db.data.stats; - if (m) { - let stat; - if (m.plugin) { - let now = +new Date(); - if (m.plugin in stats) { - stat = stats[m.plugin]; - if (!isNum(stat.total)) stat.total = 1; - if (!isNum(stat.success)) stat.success = m.error != null ? 0 : 1; - if (!isNum(stat.last)) stat.last = now; - if (!isNum(stat.lastSuccess)) - stat.lastSuccess = m.error != null ? 0 : now; - } else - stat = stats[m.plugin] = { - total: 1, - success: m.error != null ? 0 : 1, - last: now, - lastSuccess: m.error != null ? 0 : now, - }; - stat.total += 1; - stat.last = now; - if (m.error == null) { - stat.success += 1; - stat.lastSuccess = now; + if (plugin.premium && !isAnubis) { + // premium only + fail("Premium", m, anubis); + continue; + } + let extra = { + conn, + store, + match, + usedPrefix, + noPrefix, + args, + command, + text, + body, + mime, + qmsg, + chatUpdate, + fetchJson, + getSizeMedia, + getBuffer, + pushname, + botNumber, + groupName, + groupMetadata, + participants, + isOwner, + isAdmin, + isBotAdmin, + isMedia, + isAnubis, + itsMe, + isCmd, + }; + try { + anubis.sendPresenceUpdate("composing", m.chat); + await plugin.call(this, m, anubis, extra); + } catch (err) { + m.error = err; + m.err(err); + } finally { + if (typeof plugin.after === "function") { + try { + await plugin.after.call(this, m, anubis, extra); + } catch (err) { + m.err(err); + console.log(err); + } } } + break; } } - }, - contactUpdate(contactUpdate, anubis, store) { - for (let contact of contactUpdate) { - let id = anubis.decodeJid(contact.id); - if (store && store.contacts) - store.contacts[id] = { id, name: contact.notify }; - } - }, - async callUpdate(callUpdate, anubis) { - let botNum = await anubis.decodeJid(anubis.user.id); - let anu = anubis.db.data.settings[botNum] - ? anubis.db.data.settings[botNum].anticall - : false; - if (!anu) return; - for (let secure of callUpdate) { - if (secure.from.startsWith("6289653909054")) return; - if (secure.isGroup == false) { - if (secure.status == "offer") { - let hajar = await anubis.sendMessage(secure.from, { - text: `*${anubis.user.name}* tidak bisa menerima panggilan ${ - secure.isVideo ? `video` : `suara` - }. Maaf @${ - secure.from.split("@")[0] - } kamu akan di blockir. Jika tidak sengaja silahkan hubungi Owner untuk dibuka!`, - }); - anubis.sendMessage("6289653909054" + anubis.anubiskun, { - text: `wa.me/${secure.from.replace( - anubis.anubiskun, - "" - )} baru saja di blockir!`, - }); - let a = await anubis.sendContact(secure.from, ownerNum, hajar); - if (a.status) - return await anubis.updateBlockStatus(secure.from, "block"); + } catch (err) { + m.err(err, "core error"); + m.error = err; + console.log(err); + } finally { + let stats = anubis.db.data.stats; + if (m) { + let stat; + if (m.plugin) { + let now = +new Date(); + if (m.plugin in stats) { + stat = stats[m.plugin]; + if (!isNum(stat.total)) stat.total = 1; + if (!isNum(stat.success)) stat.success = m.error != null ? 0 : 1; + if (!isNum(stat.last)) stat.last = now; + if (!isNum(stat.lastSuccess)) + stat.lastSuccess = m.error != null ? 0 : now; + } else + stat = stats[m.plugin] = { + total: 1, + success: m.error != null ? 0 : 1, + last: now, + lastSuccess: m.error != null ? 0 : now, + }; + stat.total += 1; + stat.last = now; + if (m.error == null) { + stat.success += 1; + stat.lastSuccess = now; } } } - }, - async gcParticipantUpdate(gcUpdate, anubis) { - try { - let metadata = await anubis.groupMetadata(gcUpdate.id); - let participants = gcUpdate.participants; - let pUser, pGroup; - for (let num of participants) { - try { - pUser = await anubis.profilePictureUrl(num, "image"); - } catch (e) { - pUser = "https://tinyurl.com/yx93l6dan"; - } - try { - pGroup = await anubis.profilePictureUrl(gcUpdate.id, "image"); - } catch (e) { - pGroup = "https://tinyurl.com/yx93l6dan"; - } + } + }, + contactUpdate(contactUpdate, anubis, store) { + for (let contact of contactUpdate) { + let id = anubis.decodeJid(contact.id); + if (store && store.contacts) + store.contacts[id] = { id, name: contact.notify }; + } + }, + async callUpdate(callUpdate, anubis) { + let botNum = await anubis.decodeJid(anubis.user.id); + let anu = anubis.db.data.settings[botNum] + ? anubis.db.data.settings[botNum].anticall + : false; + if (!anu) return; + for (let secure of callUpdate) { + if (secure.from.startsWith("6289653909054")) return; + if (secure.isGroup == false) { + if (secure.status == "offer") { + let hajar = await anubis.sendMessage(secure.from, { + text: `*${anubis.user.name}* tidak bisa menerima panggilan ${ + secure.isVideo ? `video` : `suara` + }. Maaf @${ + secure.from.split("@")[0] + } kamu akan di blockir. Jika tidak sengaja silahkan hubungi Owner untuk dibuka!`, + }); + anubis.sendMessage("6289653909054" + anubis.anubiskun, { + text: `wa.me/${secure.from.replace( + anubis.anubiskun, + "" + )} baru saja di blockir!`, + }); + let a = await anubis.sendContact(secure.from, ownerNum, hajar); + if (a.status) + return await anubis.updateBlockStatus(secure.from, "block"); + } + } + } + }, + async gcParticipantUpdate(gcUpdate, anubis) { + try { + let metadata = await anubis.groupMetadata(gcUpdate.id); + let participants = gcUpdate.participants; + let pUser, pGroup; + for (let num of participants) { + try { + pUser = await anubis.profilePictureUrl(num, "image"); + } catch (e) { + pUser = "https://tinyurl.com/yx93l6dan"; + } + try { + pGroup = await anubis.profilePictureUrl(gcUpdate.id, "image"); + } catch (e) { + pGroup = "https://tinyurl.com/yx93l6dan"; + } - if (gcUpdate.action == "add") { - anubis.sendMessage(gcUpdate.id, { - image: { url: pUser }, - mentions: [num], - caption: `Welcome To ${metadata.subject} @${num.split("@")[0]}`, - }); - } else if (gcUpdate.action == "remove") { - anubis.sendMessage(gcUpdate.id, { - image: { url: pUser }, - mentions: [num], - caption: `@${num.split("@")[0]} Leaving To ${metadata.subject}`, - }); - } else if (gcUpdate.action == "promote") { - anubis.sendMessage(gcUpdate.id, { - image: { url: pUser }, - mentions: [num], - caption: `@${num.split("@")[0]} Promote From ${metadata.subject}`, - }); - } else if (gcUpdate.action == "demote") { - anubis.sendMessage(gcUpdate.id, { - image: { url: pUser }, - mentions: [num], - caption: `@${num.split("@")[0]} Demote From ${metadata.subject}`, - }); - } + if (gcUpdate.action == "add") { + anubis.sendMessage(gcUpdate.id, { + image: { url: pUser }, + mentions: [num], + caption: `Welcome To ${metadata.subject} @${num.split("@")[0]}`, + }); + } else if (gcUpdate.action == "remove") { + anubis.sendMessage(gcUpdate.id, { + image: { url: pUser }, + mentions: [num], + caption: `@${num.split("@")[0]} Leaving To ${metadata.subject}`, + }); + } else if (gcUpdate.action == "promote") { + anubis.sendMessage(gcUpdate.id, { + image: { url: pUser }, + mentions: [num], + caption: `@${num.split("@")[0]} Promote From ${metadata.subject}`, + }); + } else if (gcUpdate.action == "demote") { + anubis.sendMessage(gcUpdate.id, { + image: { url: pUser }, + mentions: [num], + caption: `@${num.split("@")[0]} Demote From ${metadata.subject}`, + }); } - } catch (err) { - console.err(err); } - }, - async gcUpdate(gcUp, anubis) { - try { - for(let noir of gcUp) { - let pGroup; - try { - pGroup = await anubis.profilePictureUrl(noir.id, "image"); - } catch (e) { - pGroup = "https://tinyurl.com/yx93l6dan"; - } - - if (noir.announce == true) { - anubis.sendMessage(gcUpdate.id, { - image: { url: pGroup }, - caption: `ใ€Œ Group Settings Change ใ€\n\nGroup telah ditutup oleh admin, Sekarang hanya admin yang dapat mengirim pesan !`, - }); - } else if (noir.announce == false) { - anubis.sendMessage(gcUpdate.id, { - image: { url: pGroup }, - caption: `ใ€Œ Group Settings Change ใ€\n\nGroup telah dibuka oleh admin, Sekarang peserta dapat mengirim pesan !`, - }); - } else if (noir.restrict == true) { - anubis.sendMessage(gcUpdate.id, { - image: { url: pGroup }, - caption: `ใ€Œ Group Settings Change ใ€\n\nInfo group telah dibatasi, Sekarang hanya admin yang dapat mengedit info group !`, - }); - } else if (noir.restrict == false) { - anubis.sendMessage(gcUpdate.id, { - image: { url: pGroup }, - caption: `ใ€Œ Group Settings Change ใ€\n\nInfo group telah dibuka, Sekarang peserta dapat mengedit info group !`, - }); - } else { - anubis.sendMessage(gcUpdate.id, { - image: { url: pGroup }, - caption: `ใ€Œ Group Settings Change ใ€\n\nGroup Subject telah diganti menjadi *${noir.subject}*`, - }); - } + } catch (err) { + console.err(err); + } + }, + async gcUpdate(gcUp, anubis) { + try { + for (let noir of gcUp) { + let pGroup; + try { + pGroup = await anubis.profilePictureUrl(noir.id, "image"); + } catch (e) { + pGroup = "https://tinyurl.com/yx93l6dan"; + } + + if (noir.announce == true) { + anubis.sendMessage(gcUpdate.id, { + image: { url: pGroup }, + caption: `ใ€Œ Group Settings Change ใ€\n\nGroup telah ditutup oleh admin, Sekarang hanya admin yang dapat mengirim pesan !`, + }); + } else if (noir.announce == false) { + anubis.sendMessage(gcUpdate.id, { + image: { url: pGroup }, + caption: `ใ€Œ Group Settings Change ใ€\n\nGroup telah dibuka oleh admin, Sekarang peserta dapat mengirim pesan !`, + }); + } else if (noir.restrict == true) { + anubis.sendMessage(gcUpdate.id, { + image: { url: pGroup }, + caption: `ใ€Œ Group Settings Change ใ€\n\nInfo group telah dibatasi, Sekarang hanya admin yang dapat mengedit info group !`, + }); + } else if (noir.restrict == false) { + anubis.sendMessage(gcUpdate.id, { + image: { url: pGroup }, + caption: `ใ€Œ Group Settings Change ใ€\n\nInfo group telah dibuka, Sekarang peserta dapat mengedit info group !`, + }); + } else { + anubis.sendMessage(gcUpdate.id, { + image: { url: pGroup }, + caption: `ใ€Œ Group Settings Change ใ€\n\nGroup Subject telah diganti menjadi *${noir.subject}*`, + }); } - } catch (err) { - console.err(err); } - }, - }; + } catch (err) { + console.err(err); + } + }, +}; - global.dfail = (type, m, anubis) => { - let msg = { - isAnubis: "Cuma buat Owner Anubis ngab! lu siapa???!!", - isPremium: "Limit habis!,\nBeli limit kelipatan 200/10k! ke owner", - Premium: "Cuma buat member premium ngab!, yo beli title Premium ke owner", - group: "Cuma bisa di Group ngab ga bisa di sini", - private: "Cuma bisa di Private Chat ngab ga bisa di sini!", - admin: "Cuma buat admin ngab! lu siapa???!!", - botAdmin: "Perintah di luar nalar!\njadiin admin dulu ngab! ", - }[type]; - if (msg) return m.reply(msg); +global.dfail = (type, m, anubis) => { + let msg = { + isAnubis: "Cuma buat Owner Anubis ngab! lu siapa???!!", + isPremium: "Limit habis!,\nBeli limit kelipatan 200/10k! ke owner", + Premium: "Cuma buat member premium ngab!, yo beli title Premium ke owner", + group: "Cuma bisa di Group ngab ga bisa di sini", + private: "Cuma bisa di Private Chat ngab ga bisa di sini!", + admin: "Cuma buat admin ngab! lu siapa???!!", + botAdmin: "Perintah di luar nalar!\njadiin admin dulu ngab! ", + }[type]; + if (msg) return m.reply(msg); }; diff --git a/library/converter.js b/library/converter.js index 685f9dc..9adc26d 100644 --- a/library/converter.js +++ b/library/converter.js @@ -145,10 +145,8 @@ file = buffer } return ffmpeg(file, [ - "-vcodec", - "libwebp", - "-vf", - "scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse" + "-vcodec", "libwebp", + "-vf", "scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse" ], 'jpg', 'webp') } @@ -161,14 +159,15 @@ } return ffmpeg(file, [ "-vcodec", "libwebp", - "-vf", "scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse", + "-vf", "scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=30, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse", "-lossless", "1", "-compression_level", "6", "-loop", "0", + "-ss", "00:00:00", + "-t", "00:00:10", "-preset", "default", "-an", - "-vsync", - "0" + "-vsync", "0" ], 'webp', 'webp') } @@ -180,21 +179,14 @@ file = buffer } return ffmpeg(file, [ - "-vcodec", - "libwebp", - "-vf", - "scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse", - "-loop", - "0", - "-ss", - "00:00:00", - "-t", - "00:00:10", - "-preset", - "default", + "-vcodec", "libwebp", + "-vf", "scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=30, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse", + "-loop", "0", + "-ss", "00:00:00", + "-t", "00:00:10", + "-preset", "default", "-an", - "-vsync", - "0" + "-vsync", "0" ], 'mp4', 'webp') } @@ -211,7 +203,7 @@ file = buffer } return ffmpeg(file, [ - '-ss', '00:00:00', + '-ss', '00:01:00', '-vf', 'scale=32:-1', '-vframes', '1', '-f', 'image2', diff --git a/library/exif.js b/library/exif.js index 02985ce..cee1ad3 100644 --- a/library/exif.js +++ b/library/exif.js @@ -10,6 +10,7 @@ const webp = require("node-webpmux") const path = require("path"); const { imageToWebp, videoToWebp, WebpToWebp } = require('./converter'); + const { webp2mp4File } = require('./upload'); async function writeExifImg (media, metadata) { let wMedia = await imageToWebp(media) @@ -67,8 +68,11 @@ try { await img.load(media) } catch (err) { - let media = videoToWebp(file) - await img.load(media) + fs.writeFileSync(tmpFileOut, file) + let {result} = await webp2mp4File(tmpFileOut) + fs.unlinkSync(tmpFileOut) + let buff = await WebpToWebp(result) + await img.load(buff) } img.exif = exif await img.save(tmpFileOut) diff --git a/library/lib.js b/library/lib.js index 019bb2f..b590466 100644 --- a/library/lib.js +++ b/library/lib.js @@ -16,6 +16,7 @@ const { getContentType, BufferJSON, initAuthCreds, + extractImageThumb, } = require("@adiwajshing/baileys"); const Path = require("path"); const axios = require("axios").default; @@ -30,9 +31,7 @@ const util = require("util"); const FileType = require("file-type"); const { writeExifVid, writeExif } = require("./exif"); const { - imageToWebp, videoToWebp, - ffmpeg, videoToThumb, imageToThumb, } = require("./converter"); @@ -394,11 +393,10 @@ const anubisFunc = (conn, store) => { return await this.sendMessage(jid, listMessage, { quoted, ...options }); }, - /** Send Button 5 Message + /** Send Button 3 Message * * @param {*} jid * @param {*} text - * @param {*} footer * @param {*} button * @returns */ @@ -417,11 +415,10 @@ const anubisFunc = (conn, store) => { return await this.sendMessage(jid, buttonMessage, { quoted, ...options }); }, - /** Send Button 5 Image + /** Send Button 3 Image * * @param {*} jid * @param {*} text - * @param {*} footer * @param {*} image * @param [*] button * @param {*} options @@ -430,89 +427,108 @@ const anubisFunc = (conn, store) => { async sendButtonImg( jid, text = "", - img, + path, buttons = [], quoted = "", options = {} ) { + let buffer = Buffer.isBuffer(path) + ? path + : /^data:.*?\/.*?;base64,/i.test(path) + ? Buffer.from(path.split`,`[1], "base64") + : /^https?:\/\//.test(path) + ? await await getBuffer(path) + : fs.existsSync(path) + ? fs.readFileSync(path) + : Buffer.alloc(0); return await this.sendMessage( jid, - { image: img, caption: text, footer: anuFooter, buttons }, + { image: buffer, caption: text, footer: anuFooter, buttons }, { quoted, ...options } ); }, - /** Send Button 5 Location + /** Send Button 3 Video * * @param {*} jid * @param {*} text - * @param {*} footer - * @param {*} location + * @param {*} Video * @param [*] button * @param {*} options + * @returns */ - async sendButtonLoc( + async sendButtonVid( jid, text = "", - footer = "", - lok, - but = [], + path, + buttons = [], quoted = "", + thumb, options = {} ) { - let bb = await this.genThumb(lok); - let jpegThumbnail = bb.status ? bb.thumbnail : ""; + let buffer = Buffer.isBuffer(path) + ? path + : /^data:.*?\/.*?;base64,/i.test(path) + ? Buffer.from(path.split`,`[1], "base64") + : /^https?:\/\//.test(path) + ? await await getBuffer(path) + : fs.existsSync(path) + ? fs.readFileSync(path) + : Buffer.alloc(0); + let jpegThumbnail; + if (isUrl(thumb)) { + jpegThumbnail = (await extractImageThumb(thumb)).buffer; + } else { + let bb = await this.genThumb(buffer); + jpegThumbnail = bb.status ? bb.thumbnail : ""; + } return await this.sendMessage( jid, { - location: { jpegThumbnail }, + video: buffer, caption: text, + jpegThumbnail, footer: anuFooter, - templateButtons: but, + buttons, }, { quoted, ...options } ); }, - /** Send Button 5 Video + /** Send Button 3 Location * * @param {*} jid * @param {*} text - * @param {*} footer - * @param {*} Video + * @param {*} location * @param [*] button * @param {*} options - * @returns */ - async sendButtonVid( + async sendButtonLoc( jid, text = "", - footer = "", - vid, - but = [], + lok, + buttons = [], quoted = "", options = {} ) { - let bb = await this.genThumb(vid); + let bb = await this.genThumb(lok); let jpegThumbnail = bb.status ? bb.thumbnail : ""; return await this.sendMessage( jid, { - video: vid, + location: { jpegThumbnail }, caption: text, - jpegThumbnail, footer: anuFooter, - templateButtons: but, + buttons, }, { quoted, ...options } ); }, - /** Send Button 5 Gif + /** Send Button 3 Gif * * @param {*} jid * @param {*} text - * @param {*} footer * @param {*} Gif * @param [*] button * @param {*} options @@ -521,7 +537,6 @@ const anubisFunc = (conn, store) => { async sendButtonGif( jid, text = "", - footer = "", gif, but = [], quoted = "", @@ -551,7 +566,6 @@ const anubisFunc = (conn, store) => { * @param {*} jid * @param {*} buttons * @param {*} caption - * @param {*} footer * @param {*} quoted * @param {*} options */ @@ -574,10 +588,10 @@ const anubisFunc = (conn, store) => { * @param {*} options * @returns */ - async sendText(jid, text, quoted = "", options) { + async sendText(jid, text = "", quoted = "", options) { return await this.sendMessage( jid, - { text: text, ...options }, + { text, ...options }, { quoted, ...options } ); }, @@ -622,6 +636,7 @@ const anubisFunc = (conn, store) => { path, caption = "", quoted = "", + thumb, gif = false, options ) { @@ -634,8 +649,13 @@ const anubisFunc = (conn, store) => { : fs.existsSync(path) ? fs.readFileSync(path) : Buffer.alloc(0); - let bb = await this.genThumb(buffer); - let jpegThumbnail = bb.status ? bb.thumbnail : ""; + let jpegThumbnail; + if (isUrl(thumb)) { + jpegThumbnail = (await extractImageThumb(thumb)).buffer; + } else { + let bb = await this.genThumb(buffer); + jpegThumbnail = bb.status ? bb.thumbnail : ""; + } return await this.sendMessage( jid, { @@ -720,7 +740,10 @@ const anubisFunc = (conn, store) => { if (options && (options.packname || options.author)) { buffer = await writeExif(buff, options); } else { - buffer = await imageToWebp(buff); + buffer = await writeExif(buff, { + packname: global.packname, + author: global.author, + }); } await this.sendMessage( jid, @@ -729,6 +752,7 @@ const anubisFunc = (conn, store) => { ); return buffer; } catch (err) { + console.log("error ngab!"); console.err(err); } }, @@ -826,47 +850,82 @@ const anubisFunc = (conn, store) => { async sendMedia( jid, path, - fileName = "", + fileName, caption = "", quoted = "", options = {} ) { - let types = await this.getFile(path, true); - let { mime, ext, res, data, filename } = types; - if (res && res.status !== 200) { + let a = {}, + types = {}, + txt; + if (isUrl(path)) { + const url = new URL(path); + const res = await axios({ + url: url.href, + method: "GET", + responseType: "arraybuffer", + }); + path = res.data; + types = /text|json/.test(res.headers["content-type"]) + ? { ext: "txt" } + : /application/.test(res.headers["content-type"]) + ? { mime: "application" } + : await FileType.fromBuffer(path); + } else { + path = Buffer.isBuffer(path) + ? path + : /^data:.*?\/.*?;base64,/i.test(path) + ? Buffer.from(path.split`,`[1], "base64") + : isUrl(path) + ? await await getBuffer(path) + : fs.existsSync(path) + ? fs.readFileSync(path) + : Buffer.alloc(0); + types = await FileType.fromBuffer(path); + } + if (/txt/.test(types.ext)) { try { - throw { json: JSON.parse(file.toString()) }; + path = util.format(JSON.parse(path + "")); } catch (e) { - if (e.json) throw e.json; + path = path + ""; + } finally { + a = await this.sendText( + jid, + path.slice(0, 65536) + "", + quoted, + options + ); + } + } else { + if (!fileName) fileName = getRandom("." + types.ext); + console.log(types); + if (/(png|jpg|webp)/.test(types.ext)) { + a = await this.sendImage(jid, path, caption, quoted); + } else if (/mp4/.test(types.ext)) { + a = await this.sendMessage( + jid, + { video: path, fileName, caption }, + { quoted } + ); + } else if (/mp3/.test(types.ext)) { + a = await this.sendText(jid, caption, quoted, options); + if (a.status) a = await this.sendAudio(jid, path, quoted); + } else if (/gif/.test(types.ext)) { + a = await this.sendMessage( + jid, + { video: path, fileName, caption, gifPlayback: true }, + { quoted } + ); + } else if (/application/.test(types.mime)) { + a = await this.sendMessage( + jid, + { document: path, mimetype: types.mime, fileName, caption }, + { quoted } + ); } } - let type = "", - mimetype = mime, - pathFile = filename; - if (options.asDocument) type = "document"; - if (options.asSticker || /webp/.test(mime)) { - let { writeExif } = require("./lib/exif"); - let media = { mimetype: mime, data }; - pathFile = await writeExif(media, { - packname: options.packname ? options.packname : global.packname, - author: options.author ? options.author : global.author, - categories: options.categories ? options.categories : [], - }); - await fs.promises.unlink(filename); - type = "sticker"; - mimetype = "image/webp"; - } else if (/image/.test(mime)) type = "image"; - else if (/video/.test(mime)) type = "video"; - else if (/audio/.test(mime)) type = "audio"; - else type = "document"; - let a = await this.sendMessage( - jid, - { [type]: { url: pathFile }, caption, mimetype, fileName, ...options }, - { quoted, ...options } - ); return { ...a, - pathFile: fs.promises.unlink(pathFile), }; }, @@ -1083,7 +1142,8 @@ const jsonFileAuth = async (database, name = null) => { }; if (typeof database == "object") { - if (name == null) throw new Error("parameter name can't be null"); + if (name == null) + throw console.error("[ERROR] : parameter name can't be null"); if ( typeof database[name] == "object" && typeof database[name].creds == "object" @@ -1421,14 +1481,25 @@ const smsg = (conn, m, store) => { */ m.reply = async (text, chatId = m.chat, options = {}) => Buffer.isBuffer(text) - ? await conn.sendMedia(chatId, text, "file", "", m, { ...options }) - : await conn.sendText(chatId, text, m, { ...options }); + ? await conn.sendMedia(chatId, String(text), "file", "", m, { + ...options, + }) + : await conn.sendText(chatId, String(text), m, { ...options }); /** * Copy this message */ m.copy = () => smsg(conn, M.fromObject(M.toObject(m))); + m.gcParUp = (user, action) => { + const isAct = /(add|remove|demote|promote)/.test(action) ? action : false; + if (isAct) { + if (!m.isGroup) return m.reply("Harus di Group ngab!"); + user = typeof user == "string" ? user.split(",") : user; + conn.groupParticipantsUpdate(m.chat, user, isAct); + } + }; + m.err = console.err = (err, fun = false) => { conn.sendMessage(m.anubis, { text: `[ LAPORAN ERROR ]\n*cmd/func* : ${ @@ -1440,18 +1511,7 @@ const smsg = (conn, m, store) => { console.log(err); }; - m.gcParUp = (user, action) => { - const isAct = /(add|remove|demote|promote)/.test(action) ? action : false; - if (isAct) { - try { - if (!m.isGroup) return m.reply("Harus di Group ngab!"); - user = typeof user == "string" ? user.split(",") : user; - conn.groupParticipantsUpdate(m.chat, user, isAct); - } catch (err) { - console.err(err); - } - } - }; + m.delete = async (key) => await conn.sendMessage(m.sender, { delete: key }); /** * @@ -1516,7 +1576,7 @@ function msToTime(s) { var mins = s % 60; var hrs = (s - mins) / 60; - return hrs + ":" + mins + ":" + secs + "." + ms; + return hrs + ":" + mins + ":" + secs; } /** @@ -1603,108 +1663,120 @@ const getRandom = (ext = "") => { */ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); +/** + * + * @param {axiosConfig} options + * @returns + */ +function anureq(options) { + return new Promise((resolve, reject) => { + axios({ ...options }) + .then(({ data }) => resolve(data)) + .catch((e) => { + console.err(e, "anureq error"); + }); + }); +} + /** * * @param {number} id * @returns */ -const igjson = (id) => { +function igjson(id) { return new Promise((resolve, reject) => { let hasil = []; let user = {}; let post = {}; let media = []; - let promoses = []; - promoses.push( - axios - .get(`https://i.instagram.com/api/v1/media/${id}/info/`, { - headers: { - "User-Agent": - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36", - cookie: anuCookie.ig, - "x-ig-app-id": 936619743392459, - "x-ig-www-claim": 0, - "x-asbd-id": 198387, - Accept: "*/*", - }, - }) - .then(({ data }) => { - let j = data.items[0]; - if (j.carousel_media) { - for (var i = 0; i < j.carousel_media.length; i++) { - let jj = j.carousel_media[i]; - if (jj.video_versions) { - media.push({ - url: jj.video_versions[0].url, - type: "mp4", - }); - } else { - media.push({ - url: jj.image_versions2.candidates[0].url, - type: "jpg", - }); - } + anureq({ + url: `https://i.instagram.com/api/v1/media/${id}/info/`, + headers: { + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", + cookie: anuCookie.ig, + "x-ig-app-id": 936619743392459, + "x-csrftoken": /csrftoken=([a-zA-Z0-9]*)\;/.exec(anuCookie.ig)[1], + referer: "https://www.instagram.com/atrisna477769", + }, + method: "GET", + }) + .then((data) => { + let j = data.items[0]; + if (j.carousel_media) { + for (var i = 0; i < j.carousel_media.length; i++) { + let jj = j.carousel_media[i]; + if (jj.video_versions) { + media.push({ + url: jj.video_versions[0].url, + thumb: jj.image_versions2.candidates[0].url, + type: "mp4", + }); + } else { + media.push({ + url: jj.image_versions2.candidates[0].url, + type: "jpg", + }); } - } else if (j.video_versions) { - media.push({ - url: j.video_versions[0].url, - type: "mp4", - }); - } else { - media.push({ - url: j.image_versions2.candidates[0].url, - type: "jpg", - }); - } - let cap; - if (j.caption == null) { - cap = ""; - } else { - cap = j.caption.text; } - user = { - username: j.user.username, - full_name: j.user.full_name, - is_private: j.user.is_private, - is_verified: j.user.is_verified, - profile_pic_url: j.user.profile_pic_url, - id: j.user.pk, - }; + } else if (j.video_versions) { + media.push({ + url: j.video_versions[0].url, + thumb: j.image_versions2.candidates[0].url, + type: "mp4", + }); + } else { + media.push({ + url: j.image_versions2.candidates[0].url, + type: "jpg", + }); + } + let cap; + if (j.caption == null) { + cap = ""; + } else { + cap = j.caption.text; + } + user = { + username: j.user.username, + full_name: j.user.full_name, + is_private: j.user.is_private, + is_verified: j.user.is_verified, + profile_pic_url: j.user.profile_pic_url, + id: j.user.pk, + }; - if (j.taken_at) { - post = { - title: j.title, - caption: cap, - taken_at: j.taken_at, - comment_count: j.comment_count, - like_count: j.like_count, - video_duration: j.video_duration, - view_count: j.view_count, - play_count: j.play_count, - has_audio: j.has_audio, - }; - } + if (j.taken_at) { + post = { + title: j.title, + caption: cap, + taken_at: j.taken_at, + comment_count: j.comment_count, + like_count: j.like_count, + video_duration: j.video_duration, + view_count: j.view_count, + play_count: j.play_count, + has_audio: j.has_audio, + }; + } - hasil.push({ - user: user, - post: post, - media: media, - }); + hasil.push({ + user: user, + post: post, + media: media, + }); - Promise.all(promoses).then(() => - resolve({ - creator: "anubis-bot", - status: true, - data: hasil, - }) - ); - }) - .catch((err) => { - console.err(err, "igjson"); - }) - ); + resolve({ + creator: "anubis-bot", + status: true, + data: hasil, + }); + }) + .catch((err) => { + console.err(err, "igjson"); + }); }); -}; +} /** * @@ -1713,23 +1785,25 @@ const igjson = (id) => { */ const iggetid = (shortcode) => { return new Promise(async (resolve, reject) => { - const igid = await axios({ + anureq({ url: `https://www.instagram.com/graphql/query/?query_hash=d4e8ae69cb68f66329dcebe82fb69f6d&variables={"shortcode":"${shortcode}"}`, headers: { "User-Agent": - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", cookie: anuCookie.ig, + "x-ig-app-id": 936619743392459, + "x-csrftoken": /csrftoken=([a-zA-Z0-9]*)\;/.exec(anuCookie.ig)[1], + referer: "https://www.instagram.com/atrisna477769", }, - data: null, method: "GET", - }).catch((err) => { - console.err(err, "iggetid"); - }); - try { - resolve({ status: true, id: igid.data.data.shortcode_media.id }); - } catch (e) { - resolve({ status: false }); - } + }) + .then((data) => { + resolve({ status: true, id: data.data.shortcode_media.id }); + }) + .catch((err) => { + console.err(err, "iggetid failed get id"); + resolve({ status: false }); + }); }); }; @@ -1749,20 +1823,19 @@ const igstory = (urlnya) => { let anubis = {}; let user = {}; if (regx[2] == "highlights") { - axios({ + anureq({ url: `https://i.instagram.com/api/v1/feed/reels_media/?reel_ids=highlight:${regx[3]}`, headers: { "User-Agent": - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", cookie: anuCookie.ig, "x-ig-app-id": 936619743392459, - "x-ig-www-claim": 0, - "x-asbd-id": 198387, - Accept: "*/*", + "x-csrftoken": /csrftoken=([a-zA-Z0-9]*)\;/.exec(anuCookie.ig)[1], + referer: "https://www.instagram.com/atrisna477769", }, method: "GET", }) - .then(({ data }) => { + .then((data) => { let j = data.reels_media[0]; for (var i = 0; i < j.items.length; i++) { let jj = j.items[i]; @@ -1776,6 +1849,7 @@ const igstory = (urlnya) => { media.push({ id: jj.id, url: jj.video_versions[0].url, + thumb: jj.image_versions2.candidates[0].url, type: "mp4", caption: cap, taken_at: jj.taken_at, @@ -1985,6 +2059,77 @@ function pinterest(querry) { }); } +/** + * + * @param {String} query + * @returns + */ +function pinterest2(query) { + return new Promise((resolve, reject) => { + anureq({ + url: `https://id.pinterest.com/resource/BaseSearchResource/get/?source_url=/search/pins/?q=${encodeURIComponent( + query + )}&rs=typed&data={"options":{"article":null,"applied_filters":null,"appliedProductFilters":"---","auto_correction_disabled":false,"corpus":null,"customized_rerank_type":null,"filters":null,"query":"${query}","query_pin_sigs":null,"redux_normalize_feed":true,"rs":"typed","scope":"pins","source_id":null,"no_fetch_context_on_resource":false},"context":{}}&_=1665811633913`, + headers: { + "X-Requested-With": "XMLHttpRequest", + Accept: "application/json, text/javascript, */*, q=0.01", + "X-Pinterest-Source-Url": `/search/pins/?q=${encodeURIComponent( + query + )}&rs=typed`, + "X-Pinterest-PWS-Handler": "www/index.js", + cookie: + global.anuCookie.pinterest, + }, + method: "GET", + }) + .then((data) => { + let res = []; + for (let img of data.resource_response.data.results) { + if (!img.images) continue; + if (!img.images.orig) continue; + let owner = {}; + let id = img.id; + let type = img.type; + let title = img.title; + let image = img.images.orig; + let desc = img.description; + let alt = img.alt_text; + let video = + img.videos == null + ? null + : img.videos.video_list.V_EXP7 + ? img.videos.video_list.V_EXP7 + : null; + let img_sign = img.image_signature; + let created = img.created_at.split("+")[0]; + owner.profile = img.pinner.image_large_url; + owner.id = img.pinner.id; + owner.username = img.pinner.username; + owner.full_name = img.pinner.full_name; + owner.follower = img.pinner.follower_count; + res.push({ + id, + type, + title, + image, + desc, + alt, + video, + img_sign, + created, + owner, + }); + } + arrayMix(res); + resolve({ status: true, anubis: res }); + }) + .catch((err) => { + console.err(err, "pinterest"); + resolve({ status: false }); + }); + }); +} + /** * * @param {uri} url @@ -2313,7 +2458,7 @@ function y2mateConvert(id, ytid, type, quality) { return resolve({ a }); } const $ = cheerio.load(data.result); - const url = $("div > a").attr("href"); + const url = $("a").attr("href"); resolve({ url }); }) .catch((err) => console.err(err, "y2mateConverter")); @@ -2433,6 +2578,7 @@ function jooxSearch(query) { artis_list += track.artist_list[j].name; artis_list += ", "; } + if (typeof track.images[1] === "undefined") continue; if (track.is_playable) { let duration = durasiConverter(track.play_duration); tracks.push({ @@ -2586,15 +2732,86 @@ function soundcloud(query) { }); } +function slBitly(url) { + return new Promise((resolve, reject) => { + anureq({ + url: `https://bitly.com/data/anon_shorten`, + headers: { + "x-requested-with": "XMLHttpRequest", + "content-type": "application/x-www-form-urlencoded; charset=UTF-8", + "x-xsrftoken": "9f377bfe66074af3830a5328d3ff5108", + cookie: + "_xsrf=9f377bfe66074af3830a5328d3ff5108; anon_u=cHN1X18zZjNjMGRjZC04MWE1LTRhZjMtODdjNi1kNTA0MzBhYWRhNjc=|1665818550|8d3b7544ca7629f38edff458f52116a270bfbd3f; cookie_banner=1; wow-modal-id-12=yes", + }, + data: `url=${encodeURIComponent(url)}`, + method: "POST", + }) + .then((data) => { + if (data.status_code !== 200) return resolve({ status: false }); + resolve({ status: true, url: data.data.link }); + }) + .catch((e) => { + resolve({ status: false }); + }); + }); +} + +function slTiny(url) { + return new Promise((resolve, reject) => { + anureq({ + url: `https://tinyurl.com/api-create.php?url=${encodeURIComponent(url)}`, + headers: { + "content-type": "application/x-www-form-urlencoded; charset=UTF-8", + }, + method: "GET", + }) + .then((data) => { + if (!isUrl(data)) return resolve({ status: false }); + resolve({ status: true, url: data }); + }) + .catch((e) => { + resolve({ status: false }); + }); + }); +} + /** * * @param {uri} url */ async function shortlink(url) { - let res = await axios - .get("https://tinyurl.com/api-create.php?url=" + url) - .catch((err) => console.err(err, "shortlink")); - return res.data; + return new Promise((resolve, reject) => { + slBitly(url) + .then((anu) => { + if (anu.status) return resolve(anu.url); + }) + .catch((e) => { + return slTiny(url); + }) + .then((anu) => { + if (anu.status) return resolve(anu.url); + }) + .catch((e) => {}); + }); +} + +const isNum = (x) => typeof x === "number" && !isNaN(x); + +function arrayMix(array) { + let currentIndex = array.length, + randomIndex; + + while (currentIndex != 0) { + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex--; + + [array[currentIndex], array[randomIndex]] = [ + array[randomIndex], + array[currentIndex], + ]; + } + + return array; } module.exports = { @@ -2624,6 +2841,7 @@ module.exports = { urlDirect2, isJson, pinterest, + pinterest2, hagodl, subFinder, ytUrlRegex, @@ -2636,4 +2854,7 @@ module.exports = { jooxLyric, soundcloud, shortlink, + isNum, + anureq, + arrayMix, }; diff --git a/library/upload.js b/library/upload.js index e9864a0..c3321b6 100644 --- a/library/upload.js +++ b/library/upload.js @@ -1,112 +1,112 @@ - /** - * anubisbot-MD https://github.com/anubiskun/anubisbot-MD - * - * Copyright (c) 2022 anubiskun - * https://github.com/anubiskun - */ +/** + * anubisbot-MD https://github.com/anubiskun/anubisbot-MD + * + * Copyright (c) 2022 anubiskun + * https://github.com/anubiskun + */ - const axios = require('axios') - const BodyForm = require('form-data') - const fs = require('fs') - let cheerio = require('cheerio') - - /** - * - * @param {path} Path - * @returns - */ - function telegraphUp (Path) { - return new Promise (async (resolve, reject) => { - if (!fs.existsSync(Path)) return reject(new Error("File not Found")) - try { - const form = new BodyForm(); - form.append("file", fs.createReadStream(Path)) - const data = await axios({ - url: "https://telegra.ph/upload", - method: "POST", - headers: { - ...form.getHeaders() - }, - data: form - }).catch(err => console.err(err, 'telegraphUp')) - // return resolve(data) - return resolve("https://telegra.ph" + data.data[0].src) - } catch (err) { - return reject(new Error(String(err))) +const axios = require('axios') +const BodyForm = require('form-data') +const fs = require('fs') +let cheerio = require('cheerio') + +/** + * + * @param {path} Path + * @returns + */ +function telegraphUp (Path) { + return new Promise (async (resolve, reject) => { + if (!fs.existsSync(Path)) return reject(new Error("File not Found")) + try { + const form = new BodyForm(); + form.append("file", fs.createReadStream(Path)) + const data = await axios({ + url: "https://telegra.ph/upload", + method: "POST", + headers: { + ...form.getHeaders() + }, + data: form + }).catch(err => console.err(err, 'telegraphUp')) + // return resolve(data) + return resolve("https://telegra.ph" + data.data[0].src) + } catch (err) { + return reject(new Error(String(err))) + } + }) +} + +/** + * + * @param {path} path + * @returns + */ +function webp2mp4File(path) { + return new Promise((resolve, reject) => { + const form = new BodyForm() + form.append('new-image-url', '') + form.append('new-image', fs.createReadStream(path)) + axios({ + method: 'post', + url: 'https://s6.ezgif.com/webp-to-mp4', + data: form, + headers: { + 'Content-Type': `multipart/form-data; boundary=${form._boundary}` } - }) - } - - /** - * - * @param {path} path - * @returns - */ - function webp2mp4File(path) { - return new Promise((resolve, reject) => { - const form = new BodyForm() - form.append('new-image-url', '') - form.append('new-image', fs.createReadStream(path)) + }).then(({ data }) => { + const bodyFormThen = new BodyForm() + const $ = cheerio.load(data) + const file = $('input[name="file"]').attr('value') + bodyFormThen.append('file', file) + bodyFormThen.append('convert', "Convert WebP to MP4!") axios({ - method: 'post', - url: 'https://s6.ezgif.com/webp-to-mp4', - data: form, - headers: { - 'Content-Type': `multipart/form-data; boundary=${form._boundary}` - } + method: 'post', + url: 'https://ezgif.com/webp-to-mp4/' + file, + data: bodyFormThen, + headers: { + 'Content-Type': `multipart/form-data; boundary=${bodyFormThen._boundary}` + } }).then(({ data }) => { - const bodyFormThen = new BodyForm() - const $ = cheerio.load(data) - const file = $('input[name="file"]').attr('value') - bodyFormThen.append('file', file) - bodyFormThen.append('convert', "Convert WebP to MP4!") - axios({ - method: 'post', - url: 'https://ezgif.com/webp-to-mp4/' + file, - data: bodyFormThen, - headers: { - 'Content-Type': `multipart/form-data; boundary=${bodyFormThen._boundary}` - } - }).then(({ data }) => { - const $ = cheerio.load(data) - const result = 'https:' + $('div#output > p.outfile > video > source').attr('src') - resolve({ - status: true, - message: "Created By anubiskun", - result: result - }) - }).catch(err => console.err(err, 'webp2mp4File')) + const $ = cheerio.load(data) + const result = 'https:' + $('div#output > p.outfile > video > source').attr('src') + resolve({ + status: true, + message: "Created By anubiskun", + result: result + }) }).catch(err => console.err(err, 'webp2mp4File')) - }) - } - - /** - * - * @param {path} input - * @returns - */ - async function tmpfiles (input) { - return new Promise (async (resolve, reject) => { - const form = new BodyForm(); - form.append("file", fs.createReadStream(input)) - await axios({ - url: "https://tmpfiles.org/api/v1/upload", - method: "POST", - headers: { - ...form.getHeaders() - }, - data: form - - }).then(({data}) => { - // console.log(data) - let ew = /https?:\/\/tmpfiles.org\/(.*)/.exec(data.data.url) - resolve('https://tmpfiles.org/dl/' + ew[1]) - }).catch(err => console.err(err, 'tmpfiles')) - }) - } - - module.exports = { - telegraphUp, - tmpfiles, - webp2mp4File, - } \ No newline at end of file + }).catch(err => console.err(err, 'webp2mp4File')) + }) +} + +/** + * + * @param {path} input + * @returns + */ +async function tmpfiles (input) { + return new Promise (async (resolve, reject) => { + const form = new BodyForm(); + form.append("file", fs.createReadStream(input)) + await axios({ + url: "https://tmpfiles.org/api/v1/upload", + method: "POST", + headers: { + ...form.getHeaders() + }, + data: form + + }).then(({data}) => { + // console.log(data) + let ew = /https?:\/\/tmpfiles.org\/(.*)/.exec(data.data.url) + resolve('https://tmpfiles.org/dl/' + ew[1]) + }).catch(err => console.err(err, 'tmpfiles')) + }) +} + +module.exports = { +telegraphUp, +tmpfiles, +webp2mp4File, +} \ No newline at end of file diff --git a/package.json b/package.json index cb7c25f..053f7a2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "anubisbot-md", - "version": "2.1.4-core-2.4", - "versionCode": 2142022101524, + "version": "2.2.0-core-2.5", + "versionCode": 2202022101925, "description": "anubisbot-md coded by anubiskun", "depecrated": false, "main": "index.js", @@ -13,7 +13,20 @@ }, "scripts": { "start": "node index.js --server", - "test": "node index.js --test" + "test": "nodemon -- --name anubisTest --test" + }, + "nodemonConfig": { + "ignore": [ + "*/*.json", + "*/*.png", + "*/*.jpg", + "*/*.mp4", + "*/*.mp3", + "*/plugins/*", + "*/node_modules/*", + "*/.git/*", + "*/temp/*" + ] }, "repository": { "type": "git", @@ -36,9 +49,9 @@ "bugs": { "url": "https://github.com/anubiskun/anubisbot-MD/issues" }, - "homepage": "https://github.com/anubiskun/anubisbot-MD", + "homepage": "https://github.com/anubiskun/anubisbot-MD#readme", "dependencies": { - "@adiwajshing/baileys": "github:adiwajshing/baileys", + "@adiwajshing/baileys": "git@github.com:anubiskun/Baileys.git", "@adiwajshing/keyed-db": "^0.2.4", "@ffmpeg-installer/ffmpeg": "^1.1.0", "@hapi/boom": "^10.0.0", @@ -54,7 +67,7 @@ "follow-redirect-url": "^2.0.1", "form-data": "^4.0.0", "google-it": "^1.6.3", - "googlethis": "^1.4.1", + "googlethis": "^1.4.3", "got": "^12.5.1", "human-readable": "^0.2.1", "is-url": "^1.2.4", @@ -76,7 +89,11 @@ "yargs": "^17.5.1", "youtube-search-api": "^1.1.0" }, + "devDependencies": { + "nodemon": "^2.0.20" + }, "changeLogs": [ + "[ V 2.2.0-core-2.5 ]\n- Update core v2.5\n- Fix Many Bugs\n- Added AntiLink Private and Group Chats\n- Added Antilink Filter Domain\n- Added AntiViewOnce Group Chats\n- Added antilinkadd & antilinkdel & antilinklist command for add domain lists (group)\n- Added setting command (group)\n- Added Premium time\n- Reset Limit every 00:00 AM UTC + 07:00 Jakarta\n- Fix Instagram new Method\n- New Pinterest Search\n- Fix Shortlink", "[ V 2.1.4-core-2.4 ]\n- Added Group Update (https://github.com/irham01)\n Added Limit Premium Free fiture", "[ V 2.1.2-core-2.4 ]\n- Update core v2.4\n- System Send Notif if Error\n- Error Catch\n- Fix SoundCloud search\n- Fix Tiktok Downloader\n- Fix Google Search\n- Added Welcomer in group\n- Added Anti link", "[ V 2.1.0-core-2.3 ]\n- Update core v2.3\n- Added Command Corections\n- Added notification updates\n- Fix command removebg", diff --git a/plugins/__antiSipalingAnti.js b/plugins/__antiSipalingAnti.js new file mode 100644 index 0000000..149cc31 --- /dev/null +++ b/plugins/__antiSipalingAnti.js @@ -0,0 +1,88 @@ +/** + * anubisbot-MD https://github.com/anubiskun/anubisbot-MD + * + * Copyright (c) 2022 anubiskun + * https://github.com/anubiskun + */ + +module.exports = anuplug = { + async before(m, anubis, { store, botNumber, isAdmin, isBotAdmin }) { + if (m.isBaileys || m.fromMe || m.isAnubis || !m.isGroup || m.isOwner) + return true; + if (!isBotAdmin) return global.dfail("isBotAdmin", m, anubis); + const user = anubis.db.data.users[m.sender]; + const chat = anubis.db.data.chats[m.chat]; + const database = anubis.db.data.database; + const setting = anubis.db.data.settings[botNumber]; + let dbregx = database.banUrl.map( + (v) => + new RegExp( + `(?:(?:https?|ftp)\:(?:[A-Za-z0-9\/]+)?\.?)?${v}(?:[A-Za-z0-9\/\-?=%.]+)?`, + "g" + ) + ); + let gcregx = chat.banUrl.map( + (v) => + new RegExp( + `(?:(?:https?|ftp)\:(?:[A-Za-z0-9\/]+)?\.?)?${v}(?:[A-Za-z0-9\/\-?=%.]+)?`, + "g" + ) + ); + let regx = [...dbregx, ...gcregx]; + let isLink = false; + let link = new RegExp(); + for (link of regx) { + if (!link) break; + if (!chat.antilink) break; + isLink = link.test(m.text); + if (isLink) break; + } + if (isLink && chat.antilink) { + user.warn = user.warn + 1; + const pes = `[ Antilink ]\n\nPesan mengandung link!\nHai, @${ + m.sender.split("@")[0] + } warning bertambah 1, max 3 warning\nJika Melebihi 3 maka akan di keluarkan dari group *${await anubis.getName( + m.chat, + true + )}*\nTotal Warning anda : ${user.warn}`; + const pWarn = await anubis.sendMessage( + m.chat, + { text: pes, mentions: [m.sender] }, + { quoted: m } + ); + if (pWarn.status && user.warn > 3) { + let a = await anubis.sendImage( + m.chat, + "https://i.pinimg.com/736x/c5/32/aa/c532aafc70f9b4e586e38bb7e0c71c7b.jpg", + "hayoo mau keluar di dalem atau di luar?", + m + ); + if (a.status) { + setTimeout(() => { + if (isAdmin) { + anubis.sendImage( + m.chat, + "https://64.media.tumblr.com/9fd00065505abbfcf5e54da7c195ea95/6e338d93859f114e-11/s640x960/824694309443f685756f445bc87ebab7f52331d8.png", + "Eee? gome onii-chan! ๐Ÿคข", + m + ); + user.warn = 0; + } else { + m.gcParUp(m.sender, "remove"); + } + }, 3000); + } + } + } + if (chat.antiviewonce && !isAdmin) { + if (m.mtype == "viewOnceMessage") { + await anubis.copyNForward( + m.chat, + await store.loadMessage(m.chat, m.id), + false, + { quoted: m, readViewOnce: true } + ); + } + } + }, +}; diff --git a/plugins/_antilink.js b/plugins/_antilink.js deleted file mode 100644 index 6ee5322..0000000 --- a/plugins/_antilink.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * anubisbot-MD https://github.com/anubiskun/anubisbot-MD - * - * Copyright (c) 2022 anubiskun - * https://github.com/anubiskun - */ -let regGc = /chat.whatsapp.com\/(?:invite\/)?([0-9A-Za-z]{20,24})/i -module.exports = anuplug = { - async before(m, anubis, { botNumber, isAdmin, isBotAdmin }) { - if (m.isBaileys || m.fromMe || m.isAnubis || !m.isGroup || isAdmin) return true - if (!isBotAdmin) return dfail('isBotAdmin', m) - const user = anubis.db.data.users[m.sender] - const setting = anubis.db.data.settings[botNumber] - if (regGc.test(m.text) && setting.antilink) { - user.warn = user.warn + 1 - const pes = `[ Antilink ]\n\nPesan mengandung link!\nHai, @${m.sender.split('@')[0]} warning bertambah 1, max 3 warning\nJika Melebihi 3 maka akan di keluarkan dari group *${await anubis.getName(m.chat, true)}*\nTotal Warning anda : ${user.warn}`; - const pWarn = await anubis.sendMessage(m.chat, {text: pes, mentions: [m.sender]}, {quoted: m}) - if (pWarn.status && user.warn > 3) { - m.reply('hayoo mau keluar sendiri atau di keluarin?') - setTimeout(() => { - m.gcParUp(m.sender, 'remove') - user.isBanned = true - }, 5000) - } - } - } -} \ No newline at end of file diff --git a/plugins/_cmdCorection.js b/plugins/_cmdCorection.js index 8fd9400..8b54673 100644 --- a/plugins/_cmdCorection.js +++ b/plugins/_cmdCorection.js @@ -1,87 +1,178 @@ /** * anubisbot-MD https://github.com/anubiskun/anubisbot-MD - * + * * Copyright (c) 2022 anubiskun * https://github.com/anubiskun */ - module.exports = anuplug = { - async before(m, anubis, { text, command, args, prefix, pushname, ucapan }) { - try { - let user = anubis.db.data.users[m.sender] - let buttons = [ { buttonId: `/owner`, buttonText: { displayText: "Contact Owner" }, type: 1 }, { buttonId: `/changelogs`, buttonText: { displayText: "Change Logs" }, type: 1 }, { buttonId: `/menu`, buttonText: { displayText: "Menu" }, type: 1 } ] +module.exports = anuplug = { + async before(m, anubis, { text, command, args, prefix, pushname, ucapan }) { + try { + let user = anubis.db.data.users[m.sender]; + let msgs = anubis.db.data.database.note[m.chat]; + let buttons = [ + { + buttonId: `/owner`, + buttonText: { displayText: "Contact Owner" }, + type: 1, + }, + { + buttonId: `/changelogs`, + buttonText: { displayText: "Change Logs" }, + type: 1, + }, + { buttonId: `/menu`, buttonText: { displayText: "Menu" }, type: 1 }, + ]; - function similar(a,b) { - let equivalency = 0 - let minLength = (a.length > b.length) ? b.length : a.length - let maxLength = (a.length < b.length) ? b.length : a.length - let hasil - for(let i = 0; i < minLength; i++) { - if(a[i] == b[i]) { - equivalency++ - } - let weight = equivalency / maxLength - let rate = (weight * 100) - if (rate > 39) hasil = {rate, text: b} - } - return (typeof hasil !== 'undefined') ? hasil : null - } + function similar(teks, tekss) { + let equivalency = 0; + let minLength = teks.length > tekss.length ? tekss.length : teks.length; + let maxLength = teks.length < tekss.length ? tekss.length : teks.length; + let hasil; + for (let i = 0; i < minLength; i++) { + if (teks[i] == tekss[i]) { + equivalency++; + } + let weight = equivalency / maxLength; + let rate = weight * 100; + if (rate > 39) hasil = { rate, text: tekss }; + } + return typeof hasil !== "undefined" ? hasil : null; + } - function initialize(a,b) { - let cmd = [] - for (let i = 0; i < b.length; i++) { - let d = b[i].test(a) - if (d) cmd.push(d) - } - return cmd[0] - } + function initialize(teks, arr) { + let cmd = []; + for (let i = 0; i < arr.length; i++) { + let d = arr[i].test(teks); + if (d) cmd.push(d); + } + return cmd[0]; + } - let helps = [] - let cmds = [] - for (let i = 0; i < Object.values(global.plugins).filter(plugin => !plugin.disabled).length; i++) { - if (Object.values(global.plugins).filter(plugin => !plugin.disabled)[i].help !== undefined) { - for (let j = 0; j < Object.values(global.plugins).filter(plugin => !plugin.disabled)[i].help.length; j++) { - helps.push(Object.values(global.plugins).filter(plugin => !plugin.disabled)[i].help[j]) - } - cmds.push(Object.values(global.plugins).filter(plugin => !plugin.disabled)[i].command) - } - } - let isCmd = initialize(command, cmds) - let pada = [] - for (let help of helps) { - let a = similar(command, help, cmds) - if (a !== null) pada.push(a) - } - if (!prefix) { - if (m.mtype === 'conversation') { - if (m.chat.endsWith('broadcast') || m.fromMe || m.isGroup) return - if (new Date - user.cCorect < 300 * 1000) return // 5 minutes ago - anubis.sendButtonMsg(m.chat, `Hanya bisa menerima command ngab!\nKalo mau chat, complain, ngeluh tentang botnya dll\nKirim pesan ke admin ngab!\nDisini ga bakal di jawab\nKalo di jawab pun anda termasuk orang yang beruntung :v`, buttons, m) - user.cCorect = new Date * 1 - return - } - } else { - if (isCmd) return - if (pada.length === 0) { - anubis.sendButtonMsg(m.chat, `Command *${prefix + command}* tidak ditemukan ngab!\nCoba cek menu list`, buttons, m) - } else if (pada.length === 1) { - if (pada[0].rate === 100) return - let sections = [ { title: 'Mungkin maksud command anda', rows: [{ title: pada[0].text, description: ``, rowId: `${prefix + pada[0].text} ${text}` }] } ] - return anubis.sendList(m.chat, 'Command Correction', 'Command tidak ditemukan\nMungkin maksud anda : ', 'Result', sections, m) - } else if (pada.length > 1) { - let rows = [] - for (let i = 0; i < pada.length; i++) { - if (pada[i].rate === 100) return - rows.push( { title: pada[i].text, description: ``, rowId: `${prefix + pada[i].text} ${text}` } ) - } - let sections = [ { title: 'Mungkin maksud command anda', rows: rows } ] - return anubis.sendList(m.chat, 'Command Correction', 'Command tidak ditemukan\nMungkin maksud anda : ', 'Result', sections, m) - } else { - return anubis.sendMessage(m.chat, {text: 'gila lu ngab!'}, {quoted: m}) - } - } - } catch (err) { - console.err(err) + let helps = []; + let cmds = []; + for ( + let i = 0; + i < + Object.values(global.plugins).filter((plugin) => !plugin.disabled) + .length; + i++ + ) { + if ( + Object.values(global.plugins).filter((plugin) => !plugin.disabled)[i] + .help !== undefined + ) { + for ( + let j = 0; + j < + Object.values(global.plugins).filter((plugin) => !plugin.disabled)[ + i + ].help.length; + j++ + ) { + helps.push( + Object.values(global.plugins).filter( + (plugin) => !plugin.disabled + )[i].help[j] + ); + } + cmds.push( + Object.values(global.plugins).filter((plugin) => !plugin.disabled)[ + i + ].command + ); + } + } + let isCmd = initialize(command, cmds); + let pada = []; + for (let help of helps) { + let a = similar(command, help); + if (a !== null) pada.push(a); + } + if (!prefix) { + if (m.isGroup && m.text.toLowerCase() in msgs) { + // to get notes in group without command get + if (msgs[m.text.toLowerCase()].lock) return; + return await anubis.copyNForward( + m.chat, + msgs[m.text.toLowerCase()].pesan, + true + ); + } + if (m.mtype === "conversation") { + if (m.chat.endsWith("broadcast") || m.fromMe || m.isGroup) return; + if (new Date() - user.cCorect < 300 * 1000) return; // 5 minutes ago + anubis.sendButtonMsg( + m.chat, + `Hanya bisa menerima command ngab!\nKalo mau chat, complain, ngeluh tentang botnya dll\nKirim pesan ke admin ngab!\nDisini ga bakal di jawab\nKalo di jawab pun anda termasuk orang yang beruntung :v`.trim(), + buttons, + m + ); + user.cCorect = new Date() * 1; + return; + } + } else { + if (isCmd) return; + if (pada.length === 0) { + anubis.sendButtonMsg( + m.chat, + `Command *${ + prefix + command + }* tidak ditemukan ngab!\nCoba cek menu list`, + buttons, + m + ); + } else if (pada.length === 1) { + if (pada[0].rate === 100) return; + let sections = [ + { + title: "Mungkin maksud command anda", + rows: [ + { + title: pada[0].text, + description: ``, + rowId: `${prefix + pada[0].text} ${text}`, + }, + ], + }, + ]; + return anubis.sendList( + m.chat, + "Command Correction", + "Command tidak ditemukan\nMungkin maksud anda : ", + "Result", + sections, + m + ); + } else if (pada.length > 1) { + let rows = []; + for (let i = 0; i < pada.length; i++) { + if (pada[i].rate === 100) return; + rows.push({ + title: pada[i].text, + description: ``, + rowId: `${prefix + pada[i].text} ${text}`, + }); + } + let sections = [{ title: "Mungkin maksud command anda", rows: rows }]; + return anubis.sendList( + m.chat, + "Command Correction", + "Command tidak ditemukan\nMungkin maksud anda : ", + "Result", + sections, + m + ); + } else { + return anubis.sendMessage( + m.chat, + { text: "gila lu ngab!" }, + { quoted: m } + ); } + } + } catch (err) { + console.err(err); } -} + }, +}; diff --git a/plugins/_firstchat.js b/plugins/_firstchat.js index 5ed20cb..efa01f5 100644 --- a/plugins/_firstchat.js +++ b/plugins/_firstchat.js @@ -1,27 +1,43 @@ /** * anubisbot-MD https://github.com/anubiskun/anubisbot-MD - * + * * Copyright (c) 2022 anubiskun * https://github.com/anubiskun */ -const moment = require('moment-timezone') +const moment = require("moment-timezone"); module.exports = anuplug = { - async all(m, anubis, {pushname}) { - let user = anubis.db.data.users[m.sender] - let public = global.botpublic - if (m.chat.endsWith('broadcast') || m.fromMe || m.isGroup) return - if (new Date - user.pc < 10800 * 1000) return // count 3 hours + async all(m, anubis, { pushname }) { + let user = anubis.db.data.users[m.sender]; + let public = global.botpublic; + if (m.chat.endsWith("broadcast") || m.fromMe || m.isGroup) return; + if (public) if (new Date() - user.pc < 10800 * 1000) return; // count 3 hours let buttons = [ - { buttonId: `.owner`, buttonText: { displayText: "Contact Owner" }, type: 1 }, - { buttonId: `.changelogs`, buttonText: { displayText: "Change Logs" }, type: 1 }, - { buttonId: `.menu`, buttonText: { displayText: "Menu" }, type: 1 }, + { + buttonId: `/owner`, + buttonText: { displayText: "Contact Owner" }, + type: 1, + }, + { + buttonId: `/changelogs`, + buttonText: { displayText: "Change Logs" }, + type: 1, + }, + { buttonId: `/menu`, buttonText: { displayText: "Menu" }, type: 1 }, ]; - let buttonMessage = { text: `${ucapan()} *${pushname}*\n${!public ? 'bot sedang ingin menyendiri,\n lagi maintenance sama ayang anubis, bot sementara ga bisa jawab >_< \nGomen nasai *(โ„ส˜โ„โ„ฯ‰โ„โ„ส˜โ„)๐Ÿ™๐Ÿป*' : user.banned ? "kamu dibanned _-'" : `\nAda yang bisa ${anubis.user.name} bantu?\n\nBTW sekrang command wajib pake prefix!\nPrefixnya ./!\nContoh: .sticker atau /menu\n\nKalu ga tau /atau ada error hubungi owner thxs!!`}\n*Source code* : \nhttps://github.com/anubiskun/anubisbot-MD\n\n*Change Log* :\n${require(__root + 'package.json').changeLogs[0]}\n`.trim(), footer: global.anuFooter, buttons }; - anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); - user.pc = new Date * 1 - } -} + const pes = `${ucapan()} *${pushname}* ${ + m.isPremium ? "โœ…" : "" + }\nSisa Limit anda: *${m.limit}*\n${ + !public + ? "bot sedang ingin menyendiri,\nlagi maintenance sama ayang anubis, bot sementara ga bisa jawab >_< \nGomen nasai *(โ„ส˜โ„โ„ฯ‰โ„โ„ส˜โ„)๐Ÿ™๐Ÿป*" + : user.isBanned + ? "kamu dibanned _-'" + : `\nAda yang bisa ${anubis.user.name} bantu?\n\nBTW sekrang command wajib pake prefix!\nPrefixnya ./!#\nContoh: #sticker atau /menu\n\nKalu ga tau /atau ada error hubungi owner thxs!!` + }\n\n*Change Log* :\n${require(__root + "package.json").changeLogs[0]}\n`; + anubis.sendButtonMsg(m.sender, pes.trim(), buttons, m); + if (public) user.pc = new Date() * 1; + }, +}; function ucapan() { const time = moment.tz("Asia/Jakarta").format("HH"); @@ -39,4 +55,4 @@ function ucapan() { res = "Selamat malam"; } return res; -} \ No newline at end of file +} diff --git a/plugins/downloader.js b/plugins/downloader.js index f5d0a18..138cd26 100644 --- a/plugins/downloader.js +++ b/plugins/downloader.js @@ -5,13 +5,16 @@ * https://github.com/anubiskun */ +const fs = require('fs') const isUrl = require('is-url'); -const {iggetid, igjson, igstory, hagodl, tiktok, jooxDownloader, jooxSearch, soundcloud, pinterest, shortlink} = require('../library/lib') +const {iggetid, igjson, igstory, hagodl, tiktok, jooxDownloader, jooxSearch, soundcloud, pinterest, shortlink, pinterest2} = require('../library/lib') const moment = require('moment-timezone'); const { yta, ytv, ytIdRegex } = require('../library/y2mate') let youtube = require("youtube-search-api") +const google = require('googlethis') +const { tmpfiles } = require('../library/upload'); -module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) => { +module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix, mime, qmsg }) => { switch(command){ case 'instagram': case 'ig': @@ -19,14 +22,15 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) let igPreg = /(?:https?:\/\/)?(?:www.)?instagram.com\/?(?:[a-zA-Z0-9\.\_\-]+)?\/((?:[p]+)?(?:[reel]+)?(?:[tv]+)?(?:[stories]+)?)\/([a-zA-Z0-9\-\_\.]+)\/?([0-9]+)?/g; if (!text) return m.reply(`*Example* : ${usedPrefix + command} https://www.instagram.com/p/Cisd6jEvFKp/?igshid=YmMyMTA2M2Y=`) if (!isUrl(text)) return m.reply("coba cek lagi urlnya ngab!!!!!!!!!!"); + if (!/instagram/.test(text)) return m.reply("coba cek lagi urlnya ngab!!!!!!!!!!"); let igreg = igPreg.exec(text); m.reply(mess.wait); try { if (igreg[1] != "stories" && igreg[1] !== "s") { const getid = await iggetid(igreg[2]); - if (!getid.status) return m.reply('error ngab coba cek urlnya!') + if (!getid.status) return m.reply('Media Ga di temukan ngab!, Mungkin Private!') const ig = await igjson(getid.id); - const teks = '' + if (!ig.status) return m.reply('Media Ga di temukan ngab!, Mungkin Private!') const json = ig.data[Math.floor(Math.random() * ig.data.length)]; const time = moment .unix(json.post.taken_at) @@ -52,7 +56,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) teks += `\n*Caption*: ${json.post.caption}`; for (let i = 0; i < json.media.length; i++) { if (json.media[i].type == "mp4") { - anubis.sendVideo(m.chat, json.media[i].url, teks, m) + anubis.sendVideo(m.chat, json.media[i].url, teks, m, json.media[i].thumb) } else if (json.media[i].type == "jpg") { anubis.sendImage(m.chat, json.media[i].url, teks, m) } else { @@ -71,7 +75,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) } for (let i = 0; i < json.media.length; i++) { if (json.media[i].type == "mp4") { - anubis.sendVideo(m.chat, json.media[i].url, teks, m) + anubis.sendVideo(m.chat, json.media[i].url, teks, m, json.media[i].thumb) } else if (json.media[i].type == "jpg") { anubis.sendImage(m.chat, json.media[i].url, teks, m) } else { @@ -92,7 +96,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) teks += `\n*Caption*: ${json.anubis.caption}`; } if (json.anubis.type == "mp4") { - anubis.sendVideo(m.chat, json.anubis.url, teks, m) + anubis.sendVideo(m.chat, json.anubis.url, teks, m, json.anubis.thumb) } else if (json.anubis.type == "jpg") { anubis.sendImage(m.chat, json.anubis.url, teks, m) } else { @@ -120,7 +124,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) } for (let i = 0; i < json.media.length; i++) { if (json.media[i].type == "mp4") { - anubis.sendVideo(m.chat, json.media[i].url, teks, m) + anubis.sendVideo(m.chat, json.media[i].url, teks, m, json.media[i].thumb) } else if (json.media[i].type == "jpg") { anubis.sendImage(m.chat, json.media[i].url, teks, m) } else { @@ -198,7 +202,8 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) case 'jooxdl': case 'jooxdownloader': { - if (!text) return m.reply(`Example : ${usedPrefix + command} anubis si paling cakep :v, ygy?!`); + if (!text) return m.reply(`Example : ${usedPrefix + command} l6ZHajU7vS2zej0+x9KvMw==`); + if (isUrl(text)) return m.reply(`Example : ${usedPrefix + command} l6ZHajU7vS2zej0+x9KvMw==`); m.reply(mess.wait) try { let json = await jooxDownloader(text) @@ -232,7 +237,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) rows: rows } ] - anubis.sendList(m.chat, "*JOOX SEARCH*", pesane, 'RESULT', secs, m) + anubis.sendList(m.chat, "*[ JOOX SEARCH ]*", pesane, 'RESULT', secs, m) } catch (err) { console.err(err) m.reply(global.msg.err) @@ -259,7 +264,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) rows: rows } ] - anubis.sendList(m.chat, "*JOOX SEARCH*", pesane, 'RESULT', secs, m) + anubis.sendList(m.chat, "*[ SOUNDCLOUD SEARCH ]*", pesane, 'RESULT', secs, m) } catch (err) { console.err(err) m.reply(global.msg.err) @@ -270,49 +275,126 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) { if (!text) throw `Example : ${usedPrefix + command} gojo satoru` m.reply(mess.wait) - try { - anu = await pinterest(text); - result = anu[Math.floor(Math.random() * anu.length)]; - let buttons = [ - { + let buttons = [ + { buttonId: `${usedPrefix}pinterest ${text}`, buttonText: { displayText: "Next Image" }, type: 1, - }, - ]; + }, + ]; + try { + let anu = await pinterest2(text); + let result = anu.anubis[Math.floor(Math.random() * anu.anubis.length)]; + let pes = `*ใ€Œ PINTEREST SEARCH ใ€*\n\n` + pes += `*Query* : ${text}\n` + pes += `*Title* : ${(result.title ? result.title : '')}\n` + pes += `*Description* : ${(result.desc) ? result.desc : ''}\n` + pes += `*Alt Text* : ${(result.alt) ? result.alt : ''}\n` + pes += `*Uploader* : ${result.owner.username}\n` + pes += `*Full Name* : ${result.owner.full_name}\n` + pes += `*Follower* : ${result.owner.follower}\n` + if (result.video !== null){ + pes += `*Media Url* : ${await shortlink(result.video.url)}\n` + let buttonMessage = { + video: { url: result.video.url }, + caption: pes, + footer: anuFooter, + jpegThumbnail: result.video.thumbnail, + buttons: buttons, + headerType: 4, + }; + await anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); + } else { + pes += `*Media Url* : ${await shortlink(result.image.url)}\n` + let buttonMessage = { + image: { url: result.image.url }, + caption: pes, + footer: anuFooter, + buttons: buttons, + headerType: 4, + }; + await anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); + } + } catch (err) { + console.log(err) + anu = await pinterest(text); + result = anu[Math.floor(Math.random() * anu.length)]; let buttonMessage = { image: { url: result }, - caption: `*-------ใ€Œ PINTEREST SEARCH ใ€-------*hero -๐Ÿค  *Query* : ${text} -๐Ÿ”— *Media Url* : ${await shortlink(result)}`, + caption: `*ใ€Œ PINTEREST SEARCH ใ€* +*Query* : ${text} +*Media Url* : ${await shortlink(result)}`, footer: anuFooter, buttons: buttons, headerType: 4, }; await anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); - } catch (err) { - console.err(err) - anu = await pinterest(text); - result = anu[Math.floor(Math.random() * anu.length)]; + } + } + break; + case 'gimage': + { + if (!text) throw `Example : ${usedPrefix + command} gojo satoru` + m.reply(mess.wait) + try { + let n = [] + n = await google.image(text,{safe: false}).catch(async(e) => {n = await google.image(text,{safe: false}).catch(console.err)}) + images = n[Math.floor(Math.random() * n.length)] let buttons = [ { - buttonId: `${usedPrefix}pinterest ${text}`, - buttonText: { displayText: "Next Image" }, - type: 1, + buttonId: `${usedPrefix + command} ${text}`, + buttonText: { displayText: "Next Image" }, + type: 1, }, ]; let buttonMessage = { - image: { url: result }, - caption: `*-------ใ€Œ PINTEREST SEARCH ใ€-------*hero -๐Ÿค  *Query* : ${text} -๐Ÿ”— *Media Url* : ${await shortlink(result)}`, + image: { url: images.url }, + caption: `*ใ€Œ GIMAGE SEARCH ใ€* + +*Query* : ${text} +*Media Url* : ${await shortlink(images.url)} +*Title* : ${images.origin.title} +*WebSite Name* : ${images.origin.website.name} +*WebSite Url* : ${await shortlink(images.origin.website.url)} +*Size* : ${images.width}x${images.height}`, footer: anuFooter, buttons: buttons, headerType: 4, }; - await anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); - + anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); + } catch (err) { + console.err(err) + return m.reply(`command *${command}* lagi error ngab!`) + } + } + break; + case 'gimgrev': + { + return m.reply(`command *${command}* lagi error ngab!`) + if (!/image/.test(mime) && !isUrl(text)) return m.reply(`Reply gambar yang mau di cari di google ngab!`) + let qstring = '' + if (isUrl(text)) qstring = text + if (/image/.test(mime)) { + let media = await anubis.downloadAndSaveMediaMessage(qmsg); + let {url} = await tmpfiles(media) + await fs.unlinkSync(media); + qstring = url + } + m.reply(mess.wait) + try { + const {results} = await google.search(qstring, { ris: true }); + let teks = `Result from Google search by Image :\n\n` + if (!results) return m.reply('Gambar Tidak di temukan kecocokan ngab!') + for (let g of results) { + teks += `โญ” *Title* : ${g.title}\n` + teks += `โญ” *Description* : ${g.description}\n` + teks += `โญ” *Link* : ${g.url}\n\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n\n` + } + anubis.sendMessage(m.chat, {text: teks}, { quoted: m }); + } catch (err) { + console.err(err) + return m.reply(`command *${command}* lagi error ngab!`) } } break; @@ -344,14 +426,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) let media = await ytv(text, quality) if (media.filesize >= 100000) return anubis.sendImage(m.chat,media.thumb,`*FILE MELEBIHI BATAS SILAHKAN GUNAKAN LINK*\n\n๐ŸŒ€ Title : ${media.title}\n๐ŸŒ€ Like : ${media.likes}\n๐ŸŒ€ Dislike : ${media.dislikes}\n๐ŸŒ€ Rating : ${media.rating}\n๐ŸŒ€ ViewCount : ${media.viewCount}\n๐ŸŒ€ File Size : ${media.filesizeF}\n๐ŸŒ€ Ext : MP4\n๐ŸŒ€ Resolusi : ${args[1] || "360p"}\n*Link* : ${await shortlink(media.dl_link)}`,m); - await anubis.sendMessage(m.chat,{ - video: { url: media.dl_link }, - jpegThumbnail: await anubis.genThumb(media.thumb).thumbnail, - mimetype: "video/mp4", - fileName: `${media.title}.mp4`, - caption: `๐ŸŒ€ Title : ${media.title}\n๐ŸŒ€ Like : ${media.likes}\n๐ŸŒ€ Dislike : ${media.dislikes}\n๐ŸŒ€ Rating : ${media.rating}\n๐ŸŒ€ ViewCount : ${media.viewCount}\n๐ŸŒ€ File Size : ${media.filesizeF}\n๐ŸŒ€ Ext : MP4\n๐ŸŒ€ Resolusi : ${args[1] || "360p"}` - },{ quoted: m } - ) + await anubis.sendVideo(m.chat, media.dl_link, `๐ŸŒ€ Title : ${media.title}\n๐ŸŒ€ Like : ${media.likes}\n๐ŸŒ€ Dislike : ${media.dislikes}\n๐ŸŒ€ Rating : ${media.rating}\n๐ŸŒ€ ViewCount : ${media.viewCount}\n๐ŸŒ€ File Size : ${media.filesizeF}\n๐ŸŒ€ Ext : MP4\n๐ŸŒ€ Resolusi : ${args[1] || "360p"}`, m, media.thumb) } catch (err) { console.err(err) let buttons = [{ buttonId: `${usedPrefix}ytdlv ${text}`, buttonText: { displayText: "YT Downloader" }, type: 1 }]; @@ -400,16 +475,15 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) title: i + 1, }); }); - anubis.sendList(m.chat, "*YOUTUBE SEARCH*", pesane, 'RESULT', secs, m); + anubis.sendList(m.chat, "*[ YOUTUBE SEARCH ]*", pesane, 'RESULT', secs, m); } break; } } -anuplug.help = ['instagram','hago','tiktok','jooxsearch','soundcloudsearch','pinterest','ytmp3','ytmp4','ytsearch'] +anuplug.help = ['instagram','hago','tiktok','jooxsearch','soundcloudsearch','ytsearch','pinterest','gimage','gimgrev (error)','ytmp3','ytmp4'] anuplug.tags = ['downloader'] -anuplug.command = /^(ig|instagram|hago|hg|tiktok|tt|jooxdownloader|jooxdl|jooxsearch|jooxs|soundcloudsearch|scs|pinterest|yta|ytmp3|ytv|ytmp4|yts|ytsearch)$/i -anuplug.isPremium = true // using limit if limit 0 not run -// anuplug.premium = true // premium only +anuplug.command = /^(ig|instagram|hago|hg|tiktok|tt|jooxdownloader|jooxdl|jooxsearch|jooxs|soundcloudsearch|scs|pinterest|gimage|gimgrev|yta|ytmp3|ytv|ytmp4|yts|ytsearch)$/i +anuplug.isPremium = true function ses(secs) { let sec_num = parseInt(secs, 10); diff --git a/plugins/menu.js b/plugins/menu.js index decba0c..5c132d1 100644 --- a/plugins/menu.js +++ b/plugins/menu.js @@ -11,13 +11,13 @@ let moment = require('moment-timezone') const defaultMenu = { before: ` โ•ญโ”€โ”€โ”€โ”€โ”€โ”€ใ€” *%me* ใ€• -โ”‚ Hai, %name! +โ”‚ Hai, %name! %prem +โ”‚ Limit: %limit โ”‚ โ”‚ Date: %date โ”‚ Time: *%time* โ”‚ โ”‚ Uptime: *%uptime* -โ”‚ Github: %github โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€ใ€” *%me* ใ€• %readmore`.trimStart(), @@ -83,7 +83,7 @@ ${'```%npmdesc```'} rows: rows } ] - return anubis.sendList(m.chat, 'MENU', `${ucapan()} ${name}`, 'MENU', secs, m) + return anubis.sendList(m.chat, 'MENU', `${ucapan()} ${name} ${(m.isPremium) ? 'โœ…' : ''}\nSisa Limit : *${m.limit}*`, 'MENU', secs, m) } let groups = {} @@ -121,6 +121,8 @@ ${'```%npmdesc```'} '%': '%', p: usedPrefix, uptime, me: anubis.user.name, + prem: (m.isPremium) ? 'โœ…' : '', + limit: m.limit, npmname: package.name, npmdesc: package.description, version: package.version, @@ -133,25 +135,25 @@ ${'```%npmdesc```'} { buttonId: `${usedPrefix}owner`, buttonText: { displayText: "Contact Owner" }, type: 1 }, { buttonId: `${usedPrefix}changelogs`, buttonText: { displayText: "Change Logs" }, type: 1 }, ]; - let buttonMessage = {} + let content = {} if (thumbnail.type === 'video') { - buttonMessage = { + content = { video: Buffer.from(thumbnail.buffer, 'base64'), gifPlayback: true, jpegThumbnail: Buffer.from(thumbnail.thumb, 'base64'), caption: pesen.trim(), footer: global.anuFooter, - buttons: buttons, + buttons, } } else { - buttonMessage = { + content = { image: Buffer.from(thumbnail.buffer, 'base64'), caption: pesen.trim(), footer: global.anuFooter, - buttons: buttons, + buttons, }; } - anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); + anubis.sendMessage(m.chat, content, { quoted: m }); } catch (err) { console.err(err) } diff --git a/plugins/mixGC.js b/plugins/mixGC.js index 680d53e..f611b9e 100644 --- a/plugins/mixGC.js +++ b/plugins/mixGC.js @@ -5,109 +5,108 @@ * https://github.com/anubiskun */ - module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix, participants }) => { - let vote = anubis.db.data.others.vote; - switch(command){ - case 'tagall': - { - let teks = ` [ TAGALL ] - Pesan : ${text ? text : 'kosong'}\n\n` +module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix, participants }) => { + let vote = anubis.db.data.others.vote; + switch(command){ + case 'tagall': + { + let teks = ` [ TAGALL ] +Pesan : ${text ? text : 'kosong'}\n\n` for (let mem of participants) { - teks += `> @${mem.id.split("@")[0]}\n`; - } - anubis.sendMessage( - m.chat, - { text: teks, mentions: participants.map((a) => a.id) }, - { quoted: m } - ); - } - break; - case 'hidetag': - case 'ht': - { - anubis.sendMessage(m.chat,{ text: text ? text : "", mentions: participants.map((a) => a.id) },{ quoted: m } + teks += `> @${mem.id.split("@")[0]}\n`; + } + anubis.sendMessage( + m.chat, + { text: teks, mentions: participants.map((a) => a.id) }, + { quoted: m } ); - } - break; - case 'devote': - { - if (!(m.chat in vote)) return m.reply(`_*gak ada vote di group ini ngab!*_\n\n*${usedPrefix}vote* - untuk memulai vote ngab!`) - let isVote = vote[m.chat][1].concat(vote[m.chat][2]); - let wasVote = isVote.includes(m.sender); - if (wasVote) return m.reply("Kamu Sudah Vote"); - vote[m.chat][2].push(m.sender); - let teks = `*[ VOTE ]* - - *Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} - - *[ SETUJU ]* : ${vote[m.chat][1].length} - ${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} - - *[ TIDAK ]* : ${vote[m.chat][2].length} - ${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} - ` - let buttons = [ - { buttonId: `${usedPrefix}upvote`, buttonText: { displayText: "SETUJU" }, type: 1 }, - { buttonId: `${usedPrefix}devote`, buttonText: { displayText: "TIDAK" }, type: 1 }, - { buttonId: `${usedPrefix}cekvote`, buttonText: { displayText: "CHECK VOTE" }, type: 1 }, - ]; - let buttonMessage = { text: teks, footer: global.anuFooter, buttons }; - anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); - } - break; - case 'upvote': - { - if (!(m.chat in vote)) return m.reply(`_*gak ada vote di group ini ngab!*_\n\n*${usedPrefix}vote* - untuk memulai vote ngab!`) - let isVote = vote[m.chat][1].concat(vote[m.chat][2]); - let wasVote = isVote.includes(m.sender); - if (wasVote) return m.reply("Kamu Sudah Vote"); - vote[m.chat][1].push(m.sender); - let teks = `*[ VOTE ]* - - *Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} - - *[ SETUJU ]* : ${vote[m.chat][1].length} - ${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} - - *[ TIDAK ]* : ${vote[m.chat][2].length} - ${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} - ` - let buttons = [ - { buttonId: `${usedPrefix}upvote`, buttonText: { displayText: "SETUJU" }, type: 1 }, - { buttonId: `${usedPrefix}devote`, buttonText: { displayText: "TIDAK" }, type: 1 }, - { buttonId: `${usedPrefix}cekvote`, buttonText: { displayText: "CHECK VOTE" }, type: 1 }, - ]; - let buttonMessage = { text: teks, footer: global.anuFooter, buttons }; - anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); - } - break; - case 'cekvote': - { - if (!(m.chat in vote)) return m.reply(`_*gak ada vote di group ini ngab!*_\n\n*${usedPrefix}vote* - untuk memulai vote ngab!`) - let teks = `*[ VOTE ]* - - *Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} - - *[ SETUJU ]* : ${vote[m.chat][1].length} - ${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} - - *[ TIDAK ]* : ${vote[m.chat][2].length} - ${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} - ` - let buttons = [ - { buttonId: `${usedPrefix}upvote`, buttonText: { displayText: "SETUJU" }, type: 1 }, - { buttonId: `${usedPrefix}devote`, buttonText: { displayText: "TIDAK" }, type: 1 }, - { buttonId: `${usedPrefix}delvote`, buttonText: { displayText: "TUTUP VOTE" }, type: 1 }, - ]; - let buttonMessage = { text: teks, footer: global.anuFooter, buttons }; - anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); - } - break; - - } - } - anuplug.help = ['tagall', 'hidetag','cekvote'] - anuplug.tags = ['group'] - anuplug.command = /^(tagall|ht|hidetag|(de|up|cek)vote)$/i - anuplug.group = true - \ No newline at end of file + } + break; + case 'hidetag': + case 'ht': + { + anubis.sendMessage(m.chat,{ text: text ? text : "", mentions: participants.map((a) => a.id) },{ quoted: m } + ); + } + break; + case 'devote': + { + if (!(m.chat in vote)) return m.reply(`_*gak ada vote di group ini ngab!*_\n\n*${usedPrefix}vote* - untuk memulai vote ngab!`) + let isVote = vote[m.chat][1].concat(vote[m.chat][2]); + let wasVote = isVote.includes(m.sender); + if (wasVote) return m.reply("Kamu Sudah Vote"); + vote[m.chat][2].push(m.sender); +let teks = `*[ VOTE ]* + +*Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} + +*[ SETUJU ]* : ${vote[m.chat][1].length} +${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} + +*[ TIDAK ]* : ${vote[m.chat][2].length} +${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} +` + let buttons = [ + { buttonId: `${usedPrefix}upvote`, buttonText: { displayText: "SETUJU" }, type: 1 }, + { buttonId: `${usedPrefix}devote`, buttonText: { displayText: "TIDAK" }, type: 1 }, + { buttonId: `${usedPrefix}cekvote`, buttonText: { displayText: "CHECK VOTE" }, type: 1 }, + ]; + let buttonMessage = { text: teks, footer: global.anuFooter, buttons }; + anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); + } + break; + case 'upvote': + { + if (!(m.chat in vote)) return m.reply(`_*gak ada vote di group ini ngab!*_\n\n*${usedPrefix}vote* - untuk memulai vote ngab!`) + let isVote = vote[m.chat][1].concat(vote[m.chat][2]); + let wasVote = isVote.includes(m.sender); + if (wasVote) return m.reply("Kamu Sudah Vote"); + vote[m.chat][1].push(m.sender); +let teks = `*[ VOTE ]* + +*Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} + +*[ SETUJU ]* : ${vote[m.chat][1].length} +${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} + +*[ TIDAK ]* : ${vote[m.chat][2].length} +${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} +` + let buttons = [ + { buttonId: `${usedPrefix}upvote`, buttonText: { displayText: "SETUJU" }, type: 1 }, + { buttonId: `${usedPrefix}devote`, buttonText: { displayText: "TIDAK" }, type: 1 }, + { buttonId: `${usedPrefix}cekvote`, buttonText: { displayText: "CHECK VOTE" }, type: 1 }, + ]; + let buttonMessage = { text: teks, footer: global.anuFooter, buttons }; + anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); + } + break; + case 'cekvote': + { + if (!(m.chat in vote)) return m.reply(`_*gak ada vote di group ini ngab!*_\n\n*${usedPrefix}vote* - untuk memulai vote ngab!`) + let teks = `*[ VOTE ]* + +*Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} + +*[ SETUJU ]* : ${vote[m.chat][1].length} +${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} + +*[ TIDAK ]* : ${vote[m.chat][2].length} +${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} +` + let buttons = [ + { buttonId: `${usedPrefix}upvote`, buttonText: { displayText: "SETUJU" }, type: 1 }, + { buttonId: `${usedPrefix}devote`, buttonText: { displayText: "TIDAK" }, type: 1 }, + { buttonId: `${usedPrefix}delvote`, buttonText: { displayText: "TUTUP VOTE" }, type: 1 }, + ]; + let buttonMessage = { text: teks, footer: global.anuFooter, buttons }; + anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); + } + break; + + } +} +anuplug.help = ['tagall', 'hidetag','cekvote'] +anuplug.tags = ['group'] +anuplug.command = /^(tagall|ht|hidetag|(de|up|cek)vote)$/i +anuplug.group = true diff --git a/plugins/mixGCA.js b/plugins/mixGCA.js index e6fa07f..f41c378 100644 --- a/plugins/mixGCA.js +++ b/plugins/mixGCA.js @@ -8,13 +8,15 @@ const {sleep} = require('../library/lib') module.exports = anuplug = async(m, anubis, { participants, text, command, args, usedPrefix }) => { + let dbChats = anubis.db.data.chats[m.chat] let vote = anubis.db.data.others.vote; let user = m.mentionedJid[0] - ? m.mentionedJid[0] - : m.quoted - ? m.quoted.sender - : text.replace(/[^0-9]/g, ""); - let users = user.split("@")[0] + ? m.mentionedJid[0] + + : m.quoted + ? m.quoted.sender + : text.replace(/[^0-9]/g, ""); + let users = user.split("@")[0] switch(command){ case 'add': { @@ -106,13 +108,13 @@ await sleep(1000) let teks = `*[ VOTE ]* - *Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} - - *[ SETUJU ]* : ${vote[m.chat][1].length} - ${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} - - *[ TIDAK ]* : ${vote[m.chat][2].length} - ${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} +*Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} + +*[ SETUJU ]* : ${vote[m.chat][1].length} +${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} + +*[ TIDAK ]* : ${vote[m.chat][2].length} +${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} ` let buttons = [ { buttonId: `${usedPrefix}upvote`, buttonText: { displayText: "SETUJU" }, type: 1 }, @@ -127,13 +129,13 @@ if (!(m.chat in vote)) return m.reply(`_*gak ada vote di group ini ngab!*_\n\n*${usedPrefix}vote* - untuk memulai vote ngab!`) let teks = `*[ HASIL VOTE ]* - *Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} - - *[ SETUJU ]* : ${vote[m.chat][1].length} - ${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} - - *[ TIDAK ]* : ${vote[m.chat][2].length} - ${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} +*Alasan* : ${vote[m.chat][0] ? vote[m.chat][0] : 'tanpa alasan'} + +*[ SETUJU ]* : ${vote[m.chat][1].length} +${vote[m.chat][1].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} + +*[ TIDAK ]* : ${vote[m.chat][2].length} +${vote[m.chat][2].map((v, i) => `${i + 1}. @${v.split`@`[0]}`).join("\n")} ` const a = await anubis.sendMessage(m.chat, {text: teks}, {quoted: m}) if (a.status) { @@ -142,11 +144,105 @@ } } break; + case 'antilinkadd': { + if (!text) return m.reply(`Example: \n${usedPrefix + command} google.com\n${usedPrefix + command} google.com,youtube.com,...`); + if (!/\./.test(text)) return m.reply(`Example: ${usedPrefix + command} google.com`); + let dom = text.split(',') + let old = dbChats.banUrl.length + for (let dm of dom){ + const isSame = dbChats.banUrl.filter((v) => v === dm) + if (!isSame[0]) dbChats.banUrl.push(dm) + } + console.log(dbChats.banUrl) + if (dbChats.banUrl.length === old){ + m.reply(`Domain ${text} sudah ada di lists banned di group ini!`) + } else { + m.reply(`Domain ${text} berhasil di tambahkan di lists banned di group ini!`) + } + } + break; + case 'antilinkdel': { + if (!text) return m.reply(`Example: \n${usedPrefix + command} google.com\n${usedPrefix + command} google.com,youtube.com,...`); + if (!/\./.test(text)) return m.reply(`Example: ${usedPrefix + command} google.com`); + let dom = text.split(',') + let old = dbChats.banUrl.length + for (let dm of dom){ + const isSame = dbChats.banUrl.find((v)=> v === dm) + if (isSame) dbChats.banUrl.splice(dbChats.banUrl.indexOf(isSame), 1); + } + if (dbChats.banUrl.length === old){ + m.reply(`Domain ${text} tidak ada di lists banned global domain!`) + } else { + m.reply(`Domain ${text} berhasil di hapus dari lists banned global domain!`) + } + } + break; + case 'antilinklist': { + let banUrl = dbChats.banUrl.sort((a, b) => a.localeCompare(b)); + let pes = `*[ DOMAIN ANTILINK BANNED LIST ]* + +${banUrl.map((v, i) => `${i+1}. ${v}`).join('\n')}` + m.reply(pes) + } + break; + case 'setting': { + if (!text){ + let seting = [ + {name: 'antiviewonce', text: 'If on auto forwards oncetimeview media in this group', text2: 'If off disable auto forwards oncetimeview media in this group'}, + {name: 'antilink', text: 'If on auto warn member if detected send link with banned domain in this group', text2: 'If off disable auto warn member if detected send link with banned domain in this group'}, + {name: 'welcomer', text: 'If on auto send Welcomer to new member or leave member in this group', text2: 'If off disable auto send welcomer to new member or leave member in this group'}, + ] + let secs = [] + seting.forEach((v) => { + secs.push({ + rows: [ + { title: "on", description: `${v.text}`, rowId: `${usedPrefix + command} ${v.name} on` }, + { title: "off", description: `${v.text2}`, rowId: `${usedPrefix + command} ${v.name} off` }, + ], + title: v.name + ` ${(dbChats[v.name]) ? 'on' : 'off'}`, + }) + }) + let pesane = '*Choose one of the following options* :\n' + await anubis.sendList(m.chat, "*[ SETTINGS GROUP ]*", pesane, 'RESULT', secs, m); + } else { + let [sName, value] = args + switch (sName){ + case 'antiviewonce': { + if (value === 'on'){ + dbChats[sName] = true + } else if (value === 'off'){ + dbChats[sName] = true + } + m.reply((dbChats[sName]) ? `${sName} Dinyalakan!` : `${sName} Dimatikan!`) + } + break; + case 'antilink': { + if (value === 'on'){ + dbChats[sName] = true + } else if (value === 'off'){ + dbChats[sName] = true + } + m.reply((dbChats[sName]) ? `${sName} Dinyalakan!` : `${sName} Dimatikan!`) + } + break; + case 'welcomer': { + if (value === 'on'){ + dbChats[sName] = true + } else if (value === 'off'){ + dbChats[sName] = true + } + m.reply((dbChats[sName]) ? `${sName} Dinyalakan!` : `${sName} Dimatikan!`) + } + break; + } + } + } + break; } } - anuplug.help = ['add','kick','promote','demote','setname','setdesk','setppgroup','delete','vote','delvote'] + anuplug.help = ['add','kick','promote','demote','setname','setdesk','setppgroup','delete','vote','delvote','antilinkadd','antilinkdel','antilinklist','setting'] anuplug.tags = ['group'] - anuplug.command = /^(add|kick|(pro|de)mote|set(desk(ripsi)?|name|pp(gc|group|grup))|del(ete|vote)?)$/i + anuplug.command = /^(add|kick|(pro|de)mote|set(desk(ripsi)?|name|pp(gc|group|grup))|del(ete|vote)?|antilink(add|del|list)|setting)$/i anuplug.group = true anuplug.botAdmin = true anuplug.admin = true diff --git a/plugins/mixOwner.js b/plugins/mixOwner.js index c8879f2..9ac11c5 100644 --- a/plugins/mixOwner.js +++ b/plugins/mixOwner.js @@ -9,7 +9,7 @@ let cp = require('child_process') let { promisify } = require('util') let exec = promisify(cp.exec).bind(cp) -module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) => { +module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix, botNumber }) => { switch(command){ case 'addnote': case 'an': @@ -23,7 +23,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) } else { lock = true } - let msgs = anubis.db.data.database[m.chat] + let msgs = anubis.db.data.database.note[m.chat] let pesan = JSON.stringify(m.quoted.fakeObj) pesan = JSON.parse(pesan) if (nama.toLowerCase() in msgs) return m.reply(`nama '${nama}' sudah ada ngab!`) @@ -38,7 +38,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) case 'dn': { if (!text) return m.reply(`Example: ${usedPrefix + command} note name`) - let msgs = anubis.db.data.database[m.chat] + let msgs = anubis.db.data.database.note[m.chat] if (!(text.toLowerCase() in msgs)) return m.reply('Gaada ngab!') delete msgs[text.toLowerCase()]; m.reply('berhasil ngab!') @@ -51,7 +51,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) const [nama, ganti] = text.split('|') if (!nama) return m.reply('lu mau ganti nama note yang mana ngab!') if (!ganti) return m.reply('mau di ganti nama apa ngab! masukin dong!') - let msgs = anubis.db.data.database[m.chat] + let msgs = anubis.db.data.database.note[m.chat] if (!(nama.toLowerCase() in msgs)) return m.reply('Gaada ngab!') msgs[ganti.toLowerCase()] = msgs[nama.toLowerCase()] delete msgs[nama.toLowerCase()]; @@ -88,10 +88,26 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) m.reply(`Exif berhasil diubah menjadi\n\n๐ŸŒ€> Packname : ${global.packname}\n๐ŸŒ€> Author : ${global.author}`); } break; + case 'setcookie': { + if (!text) return m.reply(`Example: ${usedPrefix + command} ig|cookienya`) + const a = text.split('|') + if (!a[0]) return m.reply(`Example: ${usedPrefix + command} ig|cookienya`) + if (!a[1]) return m.reply(`Example: ${usedPrefix + command} ig|cookienya`) + switch (a[0]){ + case 'ig': { + anubis.db.data.settings[botNumber].igCookie = String(a[1]); + m.reply('Berhasil mereplace cookie ' + a[0]) + } + break; + } + } + break; case 'restart': { + anubis.db.data.database.lastRestart = true const a = await anubis.sendMessage(m.chat, {text: 'Bot sedang di restart tunggu beberapa saat ngab!'}, {quoted: m}) if (a.status) { + await anubis.db.write() process.send('restart') } } @@ -131,7 +147,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) break; } } -anuplug.help = ['addnote','delnote','rennote','public','setexif','restart','$','cthumb'] +anuplug.help = ['addnote','delnote','rennote','public','setexif','restart','$','insta','setcookie','cthumb'] anuplug.tags = ['owner'] -anuplug.command = /^(addnote|an|delnote|dn|rennote|rn|public|setexif|restart|[$]|cthumb)$/i +anuplug.command = /^(addnote|an|delnote|dn|rennote|rn|public|setexif|restart|[$]|insta|setcookie|cthumb)$/i anuplug.isAnubis = true \ No newline at end of file diff --git a/plugins/sticker.js b/plugins/mixsticker.js similarity index 59% rename from plugins/sticker.js rename to plugins/mixsticker.js index 5121f44..ec862aa 100644 --- a/plugins/sticker.js +++ b/plugins/mixsticker.js @@ -10,7 +10,8 @@ const Crypto = require("crypto") const webp = require("node-webpmux") const path = require("path"); const { videoToWebp, WebpToWebp, webpTopng } = require('../library/converter'); -const { webp2mp4File, tmpfiles } = require('../library/upload') +const { webp2mp4File, tmpfiles } = require('../library/upload'); +const { fetchJson } = require('../library/lib'); module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) => { const mquo = m.quoted || m; @@ -26,48 +27,6 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) const mime = (quoted.msg || quoted).mimetype || ""; const qmsg = quoted.msg || quoted; switch(command){ - case 's': - case 'sticker': - case 'stiker': - { - try { - if (!/(video|image|webp)/.test(mime)) return m.reply(`Kirim/reply gambar/video/gif dengan caption ${usedPrefix + command}\nDurasi Video/Gif 1-9 Detik`); - m.reply(mess.wait); - const tmpFileOut = path.join(__root, `/temp/${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) - let media - try { - let med = await anubis.downloadAndSaveMediaMessage(qmsg); - media = await fs.readFileSync(med) - await fs.unlinkSync(med); - } catch (e) { - media = await anubis.downloadMediaMessage(qmsg); - } - if (/(video|image)/.test(mime)) media = await WebpToWebp(media) - const img = new webp.Image() - const json = { "sticker-pack-id": Crypto.randomBytes(32).toString('hex'), "sticker-pack-name": global.packname, "sticker-pack-publisher": global.author, "emojis": ["๐Ÿ˜‚"] } - const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]) - const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8") - const exif = Buffer.concat([exifAttr, jsonBuff]) - exif.writeUIntLE(jsonBuff.length, 14, 4) - try { - await img.load(media) - } catch (err) { - let mee = await anubis.downloadAndSaveMediaMessage(qmsg); - let {result} = await webp2mp4File(mee); - let buff = await videoToWebp(result) - await fs.unlinkSync(mee); - await img.load(buff) - } - img.exif = exif - await img.save(tmpFileOut) - await anubis.sendMessage(m.chat, { sticker: { url: tmpFileOut }}, { quoted: m }) - await fs.unlinkSync(tmpFileOut); - } catch (err) { - m.reply('error ngab! cba wa ownernya!') - console.err(err) - } - } - break; case 'smeme': case 'stickermeme': case 'stikermeme': @@ -122,7 +81,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) } catch (e) { let med = await anubis.downloadAndSaveMediaMessage(qmsg); media = await fs.readFileSync(med) - await fs.unlinkSync(med); + fs.unlinkSync(med); } const ff = await webpTopng(media) anubis.sendMessage(m.chat, { image: ff }, { quoted: m }) @@ -139,25 +98,39 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) m.reply(mess.wait); let media = await anubis.downloadAndSaveMediaMessage(qmsg); let webpToMp4 = await webp2mp4File(media); - await anubis.sendMessage( - m.chat, - { - video: { - url: webpToMp4.result, - caption: "Convert Webp To Video", - }, - }, - { quoted: m } - ); - await fs.unlinkSync(media); + anubis.sendVideo(m.chat, webpToMp4.result, "Convert Webp To Video", m) + fs.unlinkSync(media); } catch (err) { console.err(err) m.reply('error ngab! cba wa ownernya!') } } break; + case 'emix': { + if (!text) return m.reply(`Example: ${usedPrefix + command} ๐Ÿ˜ ๐Ÿ˜ช\nExample: ${usedPrefix + command} ๐Ÿ˜|๐Ÿ˜ช\nExample: ${usedPrefix + command} ๐Ÿ˜`) + if (/\|/.test(text)) { + args = [] + args.push(text.split('|')[0],text.split('|')[1]) + } + let [emo1, emo2] = args + if (!emo1) return m.reply(`Example: ${usedPrefix + command} ๐Ÿ˜ ๐Ÿ˜ช\nExample: ${usedPrefix + command} ๐Ÿ˜|๐Ÿ˜ช\nExample: ${usedPrefix + command} ๐Ÿ˜`) + if (!emo2) emo2 = emo1 + m.reply(mess.wait); + try { + const anu = await fetchJson(`https://tenor.googleapis.com/v2/featured?key=AIzaSyAyimkuYQYF_FXVALexPuGQctUWRURdCYQ&contentfilter=high&media_filter=png_transparent&component=proactive&collection=emoji_kitchen_v5&q=${encodeURIComponent(emo1)}_${encodeURIComponent(emo2)}`) + if (typeof anu.results[0] !== 'object') return m.reply('emoji tidak valid coba ganti emoji') + if (typeof anu.results[0].url !== 'string') return m.reply('emoji tidak valid coba ganti emoji') + const a = await anubis.sendAsSticker(m.chat, anu.results[0].url, m) + fs.unlinkSync(a) + } catch (e) { + console.err(e) + m.reply('command lagi error ngab!') + } + } + break; } } -anuplug.help = ['sticker', 'stickermeme','togif','toimg','topng','tomp4'] +anuplug.help = ['stickermeme','togif','toimg','topng','tomp4','emix'] anuplug.tags = ['sticker'] -anuplug.command = /^(s(ticker|tiker)?(meme)?|to(gif|img|png|mp4))$/i +anuplug.command = /^(s(ticker|tiker)?(meme)|to(gif|img|png|mp4)|emix)$/i +anuplug.isPremium = true \ No newline at end of file diff --git a/plugins/mixstickerfree.js b/plugins/mixstickerfree.js new file mode 100644 index 0000000..1b91a65 --- /dev/null +++ b/plugins/mixstickerfree.js @@ -0,0 +1,75 @@ +/** + * anubisbot-MD https://github.com/anubiskun/anubisbot-MD + * + * Copyright (c) 2022 anubiskun + * https://github.com/anubiskun + */ + +const fs = require('fs') +const Crypto = require("crypto") +const webp = require("node-webpmux") +const path = require("path"); +const { WebpToWebp } = require('../library/converter'); +const { webp2mp4File } = require('../library/upload'); + +module.exports = anuplug = async(m, anubis, { command, usedPrefix }) => { + const mquo = m.quoted || m; + const quoted = mquo.mtype == "buttonsMessage" + ? mquo[Object.keys(mquo)[1]] + : mquo.mtype == "templateMessage" + ? mquo.hydratedTemplate[Object.keys(mquo.hydratedTemplate)[1]] + : mquo.mtype == "product" + ? mquo[Object.keys(mquo)[0]] + : m.quoted + ? m.quoted + : m; + const mime = (quoted.msg || quoted).mimetype || ""; + const qmsg = quoted.msg || quoted; + switch(command){ + case 's': + case 'sticker': + case 'stiker': + { + try { + if (!/(video|image|webp)/.test(mime)) return m.reply(`Kirim/reply gambar/video/gif dengan caption ${usedPrefix + command}\nDurasi Video/Gif 1-9 Detik`); + m.reply(mess.wait); + const tmpFileOut = path.join(__root, `/temp/${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) + let media + try { + let med = await anubis.downloadAndSaveMediaMessage(qmsg); + media = fs.readFileSync(med) + fs.unlinkSync(med); + } catch (e) { + media = await anubis.downloadMediaMessage(qmsg); + } + if (/(video|image)/.test(mime)) media = await WebpToWebp(media) + const img = new webp.Image() + const json = { "sticker-pack-id": Crypto.randomBytes(32).toString('hex'), "sticker-pack-name": global.packname, "sticker-pack-publisher": global.author, "emojis": ["๐Ÿ˜‚"] } + const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]) + const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8") + const exif = Buffer.concat([exifAttr, jsonBuff]) + exif.writeUIntLE(jsonBuff.length, 14, 4) + try { + await img.load(media) + } catch (err) { + let mee = await anubis.downloadAndSaveMediaMessage(qmsg); + let {result} = await webp2mp4File(mee) + let buff = await WebpToWebp(result) + fs.unlinkSync(mee); + await img.load(buff) + } + img.exif = exif + await img.save(tmpFileOut) + await anubis.sendMessage(m.chat, { sticker: { url: tmpFileOut }}, { quoted: m }) + fs.unlinkSync(tmpFileOut); + } catch (err) { + m.reply('error ngab! cba wa ownernya!') + console.err(err) + } + } + break; + } +} +anuplug.help = ['sticker'] +anuplug.tags = ['sticker'] +anuplug.command = /^(s(ticker|tiker)?)$/i \ No newline at end of file diff --git a/plugins/mixtools.js b/plugins/mixtools.js index 489a49e..6e5f665 100644 --- a/plugins/mixtools.js +++ b/plugins/mixtools.js @@ -10,11 +10,8 @@ const axios = require('axios').default const remobg = require("remove.bg"); const isUrl = require('is-url') const util = require('util') -const os = require('os') const { tmpfiles, telegraphUp} = require('../library/upload'); -const speed = require("performance-now"); -const { performance } = require("perf_hooks"); -const { runtime, formatp, shortlink, getRandom, byteToSize } = require('../library/lib') +const { shortlink, getRandom, byteToSize, fetchJson, isNum } = require('../library/lib') const { toAudio, toPTT} = require('../library/converter') const FileType = require('file-type'); const ggleit = 'google-it'; @@ -35,21 +32,6 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) const qmsg = quoted.msg || quoted; const isMedia = /image|video|sticker|audio/.test(mime); switch(command){ - case 'cekexif': - { - m.reply(`๐ŸŒ€> Packname : ${global.packname}\n๐ŸŒ€> Author : ${global.author}`); - } - break; - case 'cl': - case 'changelogs': - { - let cap = '' - for (let i = 0; i < 5; i++){ - cap += require(__root + 'package.json').changeLogs[i] + '\nโ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€\n' - } - m.reply(cap) - } - break; case 'fetch': { if (!isUrl(text)) return m.reply('wajib url direct ngab!') @@ -60,7 +42,7 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) if (res.statusText !== 'OK') return m.reply('wajib url direct ngab!') if (res.headers['content-length'] > 100000000) { delete res - throw `File size terlalu besar ngab!: ${byteToSize(res.headers['content-length'])}` + return m.reply(`File size terlalu besar ngab!: ${byteToSize(res.headers['content-length'])}`) } if (!/text|json/.test(res.headers['content-type'])) { const type = await FileType.fromBuffer(res.data) @@ -93,111 +75,6 @@ module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) } } break; - case 'p': - case 'ping': - { - const used = process.memoryUsage(); - const cpus = os.cpus().map((cpu) => { - cpu.total = Object.keys(cpu.times).reduce( - (last, type) => last + cpu.times[type], - 0 - ); - return cpu; - }); - const cpu = cpus.reduce( - (last, cpu, _, { length }) => { - last.total += cpu.total; - last.speed += cpu.speed / length; - last.times.user += cpu.times.user; - last.times.nice += cpu.times.nice; - last.times.sys += cpu.times.sys; - last.times.idle += cpu.times.idle; - last.times.irq += cpu.times.irq; - return last; - }, - { - speed: 0, - total: 0, - times: { - user: 0, - nice: 0, - sys: 0, - idle: 0, - irq: 0, - }, - } - ); - let timestamp = speed(); - let latensi = speed() - timestamp; - neww = performance.now(); - oldd = performance.now(); -respon = ` -Kecepatan Respon ${latensi.toFixed(4)} _Second_ \n ${ - oldd - neww - } _miliseconds_\n\nRuntime : ${runtime(process.uptime())} - -๐Ÿ’ป Info Server -RAM: ${formatp(os.totalmem() - os.freemem())} / ${formatp(os.totalmem())} - -_NodeJS Memory Usaage_ -${Object.keys(used).map((key, _, arr) => -`${key.padEnd(Math.max(...arr.map((v) => v.length)), " ")}: ${formatp( - used[key] -)}` -) -.join("\n")} - -${ -cpus[0] -? `_Total CPU Usage_ -${cpus[0].model.trim()} (${cpu.speed} MHZ)\n${Object.keys(cpu.times) - .map((type) => - `- *${(type + "*").padEnd(6)}: ${( - (100 * cpu.times[type]) / - cpu.total - ).toFixed(2)}%` - ) - .join("\n")} -_CPU Core(s) Usage (${cpus.length} Core CPU)_ -${cpus -.map((cpu, i) => -`${i + 1}. ${cpu.model.trim()} (${cpu.speed} MHZ)\n${Object.keys( - cpu.times -) - .map((type) => - `- *${(type + "*").padEnd(6)}: ${( - (100 * cpu.times[type]) / - cpu.total - ).toFixed(2)}%` - ) - .join("\n")}` -) -.join("\n\n")}` -: "" -} -`.trim(); - m.reply(respon); - } - break; - case 'rm': - case 'readmore': - { - const more = String.fromCharCode(8206) - const readMore = more.repeat(4001) - if (!text) return m.reply(`Example: ${usedPrefix + command} depan|belakang\n${usedPrefix + command} tau gasi! su|ka-ku ke kamu tu besar banget\nHasil : tau gasi! su${readMore}ka-ku ke kamu tu besar banget`) - let [ d, b ] = text.split('|') - if (!d) d = '' - if (!b) b = '' - m.reply(d + readMore + b) - } - break; - case 'owner': - case 'admin': - case 'sewa': - { - anubis.sendContact(m.chat, global.ownerNum, m); - } - break; case 'shortlink': { if (!isUrl(text)) return m.reply(`*Example* : ${usedPrefix + command} https://google.com`) @@ -222,78 +99,18 @@ ${cpus teks += `โญ” *Description* : ${g.snippet}\n` teks += `โญ” *Link* : ${g.link}\n\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n\n` } - anubis.sendMessage(m.chat, {text: teks}, { quoted: m }); + anubis.sendMessage(m.chat, {text: teks}, { quoted: m }); } catch (err) { console.err(err) return m.reply(`command *${command}* lagi error ngab!`) } } break; - case 'gimage': - { - return m.reply(`command *${command}* lagi error ngab!`) -// if (!text) throw `Example : ${usedPrefix + command} gojo satoru` -// m.reply(mess.wait) -// try { -// const n = await google.image(text, { safe: false }).catch(err => {}) -// images = n[Math.floor(Math.random() * n.length)] -// let buttons = [ -// { -// buttonId: `${usedPrefix + command} ${text}`, -// buttonText: { displayText: "Next Image" }, -// type: 1, -// }, -// ]; -// let buttonMessage = { -// image: { url: images.url }, -// caption: `*-------ใ€Œ GIMAGE SEARCH ใ€-------* -// ๐Ÿค  *Query* : ${text} -// ๐Ÿ”— *Media Url* : ${await shortlink(images.url)} -// โฌ› *Size* : ${images.width}x${images.height}`, -// footer: anuFooter, -// buttons: buttons, -// headerType: 4, -// }; -// anubis.sendMessage(m.chat, buttonMessage, { quoted: m }); -// } catch (err) { -// console.err(err) -// return m.reply(`command *${command}* lagi error ngab!`) -// } - } - break; - case 'gimgrev': - { - return m.reply(`command *${command}* lagi error ngab!`) - // if (!/image/.test(mime) && !isUrl(text)) return m.reply(`Reply gambar yang mau di cari di google ngab!`) - // let qstring = '' - // if (isUrl(text)) qstring = text - // if (/image/.test(mime)) { - // let media = await anubis.downloadAndSaveMediaMessage(qmsg); - // let {url} = await UploadFileUgu(media) - // await fs.unlinkSync(media); - // qstring = url - // } - // m.reply(mess.wait) - // try { - // const {results} = await google.search(qstring, { ris: true }); - // let teks = `Result from Google search by Image :\n\n` - // if (!results) return m.reply('Gambar Tidak di temukan kecocokan ngab!') - // for (let g of results) { - // teks += `โญ” *Title* : ${g.title}\n` - // teks += `โญ” *Description* : ${g.description}\n` - // teks += `โญ” *Link* : ${g.url}\n\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n\n` - // } - // anubis.sendMessage(m.chat, {text: teks}, { quoted: m }); - // } catch (err) { - // console.err(err) - // return m.reply(`command *${command}* lagi error ngab!`) - // } - } - break; case 'rmbg': case 'removebg': { - if (/!(webp|image)/.test(mime)) m.reply(`Kirim/Reply Image/video Dengan Caption ${usedPrefix + command}`) + if (!/(image)/.test(mime)) m.reply(`Kirim/Reply Image Dengan Caption ${usedPrefix + command}`) + if (/(webp)/.test(mime)) m.reply(`Kirim/Reply Image Dengan Caption ${usedPrefix + command}`) try { let apinobg = apirnobg[Math.floor(Math.random() * apirnobg.length)] let localFile = await anubis.downloadAndSaveMediaMessage(qmsg); @@ -302,20 +119,20 @@ ${cpus remobg.removeBackgroundFromImageFile({ path: localFile, apiKey: apinobg, - size: "regular", + size: "full", type: "auto", scale: "100%", outputFile, }).then(async() => { - if (text = 's') { + if (text === 's') { const a = await anubis.sendAsSticker(m.chat, outputFile, m, {packname: global.packname, author: global.author}) - await fs.unlinkSync(a); + fs.unlinkSync(a); } else { anubis.sendMessage(m.chat,{ image: fs.readFileSync(outputFile), caption: mess.success },{ quoted: m }); } - await fs.unlinkSync(localFile); - await fs.unlinkSync(outputFile); - }); + fs.unlinkSync(localFile); + fs.unlinkSync(outputFile); + }).catch(console.err) } catch (err) { console.err(err) m.reply(`command error ngab!`) @@ -377,8 +194,34 @@ ${cpus } } break; + case 'emix2': { + if (!text) return m.reply(`Example: ${usedPrefix + command} ๐Ÿ˜ ๐Ÿ˜ช\nExample: ${usedPrefix + command} ๐Ÿ˜`) + if (/\|/.test(text)) { + args = [] + args.push(text.split('|')[0],text.split('|')[1]) + } + let [emo1, emo2] = args + if (!emo1) return m.reply(`Example: ${usedPrefix + command} ๐Ÿ˜ ๐Ÿ˜ช\nExample: ${usedPrefix + command} ๐Ÿ˜`) + if (!emo2) emo2 = emo1 + const anu = await fetchJson(`https://tenor.googleapis.com/v2/featured?key=AIzaSyAyimkuYQYF_FXVALexPuGQctUWRURdCYQ&contentfilter=high&media_filter=png_transparent&component=proactive&collection=emoji_kitchen_v5&q=${encodeURIComponent(emo1)}_${encodeURIComponent(emo2)}`) + anubis.sendImage(m.chat, anu.results[0].url, await shortlink(anu.results[0].url), m) + } + break; + case 'ttp': { + if (!text) return m.reply(`Example: ${usedPrefix + command} 1/2/3/4/5/6 anubiskun`); + let [ttp, teks] = args + if (!isNum(Number(ttp))) return m.reply(`Example: ${usedPrefix + command} 1/2/3/4/5/6 anubiskun`); + if (ttp === '1') { + ttp = command + } else { + ttp = command + ttp + } + await anubis.sendImage(m.chat, `https://api.lolhuman.xyz/api/${ttp}?apikey=${lolkey}&text=${encodeURIComponent(teks)}`,'', m) + } + break; } } -anuplug.help = ['cekexif','changelogs','ping','readmore','owner','shortlink','google','gimage (error)','gimgrev (error)','removebg','tomp3','tourl','tovn'] +anuplug.help = ['fetch','shortlink','google','removebg','tomp3','tourl','tovn','emix2','ttp'] anuplug.tags = ['tools'] -anuplug.command = /^(cekexif|changelogs|cl|fetch|p(ing)?|rm|readmore|owner|admin|sewa|shortlink|google|gimage|gimgrev|rmbg|removebg|to(mp3|url|vn))$/i \ No newline at end of file +anuplug.command = /^(fetch|shortlink|google|rmbg|removebg|to(mp3|url|vn)|emix2|ttp)$/i +anuplug.isPremium = true \ No newline at end of file diff --git a/plugins/mixtoolsfree.js b/plugins/mixtoolsfree.js new file mode 100644 index 0000000..4e3e8b5 --- /dev/null +++ b/plugins/mixtoolsfree.js @@ -0,0 +1,166 @@ +/** + * anubisbot-MD https://github.com/anubiskun/anubisbot-MD + * + * Copyright (c) 2022 anubiskun + * https://github.com/anubiskun + */ + +const os = require('os') +const speed = require("performance-now"); +const { performance } = require("perf_hooks"); +const { runtime, formatp } = require('../library/lib') + +module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) => { + const mquo = m.quoted || m; + const quoted = mquo.mtype == "buttonsMessage" + ? mquo[Object.keys(mquo)[1]] + : mquo.mtype == "templateMessage" + ? mquo.hydratedTemplate[Object.keys(mquo.hydratedTemplate)[1]] + : mquo.mtype == "product" + ? mquo[Object.keys(mquo)[0]] + : m.quoted + ? m.quoted + : m; + const mime = (quoted.msg || quoted).mimetype || ""; + const qmsg = quoted.msg || quoted; + const isMedia = /image|video|sticker|audio/.test(mime); + switch(command){ + case 'cekexif': + { + m.reply(`๐ŸŒ€> Packname : ${global.packname}\n๐ŸŒ€> Author : ${global.author}`); + } + break; + case 'cl': + case 'changelogs': + { + let cap = '' + for (let i = 0; i < 5; i++){ + cap += require(__root + 'package.json').changeLogs[i] + '\nโ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€\n' + } + m.reply(cap) + } + break; + case 'p': + case 'ping': + { + const used = process.memoryUsage(); + const cpus = os.cpus().map((cpu) => { + cpu.total = Object.keys(cpu.times).reduce( + (last, type) => last + cpu.times[type], + 0 + ); + return cpu; + }); + const cpu = cpus.reduce( + (last, cpu, _, { length }) => { + last.total += cpu.total; + last.speed += cpu.speed / length; + last.times.user += cpu.times.user; + last.times.nice += cpu.times.nice; + last.times.sys += cpu.times.sys; + last.times.idle += cpu.times.idle; + last.times.irq += cpu.times.irq; + return last; + }, + { + speed: 0, + total: 0, + times: { + user: 0, + nice: 0, + sys: 0, + idle: 0, + irq: 0, + }, + } + ); + let timestamp = speed(); + let latensi = speed() - timestamp; + neww = performance.now(); + oldd = performance.now(); +respon = ` +Kecepatan Respon ${latensi.toFixed(4)} _Second_ \n ${ + oldd - neww + } _miliseconds_\n\nRuntime : ${runtime(process.uptime())} + +๐Ÿ’ป Info Server +RAM: ${formatp(os.totalmem() - os.freemem())} / ${formatp(os.totalmem())} + +_NodeJS Memory Usaage_ +${Object.keys(used).map((key, _, arr) => +`${key.padEnd(Math.max(...arr.map((v) => v.length)), " ")}: ${formatp( + used[key] +)}` +) +.join("\n")} + +${ +cpus[0] +? `_Total CPU Usage_ +${cpus[0].model.trim()} (${cpu.speed} MHZ)\n${Object.keys(cpu.times) + .map((type) => + `- *${(type + "*").padEnd(6)}: ${( + (100 * cpu.times[type]) / + cpu.total + ).toFixed(2)}%` + ) + .join("\n")} +_CPU Core(s) Usage (${cpus.length} Core CPU)_ +${cpus +.map((cpu, i) => +`${i + 1}. ${cpu.model.trim()} (${cpu.speed} MHZ)\n${Object.keys( + cpu.times +) + .map((type) => + `- *${(type + "*").padEnd(6)}: ${( + (100 * cpu.times[type]) / + cpu.total + ).toFixed(2)}%` + ) + .join("\n")}` +) +.join("\n\n")}` +: "" +} +`.trim(); + m.reply(respon); + } + break; + case 'rm': + case 'readmore': + { + const more = String.fromCharCode(8206) + const readMore = more.repeat(4001) + if (!text) return m.reply(`Example: ${usedPrefix + command} depan|belakang\n${usedPrefix + command} tau gasi! su|ka-ku ke kamu tu besar banget\nHasil : tau gasi! su${readMore}ka-ku ke kamu tu besar banget`) + let [ d, b ] = text.split('|') + if (!d) d = '' + if (!b) b = '' + m.reply(d + readMore + b) + } + break; + case 'owner': + case 'admin': + case 'sewa': + case 'donate': + { + let pes = '[ SUPPORT anubisbot-MD with DONATE ]\n\n' + pes += '> ovo = 6289653909054\n' + pes += '> dana = 6289653909054\n' + pes += '> gopay = 6289653909054\n' + pes += '> shoppe pay = 6289653909054\n' + pes += '> paypal = (coming soon)\n' + pes += '> saweria = https://saweria.co/anubiskun\n\n' + pes += 'Contact me :' + let a = await m.reply(pes) + if (a.status) anubis.sendContact(m.chat, global.ownerNum, m); + } + break; + case 'limit': { + m.reply((m.isPremium) ? 'anda user premium kami, tidak perlu limit' : `sisa limit anda ${m.limit}`) + } + break; + } +} +anuplug.help = ['cekexif','changelogs','ping','readmore','owner','donate','limit'] +anuplug.tags = ['tools'] +anuplug.command = /^(cekexif|changelogs|cl|p(ing)?|rm|readmore|owner|admin|sewa|donate|limit)$/i \ No newline at end of file diff --git a/plugins/notesGC.js b/plugins/notesGC.js index bf61da7..3b14536 100644 --- a/plugins/notesGC.js +++ b/plugins/notesGC.js @@ -1,46 +1,63 @@ /** * anubisbot-MD https://github.com/anubiskun/anubisbot-MD - * + * * Copyright (c) 2022 anubiskun * https://github.com/anubiskun */ const { getContentType } = require("@adiwajshing/baileys"); -module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix, isAnubis }) => { - switch(command){ - case 'get': - { - if (!text) return m.reply(`Example: ${usedPrefix + command} note name`) - let msgs = anubis.db.data.database[m.chat] - if (!(text.toLowerCase() in msgs)) return m.reply(`lawak bener lu ngab! '${text}' gak ada ngab!`) - if (msgs[text.toLowerCase()].lock && !isAnubis) return m.reply('ga liat itu di lock!') - anubis.copyNForward(m.chat, msgs[text.toLowerCase()].pesan, true); - } - break; - case 'notes': - case 'note': - { - let seplit = Object.entries(anubis.db.data.database[m.chat]).map(([nama, isi]) => { - return { nama, ...isi }; - }) - let teks = "โ”€โ”€โ”€ใ€” NOTE LIST ใ€•โ”€โ”€โ”€\n"; - for (let i of seplit) { - let kunci - if (i.lock) { - kunci = '๐Ÿ”’' - } else { - kunci = '' - } - teks += `> ${i.nama} (${getContentType(i.pesan.message).replace(/Message/i, "")}) ${kunci}\n`; - } - teks += `โ”€โ”€โ”€ใ€” NOTE LIST ใ€•โ”€โ”€โ”€\n\nGunakan command ${usedPrefix}get namanotenya\nEx: ${usedPrefix}get test` - m.reply(teks); - } - break; - } -} -anuplug.help = ['get','notes','note'] -anuplug.tags = ['group'] -anuplug.command = /^(get|notes|note)$/i -anuplug.group = true \ No newline at end of file +module.exports = anuplug = async ( + m, + anubis, + { text, body, command, args, usedPrefix, isAnubis } +) => { + switch (command) { + case "get": + { + if (!text) return m.reply(`Example: ${usedPrefix + command} note name`); + let msgs = anubis.db.data.database.note[m.chat]; + if (!(text.toLowerCase() in msgs)) + return m.reply(`lawak bener lu ngab! '${text}' gak ada ngab!`); + if (msgs[text.toLowerCase()].lock && !isAnubis) + return m.reply("ga liat itu di lock!"); + anubis.copyNForward(m.chat, msgs[text.toLowerCase()].pesan, true); + } + break; + case "notes": + case "note": + { + let seplit = Object.entries(anubis.db.data.database.note[m.chat]) + .map(([nama, isi]) => { + return { nama, ...isi }; + }) + .sort(function (a, b) { + let nama1 = a.nama.toUpperCase(); + let nama2 = b.nama.toUpperCase(); + if (nama1 < nama2) return -1; + if (nama1 > nama2) return 1; + return 0; + }); + let teks = "โ”€โ”€โ”€ใ€” NOTE LIST ใ€•โ”€โ”€โ”€\n"; + for (let i of seplit) { + let kunci; + if (i.lock) { + kunci = "๐Ÿ”’"; + } else { + kunci = ""; + } + teks += `> ${i.nama} (${getContentType(i.pesan.message).replace( + /Message/i, + "" + )}) ${kunci}\n`; + } + teks += `โ”€โ”€โ”€ใ€” NOTE LIST ใ€•โ”€โ”€โ”€\n\nGunakan command ${usedPrefix}get namanotenya\nEx: ${usedPrefix}get test`; + m.reply(teks); + } + break; + } +}; +anuplug.help = ["get", "notes", "note"]; +anuplug.tags = ["group"]; +anuplug.command = /^(get|notes|note)$/i; +anuplug.group = true; diff --git a/plugins/template.js b/plugins/template.js index cf69f7c..6d77f2e 100644 --- a/plugins/template.js +++ b/plugins/template.js @@ -5,18 +5,19 @@ * https://github.com/anubiskun */ -// module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) => { -// console.log(command) -// console.log(text) -// console.log(args) -// console.log(usedPrefix) -// m.reply(command) -// } -// anuplug.help = ['testing'] -// anuplug.tags = ['test'] -// anuplug.command = /^test(ing)?$/i -// anuplug.isAnubis = true -// anuplug.disabled = true -// anuplug.group = true -// anuplug.botAdmin = true -// anuplug.admin = true + module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) => { + console.log(command) + console.log(text) + console.log(args) + console.log(usedPrefix) + m.reply(command) +} +anuplug.help = ['template'] +anuplug.tags = ['template'] +anuplug.command = /^(template)$/i +anuplug.isAnubis = true +anuplug.disabled = true +anuplug.group = true +anuplug.botAdmin = true +anuplug.admin = true +anuplug.isPremium = true diff --git a/plugins/ytdl.js b/plugins/ytdl.js index fb573d2..3660d31 100644 --- a/plugins/ytdl.js +++ b/plugins/ytdl.js @@ -1,88 +1,186 @@ /** * anubisbot-MD https://github.com/anubiskun/anubisbot-MD - * + * * Copyright (c) 2022 anubiskun * https://github.com/anubiskun */ -const { y2mate, y2mateConvert, shortlink } = require("../library/lib") -const isUrl = require("is-url") +const { y2mate, y2mateConvert, shortlink } = require("../library/lib"); +const isUrl = require("is-url"); -module.exports = anuplug = async(m, anubis, { text, command, args, usedPrefix }) => { - if (!text) return m.reply(`Example : ${usedPrefix + command} https://youtube.com/watch?v=PtFMh6Tccag`) - switch(command){ - case 'ytdl': - case 'ytdla': - case 'ytdlv': +module.exports = anuplug = async ( + m, + anubis, + { text, command, args, usedPrefix } +) => { + if (!text) + return m.reply( + `Example : ${ + usedPrefix + command + } https://youtube.com/watch?v=PtFMh6Tccag` + ); + switch (command) { + case "ytdl": + case "ytdla": + case "ytdlv": { - m.reply(mess.wait) + m.reply(mess.wait); try { - if (!isUrl(text)) return m.reply(`Example : ${usedPrefix + command} https://youtube.com/watch?v=PtFMh6Tccag`) - const ytdl = await y2mate(text) - if (!ytdl.status) return m.reply('Coba cek urlnya ngab!') - - let rowsmp3 = [] + if (!isUrl(text)) + return m.reply( + `Example : ${ + usedPrefix + command + } https://youtube.com/watch?v=PtFMh6Tccag` + ); + const ytdl = await y2mate(text); + if (!ytdl.status) return m.reply("Coba cek urlnya ngab!"); + + let rowsmp3 = []; ytdl.audio.splice(ytdl.audio.length, ytdl.audio.length); ytdl.audio.forEach((anu, i) => { - rowsmp3.push({title: anu.resText, description: `*Title*: ${anu.title}\n*Size*: ${anu.size}`, rowId: `${usedPrefix}getytdl ${JSON.stringify(anu)}`}) + rowsmp3.push({ + title: anu.resText, + description: `*Title*: ${anu.title}\n*Size*: ${anu.size}`, + rowId: `${usedPrefix}getytdl ${encodeURIComponent( + JSON.stringify(anu) + )}`, + }); }); let secsmp3 = [ { - title: 'Audio Downloader', - rows: rowsmp3 - } - ] - - let rowsmp4 = [] + title: "Audio Downloader", + rows: rowsmp3, + }, + ]; + + let rowsmp4 = []; ytdl.video.splice(ytdl.video.length, ytdl.video.length); ytdl.video.forEach((anu, i) => { - rowsmp4.push({title: anu.resText, description: `*Title*: ${anu.title}\n*Size*: ${anu.size}`, rowId: `${usedPrefix}getytdl ${JSON.stringify(anu)}`}) + rowsmp4.push({ + title: anu.resText, + description: `*Title*: ${anu.title}\n*Size*: ${anu.size}`, + rowId: `${usedPrefix}getytdl ${encodeURIComponent( + JSON.stringify(anu) + )}`, + }); }); let secsmp4 = [ { - title: 'Video Downloader', - rows: rowsmp4 - } - ] - if (command == 'ytdla'){ - return anubis.sendList(m.chat, 'MENU', `[ YOUTUBE DL MP3 ]\n*Recommend pilih yang 128k*\n\nTitle: ${ytdl.title}\nDurasi: ${ytdl.duration}`, 'MENU', secsmp3, m) - } else if (command == 'ytdlv'){ - return anubis.sendList(m.chat, 'MENU', `[ YOUTUBE DL MP4 ]\n*Recommend pilih yang 360p*\n\nTitle: ${ytdl.title}\nDurasi: ${ytdl.duration}`, 'MENU', secsmp4, m) - } else if (command == 'ytdl') { - anubis.sendList(m.chat, 'MENU', `[ YOUTUBE DL MP3 ]\n*Recommend pilih yang 128k*\n\nTitle: ${ytdl.title}\nDurasi: ${ytdl.duration}`, 'MENU', secsmp3, m) - anubis.sendList(m.chat, 'MENU', `[ YOUTUBE DL MP4 ]\n*Recommend pilih yang 360p*\n\nTitle: ${ytdl.title}\nDurasi: ${ytdl.duration}`, 'MENU', secsmp4, m) - return + title: "Video Downloader", + rows: rowsmp4, + }, + ]; + if (command == "ytdla") { + return anubis.sendList( + m.chat, + "MENU", + `[ YOUTUBE DL MP3 ]\n*Recommend pilih yang 128k*\n\nTitle: ${ytdl.title}\nDurasi: ${ytdl.duration}`, + "MENU", + secsmp3, + m + ); + } else if (command == "ytdlv") { + return anubis.sendList( + m.chat, + "MENU", + `[ YOUTUBE DL MP4 ]\n*Recommend pilih yang 360p*\n\nTitle: ${ytdl.title}\nDurasi: ${ytdl.duration}`, + "MENU", + secsmp4, + m + ); + } else if (command == "ytdl") { + anubis.sendList( + m.chat, + "MENU", + `[ YOUTUBE DL MP3 ]\n*Recommend pilih yang 128k*\n\nTitle: ${ytdl.title}\nDurasi: ${ytdl.duration}`, + "MENU", + secsmp3, + m + ); + anubis.sendList( + m.chat, + "MENU", + `[ YOUTUBE DL MP4 ]\n*Recommend pilih yang 360p*\n\nTitle: ${ytdl.title}\nDurasi: ${ytdl.duration}`, + "MENU", + secsmp4, + m + ); + return; } else { - return m.reply('mau ngapain ngab!?') + return m.reply("mau ngapain ngab!?"); } } catch (err) { - console.err(err) - m.reply('error ngab! coba contact owner!') + console.err(err); + m.reply("error ngab! coba contact owner!"); } } - break; - case 'getytdl': + break; + case "getytdl": { - const media = JSON.parse(text) - const {url} = await y2mateConvert(media.id, media.ytid, media.type, media.quality) - if (typeof url == 'undefined') return m.reply('Download Error ngab! Coba contact Owner!') - m.reply(mess.wait) + const media = JSON.parse(decodeURIComponent(text)); + let { url } = await y2mateConvert( + media.id, + media.ytid, + media.type, + media.quality + ); + if (!isUrl(url)) + return m.reply("Download Error ngab! Coba contact Owner!"); + url = url.replace("https", "http"); + // m.reply(mess.wait) + m.reply(`Mengirim media size:` + media.size); try { - if (media.sizeByte >= 100000000) return anubis.sendImage(m.chat,media.thumb,`*FILE MELEBIHI BATAS SILAHKAN GUNAKAN LINK*\n\n*Title* : ${media.title}\n*File Size* : ${media.size}\n*Likes* : ${media.likes}\n*Dislike* : ${media.dislikes}\n*Rating* : ${media.rating}\n*Views* : ${media.viewCount}\n*Ext* : ${media.type}\n*Quality* : ${media.quality}\n*Link* : ${await shortlink(url)}`, m); - if (media.type == 'mp3') { - anubis.sendImage(m.chat, media.thumb, `*[ YOUTUBE MP3 DOWNLOADER v2 ]*\n\n*Title* : ${media.title}\n*File Size* : ${media.size}\n*Likes* : ${media.likes}\n*Dislike* : ${media.dislikes}\n*Rating* : ${media.rating}\n*Views* : ${media.viewCount}\n*Ext* : ${media.type}\n*Quality* : ${media.quality}`, m); - anubis.sendMessage(m.chat,{audio: { url: url },mimetype: "audio/mpeg",fileName: `${media.title}.mp3`},{ quoted: m }); + if (media.sizeByte >= 100000000) + return anubis.sendImage( + m.chat, + media.thumb, + `*FILE MELEBIHI BATAS SILAHKAN GUNAKAN LINK*\n\n*Title* : ${ + media.title + }\n*File Size* : ${media.size}\n*Likes* : ${ + media.likes + }\n*Dislike* : ${media.dislikes}\n*Rating* : ${ + media.rating + }\n*Views* : ${media.viewCount}\n*Ext* : ${ + media.type + }\n*Quality* : ${media.quality}\n*Link* : ${await shortlink( + url + )}`, + m + ); + if (media.type == "mp3") { + anubis.sendImage( + m.chat, + media.thumb, + `*[ YOUTUBE MP3 DOWNLOADER v2 ]*\n\n*Title* : ${media.title}\n*File Size* : ${media.size}\n*Likes* : ${media.likes}\n*Dislike* : ${media.dislikes}\n*Rating* : ${media.rating}\n*Views* : ${media.viewCount}\n*Ext* : ${media.type}\n*Quality* : ${media.quality}`, + m + ); + anubis.sendMessage( + m.chat, + { + audio: { url: url }, + mimetype: "audio/mpeg", + fileName: `${media.title}.mp3`, + }, + { quoted: m } + ); } else { - anubis.sendMessage(m.chat,{video: { url: url },mimetype: "video/mp4",fileName: `${media.title}.mp4`,caption: `*[ YOUTUBE MP4 DOWNLOADER v2 ]*\n\n*Title* : ${media.title}\n*File Size* : ${media.size}\n*Likes* : ${media.likes}\n*Dislike* : ${media.dislikes}\n*Rating* : ${media.rating}\n*Views* : ${media.viewCount}\n*Ext* : ${media.type}\n*Quality* : ${media.quality}`},{ quoted: m }) + anubis.sendVideo( + m.chat, + url, + `*[ YOUTUBE MP4 DOWNLOADER v2 ]*\n\n*Title* : ${media.title}\n*File Size* : ${media.size}\n*Likes* : ${media.likes}\n*Dislike* : ${media.dislikes}\n*Rating* : ${media.rating}\n*Views* : ${media.viewCount}\n*Ext* : ${media.type}\n*Quality* : ${media.quality}`, + m, + media.thumb + ); } } catch (err) { - console.err(err) - m.reply('command lagi error ngab!') + console.err(err); + m.reply("command lagi error ngab!"); } } - break; + break; } -} -anuplug.help = ['ytdl'] -anuplug.tags = ['downloader'] -anuplug.command = /^(ytdl(a|v)?|getytdl)$/i \ No newline at end of file +}; +anuplug.help = ["ytdl"]; +anuplug.tags = ["downloader"]; +anuplug.command = /^(ytdl(a|v)?|getytdl)$/i; +anuplug.isPremium = true;