diff --git a/plugins/Quran-surah.js b/plugins/Quran-surah.js index e82834f..57c4433 100644 --- a/plugins/Quran-surah.js +++ b/plugins/Quran-surah.js @@ -1,7 +1,7 @@ import fetch from 'node-fetch'; import { translate } from '@vitalets/google-translate-api'; -let Handler = async (m, { conn }) => { +let quranSurahHandler = async (m, { conn }) => { try { // Extract the surah number or name from the command text. let surahInput = m.text.split(' ')[1]; @@ -59,13 +59,13 @@ ${translatedTafsirEnglish.text}`; } }; -Handler.help = ['quran [surah_number|surah_name]']; -Handler.tags = ['quran', 'surah']; -Handler.command = ['quran', 'surah'] +quranSurahHandler.help = ['quran [surah_number|surah_name]']; +quranSurahHandler.tags = ['quran', 'surah']; +quranSurahHandler.command = ['quran', 'surah'] -export default Handler; +export default quranSurahHandler; - \ No newline at end of file + diff --git a/plugins/Tools-animeinfo.js b/plugins/Tools-animeinfo.js new file mode 100644 index 0000000..e6504d6 --- /dev/null +++ b/plugins/Tools-animeinfo.js @@ -0,0 +1,40 @@ +import translate from '@vitalets/google-translate-api'; +import { Anime } from '@shineiichijo/marika'; + +const client = new Anime(); + +let handler = async (m, { conn, text, usedPrefix }) => { + if (!text) return m.reply(`*[❗] Please enter the name of an anime to search for.*`); + try { + let anime = await client.searchAnime(text); + let result = anime.data[0]; + let resultes = await translate(`${result.background}`, { to: 'en', autoCorrect: true }); + let resultes2 = await translate(`${result.synopsis}`, { to: 'hi', autoCorrect: true }); + let AnimeInfo = ` +πŸŽ€ β€’ *Title:* ${result.title} +πŸŽ‹ β€’ *Format:* ${result.type} +πŸ“ˆ β€’ *Status:* ${result.status.toUpperCase().replace(/\_/g, ' ')} +πŸ₯ β€’ *Total Episodes:* ${result.episodes} +🎈 β€’ *Duration: ${result.duration}* +✨ β€’ *Based on:* ${result.source.toUpperCase()} +πŸ’« β€’ *Released:* ${result.aired.from} +πŸŽ— β€’ *Finished:* ${result.aired.to} +🎐 β€’ *Popularity:* ${result.popularity} +🎏 β€’ *Favorites:* ${result.favorites} +πŸŽ‡ β€’ *Rating:* ${result.rating} +πŸ… β€’ *Rank:* ${result.rank} +♦ β€’ *Trailer:* ${result.trailer.url} +🌐 β€’ *URL:* ${result.url} +πŸŽ† β€’ *Background:* ${resultes.text} +❄ β€’ *Synopsis:* ${resultes2.text}`; + + conn.sendFile(m.chat, result.images.jpg.image_url, 'error.jpg', AnimeInfo, m); + } catch { + throw `*[❗] ERROR, please try again.*`; + } +}; + +handler.help = ['anime'] +handler.tags = ['anime'] +handler.command = /^(anime|animeinfo)$/i; +export default handler; diff --git a/plugins/owner.banlist.js b/plugins/owner.banlist.js new file mode 100644 index 0000000..55cbbd0 --- /dev/null +++ b/plugins/owner.banlist.js @@ -0,0 +1,21 @@ + +let handler = async (m, { conn, usedPrefix }) => { + let chats = Object.entries(global.db.data.chats).filter(chat => chat[1].isBanned) + let users = Object.entries(global.db.data.users).filter(user => user[1].banned) + + m.reply(` +≑ *USERS BANNED* + +β–’ Total : *${users.length}* + +${users ? '\n' + users.map(([jid], i) => ` +${i + 1}. ${conn.getName(jid) == undefined ? 'UNKNOWN' : conn.getName(jid)} +β–’ ${jid} +`.trim()).join('\n') : ''} +`.trim()) +} +handler.help = ['listban'] +handler.tags = ['owner'] +handler.command = ['banlist', 'listban'] + +export default handler \ No newline at end of file diff --git a/plugins/plugin-all.js b/plugins/plugin-all.js new file mode 100644 index 0000000..d328b2e --- /dev/null +++ b/plugins/plugin-all.js @@ -0,0 +1 @@ +const _0x28cbbe=_0x5ef2;(function(_0xe7b3dc,_0x59b964){const _0x4124c9=_0x5ef2,_0x5383a3=_0xe7b3dc();while(!![]){try{const _0xd1587c=-parseInt(_0x4124c9(0x8f))/0x1*(parseInt(_0x4124c9(0x94))/0x2)+parseInt(_0x4124c9(0x90))/0x3+parseInt(_0x4124c9(0x88))/0x4+-parseInt(_0x4124c9(0x89))/0x5+parseInt(_0x4124c9(0x8d))/0x6+parseInt(_0x4124c9(0x95))/0x7+parseInt(_0x4124c9(0x8c))/0x8*(parseInt(_0x4124c9(0x92))/0x9);if(_0xd1587c===_0x59b964)break;else _0x5383a3['push'](_0x5383a3['shift']());}catch(_0x1ebe99){_0x5383a3['push'](_0x5383a3['shift']());}}}(_0x2d7d,0x1f30f));import _0xd0a7ce from'fs';import _0x139640 from'node-fetch';let handler=async(_0xf3422e,{conn:_0x39ec1b,usedPrefix:_0x9b34e6})=>{const _0xa73417=_0x5ef2;let _0x1cd378=_0xa73417(0x8b),_0x361376=_0xa73417(0x93);await _0x39ec1b['reply'](_0xf3422e[_0xa73417(0x8e)],_0x361376,_0xf3422e,{'contextInfo':{'mentionedJid':[_0xf3422e['sender']],'forwardingScore':0x100,'isForwarded':!![],'externalAdReply':{'title':_0xa73417(0x87),'body':botname,'sourceUrl':'https://github.com/Guru322/EXTERNAL-PLUGINS','thumbnailUrl':_0x1cd378,'mediaType':0x1,'renderLargerThumbnail':![]}}});};handler[_0x28cbbe(0x96)]=['plugins'],handler[_0x28cbbe(0x8a)]=['plugin'],handler[_0x28cbbe(0x91)]=/^plugins$/i;export default handler;function _0x5ef2(_0x41a436,_0x1a3e2f){const _0x2d7d30=_0x2d7d();return _0x5ef2=function(_0x5ef236,_0x112fa7){_0x5ef236=_0x5ef236-0x87;let _0x1e94e8=_0x2d7d30[_0x5ef236];return _0x1e94e8;},_0x5ef2(_0x41a436,_0x1a3e2f);}function _0x2d7d(){const _0x587392=['192376EkMnyF','109920WQCeKA','chat','1eaWMKv','138900SoPaMU','command','18WIBnHw','*GURU\x20BOT\x20EXTERNAL\x20PLUGINS*\x20\x0a\x0ahttps://github.com/Guru322/EXTERNAL-PLUGINS','286610EXPZvD','252588xRdLJE','help','EXTERNAL\x20PLUGINS','836852ycPSaP','434735OZrKoh','tags','https://techlogitic.net/wp-content/uploads/2022/08/itachi-pfp-4k.jpg'];_0x2d7d=function(){return _0x587392;};return _0x2d7d();} \ No newline at end of file diff --git a/plugins/plugin-install.js b/plugins/plugin-install.js new file mode 100644 index 0000000..7aa5841 --- /dev/null +++ b/plugins/plugin-install.js @@ -0,0 +1,47 @@ +import axios from 'axios'; +import fs from 'fs'; +import path from 'path'; + +let handler = async (m, { text, usedPrefix, command }) => { + if (!text) throw `Please provide a plugin URL`; + + // Extract the Gist ID from the URL + const gistId = text.match(/(?:\/|gist\.github\.com\/)([a-fA-F0-9]+)/); + + + if (!gistId) throw `Invalid plugin URL`; + + const gistName = gistId[1]; + const gistURL = `https://api.github.com/gists/${gistName}`; + + try { + const response = await axios.get(gistURL); + const gistData = response.data; + + if (!gistData || !gistData.files) { + throw `No valid files found in the Gist`; + } + + for (const file of Object.values(gistData.files)) { + // Use the Gist file name as the plugin name + const pluginName = file.filename; + + // Construct the path to save the plugin + const pluginPath = path.join('plugins', `${pluginName}`); + + // Write the Gist file content to the plugin file + await fs.promises.writeFile(pluginPath, file.content); + m.reply(`successfully installed the plugin to Guru Bot`); + } + } catch (error) { + throw `Error fetching or saving the plugin: ${error.message}`; + } +}; + +handler.help = ['install'].map((v) => v + ' '); +handler.tags = ['plugin']; +handler.command = /^install$/i; + +handler.owner = true; + +export default handler; diff --git a/plugins/plugin-remove.js b/plugins/plugin-remove.js new file mode 100644 index 0000000..e76debd --- /dev/null +++ b/plugins/plugin-remove.js @@ -0,0 +1,36 @@ +//https://github.com/Fabri115/botwhaita/blob/main/plugins/OWNER_deleteplugin.js + +import { tmpdir } from 'os'; +import path, { join } from 'path'; +import { + readdirSync, + statSync, + unlinkSync, + existsSync, + readFileSync, + watch, +} from 'fs'; + +const handler = async (m, { conn, usedPrefix: _p, __dirname, args, text }) => { + const ar = Object.keys(plugins); + const ar1 = ar.map((v) => v.replace('.js', '')); + + if (!text) throw `πŸ“Œ *_Example usage:_*\n*#deleteplugin main-menu*`; + + if (!ar1.includes(args[0])) { + return m.reply(`*πŸ—ƒοΈ This plugin doesn't exist!*` + + `\nβ€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’\n\n${ar1.map((v) => ' ' + v).join(`\n`)}`); + } + + const file = join(__dirname, '../plugins/' + args[0] + '.js'); + unlinkSync(file); + conn.reply(m.chat, `⚠️ *_The "plugins/${args[0]}.js" plugin has been deleted._*`, m); +}; + +handler.help = ['deleteplugin ']; +handler.tags = ['owner']; +handler.command = /^(deleteplugin|dp|remove)$/i; + +handler.owner = true; + +export default handler; diff --git a/plugins/rg-register.js b/plugins/rg-register.js new file mode 100644 index 0000000..70961bb --- /dev/null +++ b/plugins/rg-register.js @@ -0,0 +1,39 @@ +//import db from '../lib/database.js' + +import { createHash } from 'crypto' +let Reg = /\|?(.*)([.|] *?)([0-9]*)$/i +let handler = async function (m, { conn, text, usedPrefix, command }) { + let user = global.db.data.users[m.sender] + let name2 = conn.getName(m.sender) + if (user.registered === true) throw `✳️ You are already registered\n\nDo you want to re-register?\n\n πŸ“Œ Use this command to remove your record \n*${usedPrefix}unreg* ` + if (!Reg.test(text)) throw `⚠️ Format incorrect\n\n ✳️ Use this command: *${usedPrefix + command} name.age*\nπŸ“ŒExemple : *${usedPrefix + command}* ${name2}.16` + let [_, name, splitter, age] = text.match(Reg) + if (!name) throw '✳️ The name cannot be empty' + if (!age) throw '✳️ age cannot be empty' + if (name.length >= 30) throw '✳️The name is too long' + age = parseInt(age) + if (age > 100) throw 'πŸ‘΄πŸ» Wow grandpa wants to play bot' + if (age < 5) throw '🚼 there is a grandpa baby jsjsj ' + user.name = name.trim() + user.age = age + user.regTime = + new Date + user.registered = true + let sn = createHash('md5').update(m.sender).digest('hex') + m.reply(` +β”Œβ”€γ€Œ *REGISTERED* 」─ +β–’ *NUMBER:* ${name} +β–’ *AGE* : ${age} years +β–’ *SERIEL NUMBER* : +${sn} +└────────────── + + *${usedPrefix}help* to see menu +`.trim()) +} +handler.help = ['reg'].map(v => v + ' ') +handler.tags = ['rg'] + +handler.command = ['verify', 'reg', 'register', 'registrar'] + +export default handler + diff --git a/plugins/rg-sn.js b/plugins/rg-sn.js new file mode 100644 index 0000000..878ed96 --- /dev/null +++ b/plugins/rg-sn.js @@ -0,0 +1,13 @@ +import { createHash } from 'crypto' + +let handler = async function (m, { conn, text, usedPrefix }) { +let sn = createHash('md5').update(m.sender).digest('hex') +m.reply(` +β–’ *seriel number* : ${sn} +`.trim()) +} +handler.help = ['mysn'] +handler.tags = ['rg'] +handler.command = ['nserie', 'sn', 'mysn'] +handler.register = true +export default handler diff --git a/plugins/rg-unreg.js b/plugins/rg-unreg.js new file mode 100644 index 0000000..ac5c435 --- /dev/null +++ b/plugins/rg-unreg.js @@ -0,0 +1,19 @@ +//import db from '../lib/database.js' + +import { createHash } from 'crypto' +let handler = async function (m, { conn, args, usedPrefix}) { + if (!args[0]) throw `✳️ *Enter serial number*\nCheck your serial number with the command...\n\n*${usedPrefix}nserie*` + let user = global.db.data.users[m.sender] + let sn = createHash('md5').update(m.sender).digest('hex') + if (args[0] !== sn) throw '⚠️ *Incorrect serial number*' + user.registered = false + m.reply(`βœ… Register eliminated`) +} +handler.help = ['unreg '] +handler.tags = ['rg'] + +handler.command = ['unreg'] +handler.register = true + +export default handler + diff --git a/plugins/sticker-emojimix.js b/plugins/sticker-emojimix.js new file mode 100644 index 0000000..c5dfde5 --- /dev/null +++ b/plugins/sticker-emojimix.js @@ -0,0 +1,31 @@ + +import fetch from 'node-fetch' +import { sticker } from '../lib/sticker.js' + +const fetchJson = (url, options) => new Promise(async (resolve, reject) => { +fetch(url, options) +.then(response => response.json()) +.then(json => { +resolve(json) +}) +.catch((err) => { +reject(err) +})}) + +let handler = async (m, { conn, text, args, usedPrefix, command }) => { + +if (!args[0]) throw `πŸ“Œ Example : ${usedPrefix + command} 😎+πŸ€‘` +if (!text.includes('+')) throw `✳️ Separate the emoji with a *+* \n\nπŸ“Œ Example : \n*${usedPrefix + command}* 😎+πŸ€‘` +let [emoji, emoji2] = text.split`+` +let 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(emoji)}_${encodeURIComponent(emoji2)}`) +for (let res of anu.results) { +let stiker = await sticker(false, res.url, global.packname, global.author) +conn.sendFile(m.chat, stiker, null, { asSticker: true }, m) +}} + +handler.help = ['emojimix '] +handler.tags = ['sticker'] +handler.command = ['emojimix'] +handler.diamond = true + +export default handler diff --git a/plugins/sticker-getsticker.js b/plugins/sticker-getsticker.js new file mode 100644 index 0000000..de7904a --- /dev/null +++ b/plugins/sticker-getsticker.js @@ -0,0 +1,35 @@ + +import fg from 'api-dylux' +import fetch from 'node-fetch' +import { sticker } from '../lib/sticker.js' +let handler = async (m, { conn, args, text, usedPrefix, command }) => { + if (!args[0]) throw `✳️ enter what you want to search \n\nπŸ“Œ*Example:*\n${usedPrefix + command} homero` + + //Result https://getstickerpack.com/ + try { + /*let res = await fetch(global.API('fgmods', '/api/getsticker', { q:text }, 'apikey')) + let json = await res.json()*/ + let json = await fg.StickerSearch(text) + m.reply(` +βœ… Result + +β–’ *Title:* ${json.title} +β–’ *Total stickers:* ${json.sticker_url.length} +β–’ *Estimated shipping time:* _*${json.sticker_url.length * 2} s*_`) + for (let i of json.sticker_url) { + const stiker = await sticker(false, i, global.packname, global.author) + await conn.sendFile(m.chat, stiker, 'sticker.webp', '', m) + //await delay(1500) + } + } catch (e) { + m.reply(`❇️ Error: try another`) + } +} +handler.help = ['getsticker'] +handler.tags = ['sticker'] +handler.command = ['getsticker', 'getstick', 'stickersearch', 'sticksearch'] +handler.diamond = false + +export default handler + +const delay = time => new Promise(res => setTimeout(res, time)) diff --git a/plugins/sticker-scircle.js b/plugins/sticker-scircle.js new file mode 100644 index 0000000..90b7452 --- /dev/null +++ b/plugins/sticker-scircle.js @@ -0,0 +1,17 @@ +import uploadImage from '../lib/uploadImage.js' +import { sticker } from '../lib/sticker.js' +let handler = async (m, { conn, text }) => { +try { +let q = m.quoted ? m.quoted : m +let mime = (q.msg || q).mimetype || '' +let img = await q.download() +let url = await uploadImage(img) +let scircle = global.API('dzx', '/api/canvas/circle', { url }) +let stiker = await sticker(null, scircle, global.packname, global.author) +conn.sendFile(m.chat, stiker, 'sticker.webp', '', m, { asSticker: true }) +} catch (e) { +m.reply('*[β—πˆππ…πŽβ—] respond to a image to make it circle sticker*') +}} +handler.command = /^scircle|circle$/i +export default handler +/* `https://api.dhamzxploit.my.id/api/canvas/circle?url=${url}` */ diff --git a/plugins/sticker-smaker.js b/plugins/sticker-smaker.js new file mode 100644 index 0000000..ee083df --- /dev/null +++ b/plugins/sticker-smaker.js @@ -0,0 +1,38 @@ +import uploadImage from '../lib/uploadImage.js' +import { sticker } from '../lib/sticker.js' + +const effects = ['jail', 'gay', 'glass', 'wasted' ,'triggered', 'lolice', 'simpcard', 'horny'] + +let handler = async (m, { conn, usedPrefix, text, command }) => { +let effect = text.trim().toLowerCase() +if (!effects.includes(effect)) throw ` + +β”Œβ”€βŠ· *EFFECTS* +${effects.map(effect => `β–’ ${effect}`).join('\n')} +└─────────── + +πŸ“Œ *Example:* +${usedPrefix + command} wasted +`.trim() +let q = m.quoted ? m.quoted : m +let mime = (q.msg || q).mimetype || '' +if (!mime) throw '✳️ Respond to an image' +if (!/image\/(jpe?g|png)/.test(mime)) throw `✳️ Format not supported` +let img = await q.download() +let url = await uploadImage(img) +let apiUrl = global.API('https://some-random-api.com/canvas/', encodeURIComponent(effect), { +avatar: url +}) +try { +let stiker = await sticker(null, apiUrl, global.packname, global.author) +conn.sendFile(m.chat, stiker, null, { asSticker: true }, m) +} catch (e) { +m.reply('Conversion to sticker error, send as image instead') +await conn.sendFile(m.chat, apiUrl, 'smaker.png', null, m) +}} +handler.help = ['smaker'] +handler.tags = ['sticker'] +handler.command = ['stickmaker', 'stickermaker', 'smaker'] +handler.diamond = false + +export default handler diff --git a/plugins/sticker-sticker.js b/plugins/sticker-sticker.js new file mode 100644 index 0000000..5ca4d36 --- /dev/null +++ b/plugins/sticker-sticker.js @@ -0,0 +1,78 @@ +import fetch from 'node-fetch' +import { addExif } from '../lib/sticker.js' +import { Sticker } from 'wa-sticker-formatter' +let handler = async (m, { conn, args, usedPrefix, command }) => { +let stiker = false +try { +let [packname, ...author] = args.join` `.split`|` +author = (author || []).join`|` +let q = m.quoted ? m.quoted : m +let mime = (q.msg || q).mimetype || q.mediaType || '' +if (/webp/g.test(mime)) { +let img = await q.download?.() +stiker = await addExif(img, packname || global.packname, author || global.author) +} else if (/image/g.test(mime)) { +let img = await q.download?.() +stiker = await createSticker(img, false, packname || global.packname, author || global.author) +} else if (/video/g.test(mime)) { +let img = await q.download?.() +stiker = await mp4ToWebp(img, { pack: packname || global.packname, author: author || global.author }) +} else if (args[0] && isUrl(args[0])) { +stiker = await createSticker(false, args[0], '', author, 20) +} else throw `*RESPOND TO A IMAGE OR VIDEO OR GIF ${usedPrefix + command}*` +} catch { +stiker = '*huh*' +} finally { +m.reply(stiker)}} +handler.help = ['sfull'] +handler.tags = ['sticker'] +handler.command = /^s(tic?ker)?(gif)?(wm)?$/i +export default handler +const isUrl = (text) => text.match(new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)(jpe?g|gif|png)/, 'gi')) +async function createSticker(img, url, packName, authorName, quality) { +let stickerMetadata = { type: 'full', pack: packName, author: authorName, quality } +return (new Sticker(img ? img : url, stickerMetadata)).toBuffer()} +async function mp4ToWebp(file, stickerMetadata) { +if (stickerMetadata) { +if (!stickerMetadata.pack) stickerMetadata.pack = 'β€Ž' +if (!stickerMetadata.author) stickerMetadata.author = 'β€Ž' +if (!stickerMetadata.crop) stickerMetadata.crop = false +} else if (!stickerMetadata) { stickerMetadata = { pack: 'β€Ž', author: 'β€Ž', crop: false }} +let getBase64 = file.toString('base64') +const Format = { file: `data:video/mp4;base64,${getBase64}`, processOptions: { crop: stickerMetadata?.crop, startTime: '00:00:00.0', endTime: '00:00:7.0', loop: 0 +}, stickerMetadata: { ...stickerMetadata }, +sessionInfo: { +WA_VERSION: '2.2106.5', +PAGE_UA: 'WhatsApp/2.2037.6 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36', +WA_AUTOMATE_VERSION: '3.6.10 UPDATE AVAILABLE: 3.6.11', +BROWSER_VERSION: 'HeadlessChrome/88.0.4324.190', +OS: 'Windows Server 2016', +START_TS: 1614310326309, +NUM: '6247', +LAUNCH_TIME_MS: 7934, +PHONE_VERSION: '2.20.205.16' +}, +config: { +sessionId: 'session', +headless: true, +qrTimeout: 20, +authTimeout: 0, +cacheEnabled: false, +useChrome: true, +killProcessOnBrowserClose: true, +throwErrorOnTosBlock: false, +chromiumArgs: [ +'--no-sandbox', +'--disable-setuid-sandbox', +'--aggressive-cache-discard', +'--disable-cache', +'--disable-application-cache', +'--disable-offline-load-stale-cache', +'--disk-cache-size=0' +], +executablePath: 'C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe', +skipBrokenMethodsCheck: true, +stickerServerEndpoint: true +}} +let res = await fetch('https://sticker-api.openwa.dev/convertMp4BufferToWebpDataUrl', { method: 'post', headers: { Accept: 'application/json, text/plain, /', 'Content-Type': 'application/json;charset=utf-8', }, body: JSON.stringify(Format)}) +return Buffer.from((await res.text()).split(';base64,')[1], 'base64')} diff --git a/plugins/sticker-toimg.js b/plugins/sticker-toimg.js new file mode 100644 index 0000000..b6ff60f --- /dev/null +++ b/plugins/sticker-toimg.js @@ -0,0 +1,17 @@ +import { webp2png } from '../lib/webp2mp4.js' + +let handler = async (m, { conn, usedPrefix, command }) => { + const notStickerMessage = `✳️ Reply to a sticker with :\n\n *${usedPrefix + command}*` + if (!m.quoted) throw notStickerMessage + const q = m.quoted || m + let mime = q.mediaType || '' + if (!/sticker/.test(mime)) throw notStickerMessage + let media = await q.download() + let out = await webp2png(media).catch(_ => null) || Buffer.alloc(0) + await conn.sendFile(m.chat, out, 'out.png', '*βœ… Here you have*', m) +} +handler.help = ['toimg '] +handler.tags = ['sticker'] +handler.command = ['toimg', 'jpg', 'aimg'] + +export default handler diff --git a/plugins/sticker-tovid.js b/plugins/sticker-tovid.js new file mode 100644 index 0000000..e5f2a92 --- /dev/null +++ b/plugins/sticker-tovid.js @@ -0,0 +1,27 @@ +import { webp2mp4 } from '../lib/webp2mp4.js' +import { ffmpeg } from '../lib/converter.js' + +let handler = async (m, { conn }) => { + if (!m.quoted) throw '✳️ Respond to an animated sticker' + let mime = m.quoted.mimetype || '' + if (!/webp|audio/.test(mime)) throw '✳️ Respond to an animated sticker' + let media = await m.quoted.download() + let out = Buffer.alloc(0) + if (/webp/.test(mime)) { + out = await webp2mp4(media) + } else if (/audio/.test(mime)) { + out = await ffmpeg(media, [ + '-filter_complex', 'color', + '-pix_fmt', 'yuv420p', + '-crf', '51', + '-c:a', 'copy', + '-shortest' + ], 'mp3', 'mp4') + } + await conn.sendFile(m.chat, out, 'tovid.mp4', 'βœ… sticker a video' , m) +} +handler.help = ['tovid'] +handler.tags = ['sticker'] +handler.command = ['tovideo', 'tovid'] + +export default handler diff --git a/plugins/sticker-ttp_attp.js b/plugins/sticker-ttp_attp.js new file mode 100644 index 0000000..8fb6232 --- /dev/null +++ b/plugins/sticker-ttp_attp.js @@ -0,0 +1,85 @@ +import fetch from 'node-fetch' +import { sticker, addExif } from '../lib/sticker.js' +import { Sticker } from 'wa-sticker-formatter' +let handler = async(m, { conn, text, args, usedPrefix, command }) => { +if (!text) throw `*[❗] where is the text*\n\n*β€”β—‰ 𝙴xample:*\n*β—‰ ${usedPrefix + command} Guru*` +let teks = encodeURI(text) + +if (command == 'attp') { +let a1 = await (await fetch(`https://api.erdwpe.com/api/maker/attp?text=${teks}`)).buffer() +let a2 = await createSticker(a1, false, global.packname, global.author) +conn.sendFile(m.chat, a2, 'sticker.webp', '', m, { asSticker: true })} + +if (command == 'attp2') { +conn.sendFile(m.chat, `https://api.lolhuman.xyz/api/attp?apikey=${lolkeysapi}&text=${teks}`, 'sticker.webp', '', m, { asSticker: true })} + +if (command == 'attp3') { +conn.sendFile(m.chat, `https://api.lolhuman.xyz/api/attp2?apikey=${lolkeysapi}&text=${teks}`, 'sticker.webp', '', m, { asSticker: true })} + +if (command == 'ttp5') { +conn.sendFile(m.chat, `https://api.lolhuman.xyz/api/ttp6?apikey=${lolkeysapi}&text=${teks}`, 'sticker.webp', '', m, { asSticker: true })} + +if (command == 'ttp4') { +conn.sendFile(m.chat, `https://api.lolhuman.xyz/api/ttp5?apikey=${lolkeysapi}&text=${teks}`, 'sticker.webp', '', m, { asSticker: true })} + +if (command == 'ttp3') { +conn.sendFile(m.chat, `https://api.lolhuman.xyz/api/ttp3?apikey=${lolkeysapi}&text=${teks}`, 'sticker.webp', '', m, { asSticker: true })} + +if (command == 'ttp2') { +conn.sendFile(m.chat, `https://api.lolhuman.xyz/api/ttp2?apikey=${lolkeysapi}&text=${teks}`, 'sticker.webp', '', m, { asSticker: true })} + +if (command == 'ttp') { +conn.sendFile(m.chat, `https://api.lolhuman.xyz/api/ttp?apikey=${lolkeysapi}&text=${teks}`, 'sticker.webp', '', m, { asSticker: true })} + +} +handler.command = handler.help = ['ttp', 'ttp2', 'ttp3', 'ttp4', 'ttp5', 'attp', 'attp2', 'attp3'] +handler.tags = ['sticker'] +export default handler + +async function createSticker(img, url, packName, authorName, quality) { +let stickerMetadata = { type: 'full', pack: packName, author: authorName, quality } +return (new Sticker(img ? img : url, stickerMetadata)).toBuffer()} +async function mp4ToWebp(file, stickerMetadata) { +if (stickerMetadata) { +if (!stickerMetadata.pack) stickerMetadata.pack = 'β€Ž' +if (!stickerMetadata.author) stickerMetadata.author = 'β€Ž' +if (!stickerMetadata.crop) stickerMetadata.crop = false +} else if (!stickerMetadata) { stickerMetadata = { pack: 'β€Ž', author: 'β€Ž', crop: false }} +let getBase64 = file.toString('base64') +const Format = { file: `data:video/mp4;base64,${getBase64}`, processOptions: { crop: stickerMetadata?.crop, startTime: '00:00:00.0', endTime: '00:00:7.0', loop: 0 +}, stickerMetadata: { ...stickerMetadata }, +sessionInfo: { +WA_VERSION: '2.2106.5', +PAGE_UA: 'WhatsApp/2.2037.6 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36', +WA_AUTOMATE_VERSION: '3.6.10 UPDATE AVAILABLE: 3.6.11', +BROWSER_VERSION: 'HeadlessChrome/88.0.4324.190', +OS: 'Windows Server 2016', +START_TS: 1614310326309, +NUM: '6247', +LAUNCH_TIME_MS: 7934, +PHONE_VERSION: '2.20.205.16' +}, +config: { +sessionId: 'session', +headless: true, +qrTimeout: 20, +authTimeout: 0, +cacheEnabled: false, +useChrome: true, +killProcessOnBrowserClose: true, +throwErrorOnTosBlock: false, +chromiumArgs: [ +'--no-sandbox', +'--disable-setuid-sandbox', +'--aggressive-cache-discard', +'--disable-cache', +'--disable-application-cache', +'--disable-offline-load-stale-cache', +'--disk-cache-size=0' +], +executablePath: 'C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe', +skipBrokenMethodsCheck: true, +stickerServerEndpoint: true +}} +let res = await fetch('https://sticker-api.openwa.dev/convertMp4BufferToWebpDataUrl', { method: 'post', headers: { Accept: 'application/json, text/plain, /', 'Content-Type': 'application/json;charset=utf-8', }, body: JSON.stringify(Format)}) +return Buffer.from((await res.text()).split(';base64,')[1], 'base64')} diff --git a/plugins/tool-pdf.js b/plugins/tool-pdf.js new file mode 100644 index 0000000..903a545 --- /dev/null +++ b/plugins/tool-pdf.js @@ -0,0 +1,12 @@ +import uploadImage from '../lib/uploadImage.js' +let handler = async (m, { conn, text, usedPrefix, command, isOwner }) => { +let q = m.quoted ? m.quoted : m +let mime = (q.msg || q).mimetype || '' +if (!mime) throw '*Respond / reply to an image*' +let img = await q.download?.() +let url = await uploadImage(img) +let docname = text ? text : m.pushName || 'Gurubot' +conn.sendFile(m.chat, `http://api.lolhuman.xyz/api/convert/imgtopdf?apikey=${lolkeysapi}&img=${url}`, docname + '.pdf', '', m, false, { asDocument: true }) +} +handler.command = /^topdf$/i +export default handler \ No newline at end of file diff --git a/plugins/tool-resize.js b/plugins/tool-resize.js new file mode 100644 index 0000000..eb81e6e --- /dev/null +++ b/plugins/tool-resize.js @@ -0,0 +1,28 @@ +import uploadImage from '../lib/uploadImage.js'; +import fetch from 'node-fetch'; + +let handler = async (m, { conn, usedPrefix, command, args, text }) => { + let q = m.quoted ? m.quoted : m; + let mime = (q.msg || q).mimetype || ''; + + if (!mime) throw '⚠️️ Reply to an image or video.'; + if (!text) throw '⚠️️ Enter the new file size for the image/video.'; + if (isNaN(text)) throw 'πŸ”’ Only numbers are allowed.'; + + if (!/image\/(jpe?g|png)|video|document/.test(mime)) throw '⚠️️ Unsupported format.'; + + let img = await q.download(); + let url = await uploadImage(img); + + if (/image\/(jpe?g|png)/.test(mime)) { + conn.sendMessage(m.chat, { image: { url: url }, caption: `Here you go`, fileLength: `${text}`, mentions: [m.sender] }, { ephemeralExpiration: 24 * 3600, quoted: m }); + } else if (/video/.test(mime)) { + return conn.sendMessage(m.chat, { video: { url: url }, caption: `Here you go`, fileLength: `${text}`, mentions: [m.sender] }, { ephemeralExpiration: 24 * 3600, quoted: m }); + } +}; + +handler.tags = ['tools']; +handler.help = ['length ']; +handler.command = /^(length|filelength|edittamaΓ±o|totamaΓ±o|tamaΓ±o)$/i; + +export default handler; diff --git a/plugins/tool-shorturl.js b/plugins/tool-shorturl.js new file mode 100644 index 0000000..661ea56 --- /dev/null +++ b/plugins/tool-shorturl.js @@ -0,0 +1,20 @@ +import fetch from 'node-fetch'; + +let handler = async (m, { conn, args, text }) => { + if (!text) throw '*Please provide a URL or link to shorten.*'; + + let shortUrl1 = await (await fetch(`https://tinyurl.com/api-create.php?url=${args[0]}`)).text(); + + if (!shortUrl1) throw `*Error: Could not generate a short URL.*`; + + let done = `*SHORT URL CREATED!!*\n\n*Original Link:*\n${text}\n*Shortened URL:*\n${shortUrl1}`.trim(); + + m.reply(done); +}; + +handler.help = ['tinyurl', 'shorten'].map(v => v + ' '); +handler.tags = ['tools']; +handler.command = /^(tinyurl|short|acortar|corto)$/i; +handler.fail = null; + +export default handler; diff --git a/plugins/tool-tempmail.js b/plugins/tool-tempmail.js new file mode 100644 index 0000000..a509941 --- /dev/null +++ b/plugins/tool-tempmail.js @@ -0,0 +1,63 @@ +//thanks to inrl:https://github.com/inrl-official +import fetch from 'node-fetch'; + +let handler = async (m, { text, usedPrefix, command }) => { + if (command === 'tempmail') { + try { + const response = await fetch('https://inrl-web.onrender.com/api/getmail?apikey=inrl'); + const data = await response.json(); + + if (data.status && data.result && data.result.length > 0) { + const tempMails = data.result.join('\n'); + const replyMessage = `*Temporary Email Addresses:*\n\n${tempMails}\n\n use \`\`\`\.checkmail \`\`\`\ if you want to check inbox of any temp mail used from above`; + m.reply(replyMessage); + } else { + m.reply('No temporary email addresses found.'); + } + } catch (error) { + console.error('Error:', error); + m.reply('Failed to fetch temporary email addresses.'); + } + } else if (command === 'checkmail') { + if (!text && !(m.quoted && m.quoted.text)) { + m.reply('Please provide some text or quote a message to get a response.'); + return; + } + + if (!text && m.quoted && m.quoted.text) { + text = m.quoted.text; + } else if (text && m.quoted && m.quoted.text) { + text = `${text} ${m.quoted.text}`; + } + + try { + const response = await fetch(`https://inrl-web.onrender.com/api/getmailinfo?email=${encodeURIComponent(text)}&apikey=inrl`); + const data = await response.json(); + + if (data.status && data.result && data.result.length > 0) { + const messages = data.result.map((message) => { + return ` +*From:* ${message.from} +*Subject:* ${message.subject} +*Date:* ${message.date} +*Body:* +${message.text} + `; + }).join('\n\n---\n\n'); + const replyMessage = `*Messages in* ${text}:\n\n${messages}`; + m.reply(replyMessage); + } else { + m.reply(`No messages found in ${text}.`); + } + } catch (error) { + console.error('Error:', error); + m.reply(`Failed to check messages in ${text}.`); + } + } +}; +handler.help = ['tempmail'] +handler.tags = ['tools'] +handler.command = ['tempmail', 'checkmail']; +handler.diamond = false; + +export default handler; diff --git a/plugins/tools-element.js b/plugins/tools-element.js new file mode 100644 index 0000000..7b1b528 --- /dev/null +++ b/plugins/tools-element.js @@ -0,0 +1,40 @@ +import fetch from 'node-fetch'; + +let elementHandler = async (m, { conn, text }) => { + if (!text) throw 'Please provide an element symbol or name'; + + try { + let res = await fetch(`https://api.popcat.xyz/periodic-table?element=${text}`); + + if (!res.ok) { + throw new Error(`API request failed with status ${res.status}`); + } + + let buffer = await res.arrayBuffer(); + let json = JSON.parse(Buffer.from(buffer).toString()); + + console.log('JSON response:', json); + + let elementInfo = + `*Element Information:*\n + β€’ *Name:* ${json.name}\n + β€’ *Symbol:* ${json.symbol}\n + β€’ *Atomic Number:* ${json.atomic_number}\n + β€’ *Atomic Mass:* ${json.atomic_mass}\n + β€’ *Period:* ${json.period}\n + β€’ *Phase:* ${json.phase}\n + β€’ *Discovered By:* ${json.discovered_by}\n + β€’ *Summary:* ${json.summary}`; + + conn.sendFile(m.chat, json.image, 'element.jpg', elementInfo, m); + } catch (error) { + console.error(error); + // Handle the error appropriately + } +}; + +elementHandler.help = ['element']; +elementHandler.tags = ['tools']; +elementHandler.command = /^(element|ele)$/i; + +export default elementHandler; diff --git a/plugins/tools-imagine.js b/plugins/tools-imagine.js new file mode 100644 index 0000000..b95aaaf --- /dev/null +++ b/plugins/tools-imagine.js @@ -0,0 +1 @@ +const _0x38e781=_0x261a;(function(_0x1ab1be,_0x2450c0){const _0x4f98f2=_0x261a;const _0x2db77b=_0x1ab1be();while(!![]){try{const _0x4fd655=parseInt(_0x4f98f2(0x143))/0x1+parseInt(_0x4f98f2(0x16c))/0x2*(parseInt(_0x4f98f2(0x17e))/0x3)+parseInt(_0x4f98f2(0x136))/0x4+parseInt(_0x4f98f2(0x172))/0x5+-parseInt(_0x4f98f2(0x13a))/0x6*(-parseInt(_0x4f98f2(0x18f))/0x7)+parseInt(_0x4f98f2(0x16a))/0x8*(-parseInt(_0x4f98f2(0x18e))/0x9)+parseInt(_0x4f98f2(0x15c))/0xa*(-parseInt(_0x4f98f2(0x176))/0xb);if(_0x4fd655===_0x2450c0){break;}else{_0x2db77b['push'](_0x2db77b['shift']());}}catch(_0x18d490){_0x2db77b['push'](_0x2db77b['shift']());}}}(_0x490c,0xc4ced));const _0x398520=(function(){let _0xcd67f8=!![];return function(_0x2348a7,_0x59a634){const _0x51abed=_0xcd67f8?function(){const _0x2ff13a=_0x261a;if(_0x59a634){const _0xf51dcd=_0x59a634[_0x2ff13a(0x164)](_0x2348a7,arguments);_0x59a634=null;return _0xf51dcd;}}:function(){};_0xcd67f8=![];return _0x51abed;};}());(function(){const _0x646e7d=_0x261a;const _0x5c8b07={'XhdiE':_0x646e7d(0x16d),'hCBpB':_0x646e7d(0x14b),'XVlJb':function(_0x3f5f86,_0x4cf1b4){return _0x3f5f86(_0x4cf1b4);},'WPmhQ':_0x646e7d(0x18c),'YBvtb':_0x646e7d(0x13b),'RlunU':_0x646e7d(0x154),'TfphG':function(_0x1eb742,_0x5cc7f4){return _0x1eb742(_0x5cc7f4);},'anSXO':function(_0x494c87){return _0x494c87();},'ETxcG':function(_0x362f7b,_0x3e5e02,_0x111a02){return _0x362f7b(_0x3e5e02,_0x111a02);}};_0x5c8b07[_0x646e7d(0x165)](_0x398520,this,function(){const _0x11d239=_0x646e7d;const _0x7b1633=new RegExp(_0x5c8b07[_0x11d239(0x134)]);const _0x4f1f09=new RegExp(_0x5c8b07[_0x11d239(0x14c)],'i');const _0x4d99cd=_0x5c8b07['XVlJb'](_0x530edd,_0x5c8b07['WPmhQ']);if(!_0x7b1633[_0x11d239(0x188)](_0x4d99cd+_0x5c8b07['YBvtb'])||!_0x4f1f09[_0x11d239(0x188)](_0x4d99cd+_0x5c8b07['RlunU'])){_0x5c8b07[_0x11d239(0x17d)](_0x4d99cd,'0');}else{_0x5c8b07[_0x11d239(0x184)](_0x530edd);}})();}());import _0xc8976e from'node-fetch';let handler=async(_0x5028d9,{conn:_0x47aad9,isOwner:_0x359a68,usedPrefix:_0x51c4b8,command:_0x320c95,args:_0x5871d8})=>{const _0x3b0d63=_0x261a;const _0x843481={'kVXSU':'Oops!\x20I\x20need\x20an\x20input\x20text.\x20Try\x20something\x20like\x20this:\x0a.midjourney\x20man\x20kissing','xxmtN':function(_0x45022f,_0x58a694){return _0x45022f>=_0x58a694;},'AkNBL':function(_0x469564,_0x3f588e){return _0x469564===_0x3f588e;},'hCDdv':_0x3b0d63(0x178),'orZoU':function(_0x467e60,_0x173863){return _0x467e60(_0x173863);},'lyWdx':function(_0x544022,_0x45075c){return _0x544022>_0x45075c;},'qAjcI':function(_0x4f426e,_0x57c591){return _0x4f426e===_0x57c591;},'pswgz':function(_0x158dc4,_0x325427){return _0x158dc4*_0x325427;},'jvcVg':_0x3b0d63(0x187),'oSwLc':function(_0x180f91,_0x4f4c4b){return _0x180f91===_0x4f4c4b;},'TCErn':_0x3b0d63(0x146),'PHkcI':_0x3b0d63(0x14d)};let _0x17d8a2=_0x843481[_0x3b0d63(0x189)];let _0x27ce5a;if(_0x843481[_0x3b0d63(0x15f)](_0x5871d8[_0x3b0d63(0x183)],0x1)){_0x27ce5a=_0x5871d8[_0x3b0d63(0x17a)](0x0)[_0x3b0d63(0x144)]('\x20');_0x5028d9[_0x3b0d63(0x153)](_0x3b0d63(0x152)+_0x27ce5a+_0x3b0d63(0x147));}else if(_0x5028d9[_0x3b0d63(0x135)]&&_0x5028d9[_0x3b0d63(0x135)]['text']){if(_0x843481[_0x3b0d63(0x166)](_0x843481['hCDdv'],_0x843481[_0x3b0d63(0x141)])){_0x27ce5a=_0x5028d9[_0x3b0d63(0x135)][_0x3b0d63(0x169)];_0x5028d9[_0x3b0d63(0x153)](_0x3b0d63(0x158)+_0x27ce5a+_0x3b0d63(0x14a));}else{return!![];}}else throw _0x17d8a2;try{_0x5028d9[_0x3b0d63(0x153)]('Brewing\x20up\x20some\x20AI\x20magic...\x20πŸ§™β€β™‚οΈ');const _0x300556=await _0x843481['orZoU'](Draw,_0x27ce5a);if(_0x843481[_0x3b0d63(0x138)](_0x300556['length'],0x0)){if(_0x843481[_0x3b0d63(0x148)]('kLNGP',_0x3b0d63(0x157))){if(_0x5c325e){const _0x237cf1=_0x28faf9[_0x3b0d63(0x164)](_0x577920,arguments);_0x95f496=null;return _0x237cf1;}}else{const _0x56e3ab=Math[_0x3b0d63(0x175)](_0x843481['pswgz'](Math[_0x3b0d63(0x180)](),_0x300556[_0x3b0d63(0x183)]));const _0x413a91=_0x300556[_0x56e3ab];_0x47aad9[_0x3b0d63(0x163)](_0x5028d9['chat'],_0x413a91,_0x27ce5a,_0x3b0d63(0x191)+_0x27ce5a+'\x22',_0x5028d9);}}else{throw _0x843481['jvcVg'];}}catch(_0x2d3a16){if(_0x843481[_0x3b0d63(0x174)](_0x843481['TCErn'],_0x843481['TCErn'])){throw _0x843481[_0x3b0d63(0x179)];}else{_0x2f16a2=_0x455d2f['slice'](0x0)[_0x3b0d63(0x144)]('\x20');_0xc80f3a[_0x3b0d63(0x153)](_0x3b0d63(0x152)+_0x12c250+_0x3b0d63(0x147));}}};handler[_0x38e781(0x161)]=[_0x38e781(0x160)];handler[_0x38e781(0x133)]=['AI'];handler['command']=/^imagine$/i;function _0x261a(_0x132dbe,_0x30181c){const _0x5a4f19=_0x490c();_0x261a=function(_0x530edd,_0x398520){_0x530edd=_0x530edd-0x132;let _0x490cc9=_0x5a4f19[_0x530edd];return _0x490cc9;};return _0x261a(_0x132dbe,_0x30181c);}function _0x490c(){const _0x46ed3f=['bzqhP','*[Ta-da!\x20Here\x27s\x20your\x20result:]*\x0a\x22','No\x20image\x20links\x20found\x20in\x20the\x20API\x20response.','tags','XhdiE','quoted','1742076QLXUJh','mdwDo','lyWdx','FEsdL','60LJdPxO','chain','NLiwh','pLgHw','Failed\x20to\x20fetch\x20image\x20links\x20from\x20the\x20API.','https://v2-guru-indratensei.cloud.okteto.net/scrape?query=','kCyQb','hCDdv','iWrwF','27826hMsLKq','join','rXZqq','toxTV','\x22...','qAjcI','UWCWO','\x22,\x20let\x27s\x20generate\x20an\x20image...','\x5c+\x5c+\x20*(?:[a-zA-Z_$][0-9a-zA-Z_$]*)','hCBpB','Oh\x20snap!\x20Something\x20went\x20wrong\x20while\x20generating\x20the\x20image.\x20πŸ₯Ί','byWfm','cNCou','jPjMt','stateObject','Let\x27s\x20see\x20what\x20image\x20I\x20can\x20dream\x20up\x20from\x20\x22','reply','input','VPvvs','ryjCK','KpPbq','Aha!\x20Using\x20your\x20quoted\x20text,\x20\x22','AjSgY','oNNMC','constructor','170NIuuEf','QWpdJ','debu','xxmtN','imagine','help','string','sendFile','apply','ETxcG','AkNBL','oWxUm','fMcWH','text','56PQEABE','mGPKZ','8bCuVTn','function\x20*\x5c(\x20*\x5c)','gger','uzZpx','fKsPd','ExKoa','5942655fYjUkH','image_links','oSwLc','floor','1373174qULdrx','forhT','XNhEt','PHkcI','slice','CJMjS','EXOoH','TfphG','936480WtVhaC','call','random','pTGci','while\x20(true)\x20{}','length','anSXO','BfkCV','ieHcN','No\x20images\x20found\x20in\x20the\x20API\x20response.','test','kVXSU','ZUYdj','action','init','xCmXd','1308681MSFEon','731955DTwuak'];_0x490c=function(){return _0x46ed3f;};return _0x490c();}export default handler;async function Draw(_0x4d7fc9){const _0x4cffbe=_0x38e781;const _0x9b33a1={'ZUYdj':_0x4cffbe(0x14b),'cNCou':_0x4cffbe(0x18c),'forhT':'chain','oWxUm':function(_0x35fce6,_0x3a6f21){return _0x35fce6+_0x3a6f21;},'pTGci':'input','JKQbJ':function(_0xec2b93,_0x495e5d){return _0xec2b93(_0x495e5d);},'bzqhP':function(_0x4e49d3,_0x2fb9e1){return _0x4e49d3(_0x2fb9e1);},'xCmXd':function(_0x1f896a,_0x244309){return _0x1f896a(_0x244309);},'FEsdL':function(_0x329b20,_0xf494d8){return _0x329b20>_0xf494d8;},'AjSgY':_0x4cffbe(0x15d),'mdwDo':_0x4cffbe(0x168),'aJvsG':_0x4cffbe(0x132),'CJMjS':function(_0x1c5bb6,_0x5753a1){return _0x1c5bb6!==_0x5753a1;},'gPgZJ':_0x4cffbe(0x150),'zESUb':_0x4cffbe(0x13e)};try{const _0xd9d7f0=await _0x9b33a1[_0x4cffbe(0x190)](_0xc8976e,_0x4cffbe(0x13f)+_0x9b33a1[_0x4cffbe(0x18d)](encodeURIComponent,_0x4d7fc9));const _0x202825=await _0xd9d7f0['json']();if(_0x202825['image_links']&&_0x9b33a1[_0x4cffbe(0x139)](_0x202825[_0x4cffbe(0x173)][_0x4cffbe(0x183)],0x0)){if('EhUAy'!==_0x9b33a1[_0x4cffbe(0x159)]){return _0x202825[_0x4cffbe(0x173)];}else{_0x3d33d7=_0x184ba3[_0x4cffbe(0x135)][_0x4cffbe(0x169)];_0x3114f3['reply'](_0x4cffbe(0x158)+_0x5caaa9+_0x4cffbe(0x14a));}}else{if(_0x9b33a1[_0x4cffbe(0x137)]===_0x4cffbe(0x168)){throw _0x9b33a1['aJvsG'];}else{const _0x3a2a01=new _0x3e4f3f(_0x4cffbe(0x16d));const _0x42636c=new _0xac50f8(icmUrB[_0x4cffbe(0x18a)],'i');const _0x285837=_0x5b60ee(icmUrB[_0x4cffbe(0x14f)]);if(!_0x3a2a01[_0x4cffbe(0x188)](_0x285837+icmUrB[_0x4cffbe(0x177)])||!_0x42636c[_0x4cffbe(0x188)](icmUrB[_0x4cffbe(0x167)](_0x285837,icmUrB[_0x4cffbe(0x181)]))){icmUrB['JKQbJ'](_0x285837,'0');}else{_0x203038();}}}}catch(_0x5e6a43){if(_0x9b33a1[_0x4cffbe(0x17b)](_0x4cffbe(0x150),_0x9b33a1['gPgZJ'])){const _0x52d06e=_0x2140b6?function(){const _0x41e23e=_0x4cffbe;if(_0x12d97e){const _0x10da60=_0x3d13bc[_0x41e23e(0x164)](_0x42a6d0,arguments);_0x3fd61a=null;return _0x10da60;}}:function(){};_0x5369c7=![];return _0x52d06e;}else{throw _0x9b33a1['zESUb'];}}}function _0x530edd(_0x2ad599){const _0x2588dc=_0x38e781;const _0x4b5814={'BfkCV':function(_0x48e538,_0x2c4140){return _0x48e538(_0x2c4140);},'mGPKZ':_0x2588dc(0x142),'ryjCK':_0x2588dc(0x182),'rXZqq':'counter','kCyQb':function(_0x27ae1a,_0x3099b6){return _0x27ae1a===_0x3099b6;},'EXOoH':_0x2588dc(0x155),'oNNMC':function(_0x46d8ef,_0x5ce752){return _0x46d8ef!==_0x5ce752;},'pLgHw':function(_0x149210,_0x260219){return _0x149210+_0x260219;},'scoNX':function(_0x5ae79a,_0x161d7e){return _0x5ae79a/_0x161d7e;},'EDWTh':_0x2588dc(0x183),'edsYU':function(_0x4e3d6d,_0x540fb2){return _0x4e3d6d===_0x540fb2;},'fKsPd':function(_0x47f849,_0x2b5f56){return _0x47f849%_0x2b5f56;},'ieHcN':_0x2588dc(0x15e),'uzZpx':_0x2588dc(0x16e),'NLiwh':_0x2588dc(0x18b),'nUvpo':function(_0x5b6cf4,_0x29e85c){return _0x5b6cf4+_0x29e85c;},'HJsNZ':_0x2588dc(0x151),'UWCWO':function(_0x562fe2,_0x169fe4){return _0x562fe2===_0x169fe4;},'byWfm':function(_0x1ad91b,_0x204b95){return _0x1ad91b(_0x204b95);}};function _0x25fbc3(_0x3d6d3f){const _0x4662c5=_0x2588dc;if(typeof _0x3d6d3f===_0x4662c5(0x162)){if(_0x4b5814[_0x4662c5(0x16b)]===_0x4662c5(0x142)){return function(_0x5acc8a){}[_0x4662c5(0x15b)](_0x4b5814[_0x4662c5(0x156)])['apply'](_0x4b5814[_0x4662c5(0x145)]);}else{_0x4b5814[_0x4662c5(0x185)](_0x25a209,0x0);}}else{if(_0x4b5814[_0x4662c5(0x140)](_0x4b5814[_0x4662c5(0x17c)],_0x4b5814[_0x4662c5(0x17c)])){if(_0x4b5814[_0x4662c5(0x15a)](_0x4b5814['pLgHw']('',_0x4b5814['scoNX'](_0x3d6d3f,_0x3d6d3f))[_0x4b5814['EDWTh']],0x1)||_0x4b5814['edsYU'](_0x4b5814[_0x4662c5(0x170)](_0x3d6d3f,0x14),0x0)){(function(){return!![];}[_0x4662c5(0x15b)](_0x4b5814[_0x4662c5(0x13d)](_0x4b5814[_0x4662c5(0x186)],_0x4b5814[_0x4662c5(0x16f)]))[_0x4662c5(0x17f)](_0x4b5814[_0x4662c5(0x13c)]));}else{(function(){return![];}[_0x4662c5(0x15b)](_0x4b5814['nUvpo'](_0x4b5814[_0x4662c5(0x186)],_0x4662c5(0x16e)))[_0x4662c5(0x164)](_0x4b5814['HJsNZ']));}}else{throw _0x4662c5(0x13e);}}_0x4b5814[_0x4662c5(0x185)](_0x25fbc3,++_0x3d6d3f);}try{if(_0x2ad599){return _0x25fbc3;}else{if(_0x4b5814[_0x2588dc(0x149)](_0x2588dc(0x171),_0x2588dc(0x171))){_0x4b5814[_0x2588dc(0x14e)](_0x25fbc3,0x0);}else{const _0xeb307c=_0xd5ce6a[_0x2588dc(0x164)](_0x26b868,arguments);_0x501a70=null;return _0xeb307c;}}}catch(_0x174dad){}} diff --git a/plugins/tools-itunes.js b/plugins/tools-itunes.js new file mode 100644 index 0000000..ea1773b --- /dev/null +++ b/plugins/tools-itunes.js @@ -0,0 +1,45 @@ +import fetch from 'node-fetch'; + +let itunesHandler = async (m, { conn, text }) => { + if (!text) throw 'Please provide a song name'; + + try { + let res = await fetch(`https://api.popcat.xyz/itunes?q=${encodeURIComponent(text)}`); + + if (!res.ok) { + throw new Error(`API request failed with status ${res.status}`); + } + + let json = await res.json(); + + console.log('JSON response:', json); + + let songInfo = + `*Song Information:*\n + β€’ *Name:* ${json.name}\n + β€’ *Artist:* ${json.artist}\n + β€’ *Album:* ${json.album}\n + β€’ *Release Date:* ${json.release_date}\n + β€’ *Price:* ${json.price}\n + β€’ *Length:* ${json.length}\n + β€’ *Genre:* ${json.genre}\n + β€’ *URL:* ${json.url}`; + + // Check if thumbnail is present, then send it with songInfo as caption + if (json.thumbnail) { + await conn.sendFile(m.chat, json.thumbnail, 'thumbnail.jpg', songInfo, m); + } else { + m.reply(songInfo); + } + + } catch (error) { + console.error(error); + // Handle the error appropriately + } +}; + +itunesHandler.help = ['itunes']; +itunesHandler.tags = ['tools']; +itunesHandler.command = /^(itunes)$/i; + +export default itunesHandler; diff --git a/plugins/tools-lyrics.js b/plugins/tools-lyrics.js new file mode 100644 index 0000000..a7bc5ea --- /dev/null +++ b/plugins/tools-lyrics.js @@ -0,0 +1,24 @@ +import fetch from 'node-fetch' + +let handler = async (m, {conn, text }) => { + let teks = text ? text : m.quoted && m.quoted.text ? m.quoted.text : '' + if (!teks) throw `✳️ Enter the name of the song` + try { + let res = await fetch(global.API('https://some-random-api.com', '/lyrics', { title: teks })) + if (!res.ok) throw await res.text() + let json = await res.json() + if (!json.thumbnail.genius) throw json + conn.sendFile(m.chat, json.thumbnail.genius, null, ` +β–’ *${json.title}* +*${json.author}*\n +${json.lyrics}`, m) +m.react(done) +} catch (e) { + m.react(error) + } +} +handler.help = ['lyrics'] +handler.tags = ['tools'] +handler.command = ['letra', 'lyrics', 'letras'] + +export default handler diff --git a/plugins/tools-movie.js b/plugins/tools-movie.js new file mode 100644 index 0000000..f5a10ce --- /dev/null +++ b/plugins/tools-movie.js @@ -0,0 +1,58 @@ +import fetch from 'node-fetch'; + +let imdbHandler = async (m, { conn, text }) => { + if (!text) throw 'Please provide a movie title'; + + try { + let res = await fetch(`https://api.popcat.xyz/imdb?q=${encodeURIComponent(text)}`); + + if (!res.ok) { + throw new Error(`API request failed with status ${res.status}`); + } + + let json = await res.json(); + + console.log('JSON response:', json); + + let ratings = json.ratings.map(rating => `β€’ *${rating.source}:* ${rating.value}`).join('\n'); + + let movieInfo = + `*Movie Information:*\n + β€’ *Title:* ${json.title}\n + β€’ *Year:* ${json.year}\n + β€’ *Seasons:* ${json.totalseasons}\n + β€’ *Rated:* ${json.rated}\n + β€’ *Released:* ${json.released}\n + β€’ *Runtime:* ${json.runtime}\n + β€’ *Genres:* ${json.genres}\n + β€’ *Director:* ${json.director}\n + β€’ *Writer:* ${json.writer}\n + β€’ *Actors:* ${json.actors}\n + β€’ *Plot:* ${json.plot}\n + β€’ *Languages:* ${json.languages}\n + β€’ *Country:* ${json.country}\n + β€’ *Awards:* ${json.awards}\n + β€’ *Metascore:* ${json.metascore}\n + β€’ *Rating:* ${json.rating}\n + β€’ *Votes:* ${json.votes}\n + β€’ *IMDB ID:* ${json.imdbid}\n + β€’ *Type:* ${json.type}\n + β€’ *DVD:* ${json.dvd}\n + β€’ *Box Office:* ${json.boxoffice}\n + β€’ *Production:* ${json.production}\n + β€’ *Website:* ${json.website}\n\n + *Ratings:*\n${ratings}`; + + // send the movie poster along with the movie information as caption + await conn.sendFile(m.chat, json.poster, 'poster.jpg', movieInfo, m); + } catch (error) { + console.error(error); + // Handle the error appropriately + } +}; + +imdbHandler.help = ['imdb']; +imdbHandler.tags = ['tools']; +imdbHandler.command = /^(imdb|movie)$/i; + +export default imdbHandler; diff --git a/plugins/tools-readmore.js b/plugins/tools-readmore.js new file mode 100644 index 0000000..482fa5d --- /dev/null +++ b/plugins/tools-readmore.js @@ -0,0 +1,14 @@ +let handler = async (m, { conn, text }) => { + let [l, r] = text.split`|` + if (!l) l = '' + if (!r) r = '' + conn.reply(m.chat, l + readMore + r, m) +} +handler.help = ['readmore |'] +handler.tags = ['tools'] +handler.command = ['readmore'] + +export default handler + +const more = String.fromCharCode(8206) +const readMore = more.repeat(4001) diff --git a/plugins/tools-readviewonce.js b/plugins/tools-readviewonce.js new file mode 100644 index 0000000..032a643 --- /dev/null +++ b/plugins/tools-readviewonce.js @@ -0,0 +1,16 @@ + +let { downloadContentFromMessage } = (await import('@whiskeysockets/baileys')); + +var handler = async (m, { conn }) => { + if (!/viewOnce/.test(m.quoted?.mtype)) throw 'βœ³οΈβ‡οΈ Its Not a ViewOnce Message' + let mtype = Object.keys(m.quoted.message)[0] + let buffer = await m.quoted.download() + let caption = m.quoted.message[mtype].caption || '' + conn.sendMessage(m.chat, { [mtype.replace(/Message/, '')]: buffer, caption }, { quoted: m }) +} + +handler.help = ['readvo'] +handler.tags = ['tools'] +handler.command = ['readviewonce', 'read', 'ver', 'readvo'] + +export default handler \ No newline at end of file diff --git a/plugins/tools-removebg.js b/plugins/tools-removebg.js new file mode 100644 index 0000000..27e5245 --- /dev/null +++ b/plugins/tools-removebg.js @@ -0,0 +1,50 @@ +import axios from 'axios'; +import FormData from 'form-data'; +import fs from 'fs'; +import path from 'path'; +import dotenv from 'dotenv'; + +dotenv.config(); // Load environment variables from .env file + +const handler = async (m, { conn, text }) => { + try { + const q = m.quoted ? m.quoted : m; + const mime = (q.msg || q).mimetype || ''; + const img = await q.download(); + const apikey = process.env.REMOVEBG_KEY; // Use the API_KEY from the environment variable + + const formData = new FormData(); + formData.append('size', 'auto'); + formData.append('image_file', img, 'file.jpg'); + + const response = await axios.post('https://api.remove.bg/v1.0/removebg', formData, { + headers: { + ...formData.getHeaders(), + 'X-Api-Key': apikey, + }, + responseType: 'arraybuffer', + encoding: null, + }); + + if (response.status !== 200) { + throw new Error(`Error: ${response.status} ${response.statusText}`); + } + + const imageData = response.data; + + fs.writeFileSync('no-bg.png', imageData); + + // Add the caption to the image + const caption = `MADE BY ${botname}`; + conn.sendFile(m.chat, 'no-bg.png', '', caption, m); + } catch (e) { + console.error(e); + m.reply('Sorry, an error occurred while processing the image, maybe check your api key.'); + } +}; + +handler.help = ['removebg']; +handler.tags = ['tools']; +handler.command = /^rmbg|removebg$/i; +export default handler; + diff --git a/plugins/tools-ssweb.js b/plugins/tools-ssweb.js new file mode 100644 index 0000000..6484aaf --- /dev/null +++ b/plugins/tools-ssweb.js @@ -0,0 +1,10 @@ +import fetch from 'node-fetch' +let handler = async (m, { conn, command, args }) => { +if (!args[0]) return conn.reply(m.chat, '*[πŸ”Ž] give url*', m) +let ss = await (await fetch(`https://image.thum.io/get/fullpage/${args[0]}`)).buffer() +conn.sendFile(m.chat, ss, 'error.png', args[0], m)} +handler.help = ['ss', 'ssf'].map(v => v + ' ') +handler.tags = ['tools'] +handler.command = /^ss(web)?f?$/i +export default handler + diff --git a/plugins/tools-technews.js b/plugins/tools-technews.js new file mode 100644 index 0000000..78a8119 --- /dev/null +++ b/plugins/tools-technews.js @@ -0,0 +1,30 @@ +import fetch from 'node-fetch' + +let handler = async (m, { conn }) => { + try { + let res = await fetch('https://fantox001-scrappy-api.vercel.app/technews/random'); + if (!res.ok) throw await res.text(); + let json = await res.json(); + if (!json.news) throw json; + + let techNews = `‒───── ୨❀୧ ─────‒ + ❖ 𝑺𝑻𝑨𝑻𝑼𝑺: Active + γ‹‘ π‘ͺ𝑹𝑬𝑨𝑻𝑢𝑹: ABHISHEK-SURESH + ☞ 𝑡𝑬𝑾𝑺: ${json.news} + ‒───── ୨❀୧ ─────‒ + `; + + conn.sendFile(m.chat, json.thumbnail, 'thumbnail.jpg', techNews, m); + + + m.react(done); + } catch (e) { + + m.react(error); + } +} +handler.help = ['technews']; +handler.tags = ['news']; +handler.command = ['technews']; + +export default handler; diff --git a/plugins/tools-tgsticker.js b/plugins/tools-tgsticker.js new file mode 100644 index 0000000..e7f8510 --- /dev/null +++ b/plugins/tools-tgsticker.js @@ -0,0 +1,52 @@ +import { stickerTelegram } from '@bochilteam/scraper' +import axios from 'axios' + +var handler = async (m, { conn, args }) => { + if (args[0] && args[0].match(/(https:\/\/t.me\/addstickers\/)/gi)) { + let res = await Telesticker(args[0]) + await m.reply(`Sending ${res.length} stickers...`) + if (m.isGroup && res.length > 30) { + await m.reply('Number of stickers more than 30, bot will send it in private chat.') + for (let i = 0; i < res.length; i++) { + conn.sendMessage(m.sender, { sticker: { url: res[i].url }}) + } + } else { + for (let i = 0; i < res.length; i++) { + conn.sendMessage(m.chat, { sticker: { url: res[i].url }}) + } + } + } else if (args && args.join(' ')) { + let [query, page] = args.join(' ').split('|') + let res = await stickerTelegram(query, page) + if (!res.length) throw `Query "${args.join(' ')}" not found` + m.reply(res.map(v => `*${v.title}*\n_${v.link}_`).join('\n\n')) + } else throw 'Input Query / Telesticker Url' +} +handler.help = ['telesticker'] +handler.tags = ['tools'] +handler.command = /^(telestic?ker|tgsticker)$/i +handler.limit = true + +export default handler + +//Thanks Xfarr : https://github.com/xfar05 +async function Telesticker(url) { + return new Promise(async (resolve, reject) => { + if (!url.match(/(https:\/\/t.me\/addstickers\/)/gi)) throw 'Enter your url telegram sticker'; + const packName = url.replace('https://t.me/addstickers/', ''); + const data = await axios(`https://api.telegram.org/bot891038791:AAHWB1dQd-vi0IbH2NjKYUk-hqQ8rQuzPD4/getStickerSet?name=${encodeURIComponent(packName)}`, { method: 'GET', headers: { 'User-Agent': 'GoogleBot' } }); + const hasil = []; + for (let i = 0; i < data.data.result.stickers.length; i++) { + const fileId = data.data.result.stickers[i].thumb.file_id; + const data2 = await axios(`https://api.telegram.org/bot891038791:AAHWB1dQd-vi0IbH2NjKYUk-hqQ8rQuzPD4/getFile?file_id=${fileId}`); + const result = { + status: 200, + author: 'Xfarr05', + url: `https://api.telegram.org/file/bot891038791:AAHWB1dQd-vi0IbH2NjKYUk-hqQ8rQuzPD4/${data2.data.result.file_path}`, + }; + hasil.push(result); + } + resolve(hasil); + }); + } + \ No newline at end of file diff --git a/plugins/tools-tourl.js b/plugins/tools-tourl.js new file mode 100644 index 0000000..e4e7fdc --- /dev/null +++ b/plugins/tools-tourl.js @@ -0,0 +1,49 @@ +import uploadtoimgur from '../lib/imgur.js'; +import fs from 'fs'; +import path from 'path'; + +let handler = async (m) => { + let q = m.quoted ? m.quoted : m; + let mime = (q.msg || q).mimetype || ''; + + if (!mime) { + throw '✳️ Respond to an image/video'; + } + let mediaBuffer = await q.download(); + + + if (mediaBuffer.length > 10 * 1024 * 1024) { + throw '✴️ Media size exceeds 10 MB. Please upload a smaller file.'; + } + + let currentModuleDirectory = path.dirname(new URL(import.meta.url).pathname); + + let tmpDir = path.join(currentModuleDirectory, '../tmp'); + if (!fs.existsSync(tmpDir)) { + fs.mkdirSync(tmpDir); + } + + let mediaPath = path.join(tmpDir, `media_${Date.now()}.${mime.split('/')[1]}`); + fs.writeFileSync(mediaPath, mediaBuffer); + + let isTele = /image\/(png|jpe?g|gif)|video\/mp4/.test(mime); + + if (isTele) { + let link = await uploadtoimgur(mediaPath); + + const fileSizeMB = (mediaBuffer.length / (1024 * 1024)).toFixed(2); + + m.reply(`βœ… *Media Upload Successful*\nβ™• *File Size:* ${fileSizeMB} MB\nβ™• *URL:* ${link}`); + } else { + m.reply(`β™• ${mediaBuffer.length} Byte(s) + β™• (Unknown)`); + } + + fs.unlinkSync(mediaPath); +}; + +handler.help = ['tourl']; +handler.tags = ['tools']; +handler.command = ['url', 'tourl']; + +export default handler; diff --git a/plugins/tools-translate.js b/plugins/tools-translate.js new file mode 100644 index 0000000..a92e89a --- /dev/null +++ b/plugins/tools-translate.js @@ -0,0 +1,38 @@ + +import {translate} from '@vitalets/google-translate-api' +const defaultLang = 'en' +const tld = 'cn' + +let handler = async (m, { args, usedPrefix, command }) => { + let err = ` +πŸ“Œ *Example:* + +*${usedPrefix + command}* [text] +*${usedPrefix + command}* en Hello World + +≑ *List of supported languages:* + +https://cloud.google.com/translate/docs/languages +`.trim() + + let lang = args[0] + let text = args.slice(1).join(' ') + if ((args[0] || '').length !== 2) { + lang = defaultLang + text = args.join(' ') + } + if (!text && m.quoted && m.quoted.text) text = m.quoted.text + + try { + let result = await translate(text, { to: lang, autoCorrect: true }).catch(_ => null) + m.reply(result.text) + } catch (e) { + throw err + } + +} +handler.help = ['translate '] +handler.tags = ['tools'] +handler.command = ['translate', 'tl', 'trad', 'tr'] + +export default handler diff --git a/plugins/tools-tts.js b/plugins/tools-tts.js new file mode 100644 index 0000000..2aa0b47 --- /dev/null +++ b/plugins/tools-tts.js @@ -0,0 +1,45 @@ +import gtts from 'node-gtts' +import { readFileSync, unlinkSync } from 'fs' +import { join } from 'path' + +const defaultLang = 'en' +let handler = async (m, { conn, args, usedPrefix, command }) => { + + let lang = args[0] + let text = args.slice(1).join(' ') + if ((args[0] || '').length !== 2) { + lang = defaultLang + text = args.join(' ') + } + if (!text && m.quoted?.text) text = m.quoted.text + + let res + try { res = await tts(text, lang) } + catch (e) { + m.reply(e + '') + text = args.join(' ') + if (!text) throw `πŸ“Œ Example : \n${usedPrefix}${command} en hello world` + res = await tts(text, defaultLang) + } finally { + if (res) conn.sendFile(m.chat, res, 'tts.opus', null, m, true) + } +} +handler.help = ['tts '] +handler.tags = ['tools'] +handler.command = ['tts', 'voz'] + +export default handler + +function tts(text, lang = 'en-en') { + console.log(lang, text) + return new Promise((resolve, reject) => { + try { + let tts = gtts(lang) + let filePath = join(global.__dirname(import.meta.url), '../tmp', (1 * new Date) + '.wav') + tts.save(filePath, text, () => { + resolve(readFileSync(filePath)) + unlinkSync(filePath) + }) + } catch (e) { reject(e) } + }) +} diff --git a/plugins/tools-wikipedia.js b/plugins/tools-wikipedia.js new file mode 100644 index 0000000..83d64d8 --- /dev/null +++ b/plugins/tools-wikipedia.js @@ -0,0 +1,27 @@ +import axios from 'axios' +import cheerio from 'cheerio' + + +let handler = async (m, { text }) => { + if (!text) throw `✳️ Enter what you want to search for on Wikipedia` + + try { + const link = await axios.get(`https://es.wikipedia.org/wiki/${text}`) + const $ = cheerio.load(link.data) + let wik = $('#firstHeading').text().trim() + let resulw = $('#mw-content-text > div.mw-parser-output').find('p').text().trim() + m.reply(`β–’ *Wikipedia* + +β€£ Buscado : ${wik} + +${resulw}`) +} catch (e) { + m.reply('⚠️ No results found ') +} +} +handler.help = ['wikipedia'] +handler.tags = ['tools'] +handler.command = ['wiki','wikipedia'] + + +export default handler diff --git a/plugins/yta-play.js b/plugins/yta-play.js new file mode 100644 index 0000000..840175d --- /dev/null +++ b/plugins/yta-play.js @@ -0,0 +1,109 @@ +import {youtubedl, youtubedlv2} from '@bochilteam/scraper'; +import fetch from 'node-fetch'; +import yts from 'yt-search'; +import ytdl from 'ytdl-core'; +import axios from 'axios' +import {bestFormat, getUrlDl} from '../lib/y2dl.js'; +const handler = async (m, {text, conn, args, usedPrefix, command}) => { + if (!args[0]) throw 'hello there, ☺ \n*Example usage*\n\n*β—‰ .a(space)(Your number of video)*\n*β—‰ .a 1*'; + + let enviando; + if (enviando) return + enviando = true + let youtubeLink = ''; + if (args[0].includes('you')) { + youtubeLink = args[0]; + } else { + const index = parseInt(args[0]) - 1; + if (index >= 0) { + if (Array.isArray(global.videoList) && global.videoList.length > 0) { + const matchingItem = global.videoList.find((item) => item.from === m.sender); + if (matchingItem) { + if (index < matchingItem.urls.length) { + youtubeLink = matchingItem.urls[index]; + } else { + throw `*error*`; + } + } else { + throw `*[❗] Para poder hacer uso del comando de esta forma (${usedPrefix + command} ), example ${usedPrefix}y *`; + } + } else { + throw `*[❗] Para poder hacer uso del comando de esta forma (${usedPrefix + command} ), por favor realiza la busqueda de videos con el comando ${usedPrefix}playlist *`; + } + } + } + const { key } = await conn.sendMessage(m.chat, {text: `*_Mr-Malik Processing your audio_*`}, {quoted: m}); + try { + const formats = await bestFormat(youtubeLink, 'audio'); + const dl_url = await getUrlDl(formats.url); + const buff = await getBuffer(dl_url.download); + const yt_1 = await youtubedl(youtubeLink).catch(async (_) => await youtubedlv2(youtubeLink)); + const ttl_1 = `${yt_1?.title ? yt_1.title : 'Tu_audio_descargado'}`; + const fileSizeInBytes = buff.byteLength; + const fileSizeInKB = fileSizeInBytes / 1024; + const fileSizeInMB = fileSizeInKB / 1024; + const roundedFileSizeInMB = fileSizeInMB.toFixed(2); + if (fileSizeInMB > 50) { + await conn.sendMessage(m.chat, {document: buff, caption: `*β–’ Titulo:* ${ttl_1}\n*β–’ Peso Del Audio:* ${roundedFileSizeInMB} MB`, fileName: ttl_1 + '.mp3', mimetype: 'audio/mpeg'}, {quoted: m}); + await conn.sendMessage(m.chat, {text: `*βœ… Audio Downloded successfully.*\n\n*β€”β—‰ Se envΓ­o en formato de documento debido a que el audio pesa ${roundedFileSizeInMB} MB y supera el limite establecido por WhatsApp.*\n*β—‰ Titulo:* ${ttl_1}`, edit: key}, {quoted: m}); + enviando = false + } else { + await conn.sendMessage(m.chat, {audio: buff, caption: `*β–’ Title:* ${ttl_1}\n*β–’ Size:* ${roundedFileSizeInMB} MB`, fileName: ttl_1 + '.mp3', mimetype: 'audio/mpeg'}, {quoted: m}); + await conn.sendMessage(m.chat, {text: `*βœ… Audio Downloded Successfully.*`, edit: key}, {quoted: m}); + enviando = false + } + } catch { + console.log('noooooo') + try { + const q = '128kbps'; + const v = youtubeLink; + const yt = await youtubedl(v).catch(async (_) => await youtubedlv2(v)); + const dl_url = await yt.audio[q].download(); + const ttl = await yt.title; + const size = await yt.audio[q].fileSizeH; + await conn.sendFile(m.chat, dl_url, ttl + '.mp3', null, m, false, {mimetype: 'audio/mpeg'}); + await conn.sendMessage(m.chat, {text: '*βœ…Audio Downloaded successfully.*', edit: key}, {quoted: m}); + } catch { + try { + const lolhuman = await fetch(`https://api.lolhuman.xyz/api/ytaudio2?apikey=${lolkeysapi}&url=${youtubeLink}`); + const lolh = await lolhuman.json(); + const n = lolh.result.title || 'error'; + await conn.sendMessage(m.chat, {audio: {url: lolh.result.link}, fileName: `${n}.mp3`, mimetype: 'audio/mpeg'}, {quoted: m}); + await conn.sendMessage(m.chat, {text: '*βœ… Audio Downloaded successfully.*', edit: key}, {quoted: m}); + } catch { + try { + const searchh = await yts(youtubeLink); + const __res = searchh.all.map((v) => v).filter((v) => v.type == 'video'); + const infoo = await ytdl.getInfo('https://youtu.be/' + __res[0].videoId); + const ress = await ytdl.chooseFormat(infoo.formats, {filter: 'audioonly'}); + conn.sendMessage(m.chat, {audio: {url: ress.url}, fileName: __res[0].title + '.mp3', mimetype: 'audio/mpeg'}, {quoted: m}); + await conn.sendMessage(m.chat, {text: '*βœ… Audio Downloaded successfully.*', edit: key}, {quoted: m}); + } catch { + await conn.sendMessage(m.chat, {text: `*[ ❌ ] El audio no pudo ser descargado ni enviado, vuelva a intentarlo.*`, edit: key}, {quoted: m}); + throw '*[❗] Error, no fue posible descargar el audio.*'; + } + } + } +}}; +handler.command = /^(audio|a|yt(a|mp3))$/i; +export default handler + +const getBuffer = async (url, options) => { + try { + options ? options : {}; + const res = await axios({ + method: 'get', + url, + headers: { + 'DNT': 1, + 'Upgrade-Insecure-Request': 1, + }, + ...options, + responseType: 'arraybuffer', + }); + + return res.data; + } catch (e) { + console.log(`Error : ${e}`); + } +}; \ No newline at end of file diff --git a/plugins/ytv-play.js b/plugins/ytv-play.js new file mode 100644 index 0000000..52b35a2 --- /dev/null +++ b/plugins/ytv-play.js @@ -0,0 +1,201 @@ +import {youtubedl, youtubedlv2} from '@bochilteam/scraper'; +import fetch from 'node-fetch'; +import yts from 'yt-search'; +import ytdl from 'ytdl-core'; +import axios from 'axios'; +import {bestFormat, getUrlDl} from '../lib/y2dl.js'; +const handler = async (m, {conn, args, usedPrefix, command}) => { + + if (!args[0]) throw 'hello there, ☺ \n*Example usage*\n\n*β—‰ .b(space)(Your number of video)*\n*β—‰ .b 1*'; + +let enviando; + if (enviando) return + enviando = true + let youtubeLink = ''; + if (args[0].includes('you')) { + youtubeLink = args[0]; + } else { + const index = parseInt(args[0]) - 1; + if (index >= 0) { + if (Array.isArray(global.videoList) && global.videoList.length > 0) { + const matchingItem = global.videoList.find((item) => item.from === m.sender); + if (matchingItem) { + if (index < matchingItem.urls.length) { + youtubeLink = matchingItem.urls[index]; + } else { + enviando = false + throw `*[❗] There was no link for that number, please enter a number between 1 and ${matchingitem.urls.length}*`; + } + } else { + enviando = false + throw `*[❗] To be able to use the command in this way(${usedPrefix + command} ), ${usedPrefix}playlist *`; + } + } else { + enviando = false + throw `*[❗] Para poder hacer uso del comando de esta forma (${usedPrefix + command} ), por favor realiza la busqueda de videos con el comando ${usedPrefix}playlist *`; + } + } + } + const { key } = await m.reply(`*_Please wait, Mr malik α΄˜Κ€α΄α΄„α΄‡ssing ur α΄ Ιͺᴅᴇᴏ_*\n\n*β—‰ α΄ Ιͺᴅᴇᴏ ᴄᴏᴍᴀɴᴅ .playdoc2 ᴏ .play4 ᴏ .ytmp4doc β—‰*`); + try { + const formats = await bestFormat(youtubeLink, 'video'); + const buff = await getBuffer(formats.url); + const yt_1 = await youtubedl(youtubeLink).catch(async (_) => await youtubedlv2(youtubeLink)); + const ttl_1 = `${yt_1?.title ? yt_1.title : 'Tu_video_descargado'}`; + const fileSizeInBytes = buff.byteLength; + const fileSizeInKB = fileSizeInBytes / 1024; + const fileSizeInMB = fileSizeInKB / 1024; + const roundedFileSizeInMB = fileSizeInMB.toFixed(2); + if (fileSizeInMB > 100) { + await conn.sendMessage(m.chat, {document: buff, caption: `*β–’ Title:* ${ttl_1}\n*β–’ Size:* ${roundedFileSizeInMB} MB`, fileName: ttl_1 + '.mp4', mimetype: 'video/mp4'}, {quoted: m}); + await conn.sendMessage(m.chat, {text: `*βœ… Video downloded and successfully sent.*\n\n*β€”β—‰ send in document format because the video length ${roundedFileSizeInMB} MB and exceeds the limit by WhatsApp..*\n*β—‰ Title:* ${ttl_1}`, edit: key}, {quoted: m}); + enviando = false + } else { + await conn.sendMessage(m.chat, {video: buff, caption: `*β–’ Title:* ${ttl_1}\n*β–’ Video size:* ${roundedFileSizeInMB} MB`, fileName: ttl_1 + '.mp4', mimetype: 'video/mp4'}, {quoted: m}); + await conn.sendMessage(m.chat, {text: `*[ βœ” ] Video Downloaded.*`, edit: key}, {quoted: m}); + enviando = false + } + } catch (ee) { + console.log(ee) + try { + const qu = args[1] || '360'; + const q = qu + 'p'; + const v = youtubeLink; + const yt = await youtubedl(v).catch(async (_) => await youtubedlv2(v)); + const dl_url = yt.video[q].download(); + const ttl = yt.title; + const size = yt.video[q].fileSizeH; + await conn.sendMessage(m.chat, {video: {url: dl_url}, fileName: `${ttl}.mp4`, mimetype: 'video/mp4', caption: `*β–’ Title:* ${ttl}\n*β–’ Size:* ${size}`, thumbnail: await fetch(yt.thumbnail)}, {quoted: m}); + await conn.sendMessage(m.chat, {text: '*βœ… Video downloaded successfully.🚩*', edit: key}, {quoted: m}); + enviando = false + } catch (ee2) { + console.log(ee2) + try { + const mediaa = await ytMp4(youtubeLink); + await conn.sendMessage(m.chat, {video: {url: mediaa.result}, fileName: `error.mp4`, caption: `Mr-malik`, thumbnail: mediaa.thumb, mimetype: 'video/mp4'}, {quoted: m}); + await conn.sendMessage(m.chat, {text: '*βœ… Video downlowded successfully.*', edit: key}, {quoted: m}); + enviando = false + } catch { + try { + const lolhuman = await fetch(`https://api.lolhuman.xyz/api/ytvideo2?apikey=${lolkeysapi}&url=${youtubeLink}`); + const lolh = await lolhuman.json(); + const n = lolh.result.title || 'error'; + const n2 = lolh.result.link; + const n3 = lolh.result.size; + const n4 = lolh.result.thumbnail; + await conn.sendMessage(m.chat, {video: {url: n2}, fileName: `${n}.mp4`, mimetype: 'video/mp4', caption: `*β–’ Title:* ${n}\n*β–’ Video size:* ${n3}`, thumbnail: await fetch(n4)}, {quoted: m}); + await conn.sendMessage(m.chat, {text: '*[ βœ” ] Video downloaded successfully.*', edit: key}, {quoted: m}); + enviando = false + } catch { + await conn.sendMessage(m.chat, {text: `*[ ❌ ] The video could not be downloaded or sent, try again.*`, edit: key}, {quoted: m}); + throw '*[❗] Error, it was not possible to download the video.*'; + } + } + } +}}; + handler.command = /^(b)$/i; +export default handler; + +function bytesToSize(bytes) { + return new Promise((resolve, reject) => { + const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; + if (bytes === 0) return 'n/a'; + const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10); + if (i === 0) resolve(`${bytes} ${sizes[i]}`); + resolve(`${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`); + }); +} + +async function ytMp3(url) { + return new Promise((resolve, reject) => { + ytdl.getInfo(url).then(async (getUrl) => { + const result = []; + for (let i = 0; i < getUrl.formats.length; i++) { + const item = getUrl.formats[i]; + if (item.mimeType == 'audio/webm; codecs=\"opus\"') { + const {contentLength} = item; + const bytes = await bytesToSize(contentLength); + result[i] = {audio: item.url, size: bytes}; + } + } + const resultFix = result.filter((x) => x.audio != undefined && x.size != undefined); + const tiny = await axios.get(`https://tinyurl.com/api-create.php?url=${resultFix[0].audio}`); + const tinyUrl = tiny.data; + const title = getUrl.videoDetails.title; + const thumb = getUrl.player_response.microformat.playerMicroformatRenderer.thumbnail.thumbnails[0].url; + resolve({title, result: tinyUrl, result2: resultFix, thumb}); + }).catch(reject); + }); +} + +async function ytMp4(url) { + return new Promise(async (resolve, reject) => { + ytdl.getInfo(url).then(async (getUrl) => { + const result = []; + for (let i = 0; i < getUrl.formats.length; i++) { + const item = getUrl.formats[i]; + if (item.container == 'mp4' && item.hasVideo == true && item.hasAudio == true) { + const {qualityLabel, contentLength} = item; + const bytes = await bytesToSize(contentLength); + result[i] = {video: item.url, quality: qualityLabel, size: bytes}; + } + } + const resultFix = result.filter((x) => x.video != undefined && x.size != undefined && x.quality != undefined); + const tiny = await axios.get(`https://tinyurl.com/api-create.php?url=${resultFix[0].video}`); + const tinyUrl = tiny.data; + const title = getUrl.videoDetails.title; + const thumb = getUrl.player_response.microformat.playerMicroformatRenderer.thumbnail.thumbnails[0].url; + resolve({title, result: tinyUrl, rersult2: resultFix[0].video, thumb}); + }).catch(reject); + }); +} + +async function ytPlay(query) { + return new Promise((resolve, reject) => { + yts(query).then(async (getData) => { + const result = getData.videos.slice( 0, 5 ); + const url = []; + for (let i = 0; i < result.length; i++) { + url.push(result[i].url); + } + const random = url[0]; + const getAudio = await ytMp3(random); + resolve(getAudio); + }).catch(reject); + }); +} + +async function ytPlayVid(query) { + return new Promise((resolve, reject) => { + yts(query).then(async (getData) => { + const result = getData.videos.slice( 0, 5 ); + const url = []; + for (let i = 0; i < result.length; i++) { + url.push(result[i].url); + } + const random = url[0]; + const getVideo = await ytMp4(random); + resolve(getVideo); + }).catch(reject); + }); +} + +const getBuffer = async (url, options) => { + try { + options ? options : {}; + const res = await axios({ + method: 'get', + url, + headers: { + 'DNT': 1, + 'Upgrade-Insecure-Request': 1, + }, + ...options, + responseType: 'arraybuffer', + }); + + return res.data; + } catch (e) { + console.log(`Error : ${e}`); + } +}; \ No newline at end of file