Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
weskerty committed Oct 8, 2024
1 parent efc266f commit b2e13be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 65 deletions.
11 changes: 0 additions & 11 deletions plugins/nv-a.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,3 @@ const handler = async (m, {conn}) => {
handler.customPrefix = /ª|a|A/
handler.command = /^(a|ª|A?$)/
export default handler;

/*
let handler = async (m, { conn }) => {
if (!db.data.chats[m.chat].audios && m.isGroup) throw 0
let vn = './src/assets/audio/./src/assets/audio/01J672JMF3RCG7BPJW4X2P94N2.mp3'
conn.sendPresenceUpdate('recording', m.chat)
conn.sendMessage(m.chat, { audio: { url: vn }, contextInfo: { "externalAdReply": { "title": `👑 MysticMOD 👑`, "body": `=> ᴀᴜᴅɪᴏ ᴀᴜᴛᴏᴍᴀᴛɪᴄᴏ`, "previewType": "PHOTO", "thumbnailUrl": null,"thumbnail": imagen1, "sourceUrl": `https://github.com/weskerty/TheMysticMOD`, "showAdAttribution": true}}, seconds: '4556', ptt: true, mimetype: 'audio/mpeg', fileName: `error.mp3` }, { quoted: m })}
handler.customPrefix = /ª|a|A/
handler.command = /^(a|ª|A?$)/
export default handler
*/
69 changes: 15 additions & 54 deletions plugins/sticker-sremovebg.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,24 @@
import { BackgroundRemoval } from '@imgly/background-removal-node';
import fs from 'fs';
import path from 'path';
import { sticker } from '../src/libraries/sticker.js';
import uploadImage from '../src/libraries/uploadImage.js';
import {sticker} from '../src/libraries/sticker.js';

const TempDirectory = path.join(process.cwd(), 'src/tmp/');

const handler = async (m, {conn, text}) => {
const datas = global
const idioma = datas.db.data.users[m.sender].language || global.defaultLenguaje
const _translate = JSON.parse(fs.readFileSync(`./src/languages/${idioma}.json`))
const tradutor = _translate.plugins.sticker_sremovebg

const generateTempFileName = () => {
const now = new Date();
const timestamp = now.toISOString().replace(/[-:.]/g, '');
return `temp-${timestamp}.png`;
};


if (!fs.existsSync(TempDirectory)) {
fs.mkdirSync(TempDirectory, { recursive: true });
}

const handler = async (m, { conn }) => {
try {

await m.reply('🛠️ Generando sticker...');

const q = m.quoted ? m.quoted : m;
const q = m.quoted ? m.quoted : m;
const mime = (q.msg || q).mimetype || '';


if (!mime || !mime.startsWith('image/')) {
await conn.reply(m.chat, '❌ Por favor, envíe una imagen válida.', m);
return;
}

const img = await q.download();


const inputPath = path.join(TempDirectory, generateTempFileName());
const outputPath = path.join(TempDirectory, generateTempFileName());


fs.writeFileSync(inputPath, img);


await BackgroundRemoval.fromFile(inputPath).toFile(outputPath);


const stickerResult = await sticker(fs.readFileSync(outputPath), null, global.packname, global.author);


await conn.sendFile(m.chat, stickerResult, 'sticker.webp', '', m, { asSticker: true });


fs.unlinkSync(inputPath);
fs.unlinkSync(outputPath);

} catch (error) {
console.error('Error:', error); /
await conn.reply(m.chat, `❌ Error al generar el sticker: ${error.message}`, m); /
const img = await q.download();
const url = await uploadImage(img);
const sremovebg = global.API(`https://api.lolhuman.xyz/api/removebg?apikey=${lolkeysapi}&img=${url}`);
const stickerr = await sticker(false, sremovebg, global.packname, global.author);
conn.sendFile(m.chat, stickerr, 'sticker.webp', '', m, {asSticker: true});
} catch (e) {
m.reply(tradutor.texto1);
}
};

handler.command = /^sremovebg|rmbg$/i;
export default handler;

0 comments on commit b2e13be

Please sign in to comment.