Skip to content

Commit

Permalink
Git Pull y RMBG
Browse files Browse the repository at this point in the history
  • Loading branch information
weskerty committed Oct 8, 2024
1 parent dd2da86 commit efc266f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions plugins/propietario-actualizar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const handler = async (m, { conn, text }) => {
const _translate = JSON.parse(fs.readFileSync(`./src/languages/${idioma}.json`));
const tradutor = _translate.plugins.propietario_actualizar;

await conn.reply(m.chat, 'Comprobando...', m);
await conn.reply(m.chat, 'Comprobando...', m);

try {
const stdout = execSync('git pull' + (m.fromMe && text ? ' ' + text : ''));
Expand All @@ -20,7 +20,7 @@ const handler = async (m, { conn, text }) => {
if (messager.includes('Updating')) {
messager = tradutor.texto2 + stdout.toString();

await conn.reply(m.chat, 'Ejecutando NPM Install', m);
await conn.reply(m.chat, ' Install', m);
execSync('npm install --force');
}

Expand Down
25 changes: 18 additions & 7 deletions plugins/sticker-sremovebg.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,61 @@
import { BackgroundRemoval } from '@imgly/background-removal-node';
import { BackgroundRemoval } from '@imgly/background-removal-node';
import fs from 'fs';
import path from 'path';
import { sticker } from '../src/libraries/sticker.js';

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


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, text }) => {
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 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(false, outputPath, global.packname, global.author);

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);
console.error('Error:', error); /
await conn.reply(m.chat, `❌ Error al generar el sticker: ${error.message}`, m); /
}
};

Expand Down

0 comments on commit efc266f

Please sign in to comment.