Skip to content

Commit

Permalink
Dl fix (#70)
Browse files Browse the repository at this point in the history
* improved

* improved

* fix

* let's hope it works

* Update img-wallpaper.js

* Update package.json
  • Loading branch information
Guru322 authored Jul 29, 2023
1 parent f0d0922 commit 6c986f3
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 85 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"dependencies": {
"@adiwajshing/baileys": "npm:@whiskeysockets/baileys@^6.0.1",
"@adiwajshing/keyed-db": "^0.2.4",
"@bochilteam/scraper": "^3.0.0",
"@bochilteam/scraper": "^4.2.3",
"awesome-phonenumber": "^3.4.0",
"acrcloud": "^1.4.0",
"@shineiichijo/marika": "^2.0.6",
Expand Down
40 changes: 30 additions & 10 deletions plugins/GURU-Davinci.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
import fetch from 'node-fetch';

let handler = async (m, { conn, text, usedPrefix, command }) => {
if (!text) throw `*This command generates image from texts*\n\n*β€”β—‰ 𝙴xample usage*\n*β—‰ ${usedPrefix + command} Netaji subhas bose*\n*β—‰ ${usedPrefix + command} hatsune miku best*`
try {
m.reply('*Processing image *')
let tiores = await conn.getFile(`https://api.lolhuman.xyz/api/dall-e?apikey=${lolkeysapi}&text=${text}`)
await conn.sendFile(m.chat, tiores.data, null, null, m)
} catch {
throw `*INTERNAL ERROR*`
}}
handler.command = ['ai2', 'dalle', 'gen', 'gimg', 'openai2']
export default handler
if (!text) throw `*This command generates image from texts*\n\n*𝙴xample usage*\n*β—‰ ${usedPrefix + command} Beautiful animegirl*\n*β—‰ ${usedPrefix + command} elon musk in pink output*`;

try {
m.reply('*Please wait, generating images...*');

const response = await fetch(`https://gurugpt4-85987f3ed9b3.herokuapp.com/api/imgai?prompt=${encodeURIComponent(text)}&count=2`);
const data = await response.json();


if (data.images && Array.isArray(data.images)) {

for (const image of data.images) {
const imageResponse = await fetch(image.url);
const imageBuffer = await imageResponse.buffer();


await conn.sendFile(m.chat, imageBuffer, null, null, m);
}
} else {
throw '*Image generation failed*';
}
} catch {
throw '*Oops! Something went wrong while generating images. Please try again later.*';
}
};

handler.command = ['ai2', 'dalle', 'gen', 'gimg', 'openai2'];
export default handler;
11 changes: 4 additions & 7 deletions plugins/GURU-Openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ let handler = async (m, { text, usedPrefix, command }) => {
if (!text) throw `*Enter a request or an order to use ChatGpt*\n\n*Example*\n* ${usedPrefix + command} Latest Netflix series*\n* ${usedPrefix + command} write a JS code*`;

try {
const response = await fetch(`https://guru-scrapper.cyclic.app/api/chatgpt?query=${encodeURIComponent(text)}`);
const response = await fetch(`https://gurugpt4-85987f3ed9b3.herokuapp.com/api/gpt4?query=${encodeURIComponent(text)}`);
const data = await response.json();
const { text: result } = data.data || {};
const model = data.data?.detail?.model;
const creator = data.creator || '';
const fullResult = `${result}\n\nModel: ${model}\nCreator: ${creator}`;
m.reply(fullResult.trim());
const { response: result } = data;
m.reply(result.trim());
} catch (error) {
console.error('Error:', error); // Log the error
console.error('Error:', error);
throw `*ERROR*`;
}
};
Expand Down
62 changes: 27 additions & 35 deletions plugins/dl-tiktok.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
import { tiktokdl } from '@bochilteam/scraper';

import fg from 'api-dylux'
import { tiktokdl, tiktokdlv2, tiktokdlv3 } from '@bochilteam/scraper'
let handler = async (m, { conn, text, args, usedPrefix, command }) => {
if (!args[0]) throw `✳️ Enter a TikTok link\n\nπŸ“Œ Example: ${usedPrefix + command} https://vm.tiktok.com/ZMYG92bUh/`;
if (!args[0].match(/tiktok/gi)) throw `❎ Verify that the link is from TikTok`;

let handler = async (m, { conn, text, args, usedPrefix, command}) => {
if (!args[0]) throw `✳️ Enter a Tiktok link\n\n πŸ“Œ Example : ${usedPrefix + command} https://vm.tiktok.com/ZMNqyusVD/?k=1`
if (!args[0].match(/tiktok/gi)) throw `❎ verify that the link is from tiktok`
m.react(rwait)
try {
const { author: { nickname }, video, description } = await tiktokdl(args[0]);
const url = video.no_watermark || video.no_watermark2 || video.no_watermark_raw;
if (!url) throw '❎ Error downloading the video';

try {
let p = await fg.tiktok(args[0])
let te = `

conn.sendFile(m.chat, url, 'tiktok.mp4', `
β”Œβ”€βŠ· TIKTOK
β–’ *Username:* ${p.unique_id}
β–’ *Description:* ${p.title}
β–’ *Duration:* ${p.duration}
└───────────`
conn.sendFile(m.chat, p.play, 'tiktok.mp4', te, m)
m.react(done)
} catch {
const { author: { nickname }, video, description } = await tiktokdl(args[0])
.catch(async _ => await tiktokdlv2(args[0]))
.catch(async _ => await tiktokdlv3(args[0]))
const url = video.no_watermark2 || video.no_watermark || 'https://tikcdn.net' + video.no_watermark_raw || video.no_watermark_hd
if (!url) throw '❎ Error downloading the video'
conn.sendFile(m.chat, url, 'fb.mp4', `
β”Œβ”€βŠ· *TIKTOK DL*
β–’ *Username:* ${nickname} ${description ? `\nβ–’ *Description:* ${description}` : ''}
└───────────`, m)
m.react(done)
}

}
handler.help = ['tiktok']
handler.tags = ['dl']
handler.command = /^(tiktok|ttdl|tiktokdl|tiktoknowm)$/i
handler.diamond = true

export default handler
β–’ *Nickname:* ${nickname} ${description ? `\nβ–’ *Description:* ${description}` : ''}
└───────────`, m);
} catch (error) {
// Log the error
console.error('Error downloading TikTok video:', args[0], error);

m.reply(`❎ Error downloading the video`);
}
};

handler.help = ['tiktok'];
handler.tags = ['dl'];
handler.command = /^(tiktok|ttdl|tiktokdl|tiktoknowm)$/i;


export default handler;
58 changes: 35 additions & 23 deletions plugins/dl-yta.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
import { youtubedl, youtubedlv2, youtubedlv3 } from '@bochilteam/scraper'
import fetch from 'node-fetch'
let handler = async (m, { conn, args }) => {
if (!args[0]) throw '*[β—πˆππ…πŽβ—] SEARCH YOUTUBE / YOUTUBE 𝙻𝙸𝙽𝙺*'
await m.reply(`*_⏳processing α΄€α΄œα΄…Ιͺᴏ...⏳_*\n\n*β—‰ command #playdoc ᴏ #play.2 ᴏ #ytmp4doc β—‰*`)
try {
let q = '128kbps'
let v = args[0]
const yt = await youtubedl(v).catch(async _ => await youtubedlv2(v)).catch(async _ => await youtubedlv3(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/mp4' })
} catch {
try {
let lolhuman = await fetch(`https://api.lolhuman.xyz/api/ytaudio2?apikey=${lolkeysapi}&url=${args[0]}`)
let lolh = await lolhuman.json()
let n = lolh.result.title || 'error'
await conn.sendMessage(m.chat, { audio: { url: lolh.result.link }, fileName: `${n}.mp3`, mimetype: 'audio/mp4' }, { quoted: m })
} catch {
await conn.reply(m.chat, '*[❗]AUDIO ERROR*', m)}
}}
handler.command = /^fgmp3|dlmp3|getaud|yt(a|mp3)$/i
import { youtubedl, youtubedlv2 } from '@bochilteam/scraper';

let handler = async (m, { conn, text, args, isPrems, isOwner, usedPrefix, command }) => {
if (!args || !args[0]) throw `✳️ Example :\n${usedPrefix + command} https://youtu.be/YzkTFFwxtXI`;
if (!args[0].match(/youtu/gi)) throw `❎ Verify that it is a YouTube link.`;

m.react(rwait);

try {
let q = '128kbps';
let v = args[0];
const yt = await youtubedl(v).catch(async () => await youtubedlv2(v));
const dl_url = await yt.audio[q].download();
const title = await yt.title;

conn.sendFile(
m.chat,
dl_url,
title + '.mp3',
null,
m,
false,
{ mimetype: 'audio/mpeg' }
);

m.react(xmoji);
} catch {
await m.reply(`❎ Error: Could not download the audio.`)
}
};

handler.help = ['ytmp3 <url>']
handler.tags = ['dl']
handler.command = ['ytmp3', 'yta']

export default handler
32 changes: 23 additions & 9 deletions plugins/img-wallpaper.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { wallpaper, wallpaperv2 } from '@bochilteam/scraper'
import { wallpaper } from '@bochilteam/scraper';
import fetch from 'node-fetch';

let handler = async (m, { conn, text, usedPrefix, command }) => {
if (!text) throw `*EXAMPLE USAGE ${usedPrefix + command} Minecraft*`
const res = await (/2/.test(command) ? wallpaperv2 : wallpaper)(text)
const img = res[Math.floor(Math.random() * res.length)]
conn.sendFile(m.chat, img, 'error.jpg', `*πšπ™΄πš‚πš„π™»πšƒ ${text}*`, m)
}
handler.help = ['', '2'].map(v => 'wallpaper' + v + ' <query>')
handler.tags = ['downloader']
handler.command = /^(wallpaper2?)$/i
if (!text) throw `*EXAMPLE USAGE ${usedPrefix + command} Minecraft*`;


const res = await wallpaper(text);
const url = res[Math.floor(Math.random() * res.length)];

// Use fetch to fetch the image using the URL
const response = await fetch(url);

// Use 'arrayBuffer()' instead of 'buffer()'
const buffer = await response.arrayBuffer();


conn.sendFile(m.chat, buffer, 'wallpaper.jpg', `*${text}*`, m);
};

handler.help = [''].map(v => 'wallpaper' + v + ' <query>');
handler.tags = ['downloader'];
handler.command = /^(wallpaper)$/i;

export default handler

0 comments on commit 6c986f3

Please sign in to comment.