orkestral / venom

Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp.
https://orkestral.io
Apache License 2.0
6.03k stars 1.17k forks source link

sendImageAsSticker - Erros! #2501

Closed victorfreire100 closed 5 months ago

victorfreire100 commented 11 months ago

This is my code: case '!s': if (isMedia || quotedMsg) { const msgData = isMedia ? message : quotedMsg; var stickerMetadata = { author: process.env.NOME_AUTOR_FIGURINHAS.trim(), pack: ${process.env.NOME_AUTOR_FIGURINHAS.trim()} Stickers, keepScale: true, circle: false, discord: "155111" } console.log(process.env.NOME_AUTOR_FIGURINHAS)

                if (msgData.type === 'image') {
                    try {
                        const buffer = await client.decryptFile(msgData);           
                        const fileName = `temp-image.${mime.extension(msgData.mimetype)}`;
                        await fs.promises.writeFile(fileName, buffer);
                        console.log(fileName)

                        await client.sendImageAsSticker(from, fileName, stickerMetadata);
                        console.log('Sticker sent successfully');

                        fs.unlinkSync(fileName);
                    } catch (error) {
                        console.error('Error when sending sticker: ', error);
                        client.reply(from, "Desculpe, não consegui enviar a figurinha.", id);
                    }
                } else {
                    client.reply(from, "Por favor, envie ou cite uma imagem para converter em figurinha.", id);
                }
            }
            break;

The problem is: The sticker on WhatsApp web appears normally, but on the cell phone it says that it is not valid according to the screenshot. Another problem is that you are not getting the titles for the sticker. Maybe this is the reason?

llzmbbtz commented 10 months ago

Same problem here.

"create({ session: 'chat-bot', disableWelcome: true, }).then(async (client: Whatsapp) => { client.onMessage(async (message: Message) => { if (message.type === 'image' && message.caption === '/sticker') { try { const buffer = await client.decryptFile(message);

    if (buffer) {
      const fileExtension = message.mimetype.split('/')[1];
      const fileName = `temp-image.${fileExtension}`;
      const outputPath = path.join('C:\\Users\\bruno\\Desktop\\bruno bot\\downloaded-media', fileName);
      await fs.promises.writeFile(outputPath, buffer);

      const outputPathPNG = path.join('C:\\Users\\b\\Desktop\\bot\\downloaded-media', 'temp-image.png');
      await sharp(outputPath)

.resize(512, 512) .png() .toFile(outputPathPNG);

await client .sendImageAsSticker(message.from, outputPathPNG) .then((result) => { console.log('Result: ', result); }) .catch((error) => { console.error('Error when sending: ', error); });

      fs.unlinkSync(outputPath);
      fs.unlinkSync(outputPathPNG);
    }
  } catch (err) {
    console.error('Error processing the image:', err);
  }"

For some reason the sticker only appears on Whatsappweb. I'm using "venom-bot": "^5.0.21". ;

"import { ChatCompletionRequestMessage, ChatCompletionRequestMessageRoleEnum } from 'openai'; import { create, Whatsapp, Message } from 'venom-bot'; import { openai } from './lib/openai'; import fs from 'fs'; import path from 'path'; const sharp: any = require('sharp');"

Ygohel18 commented 9 months ago

Same here sticker sending is not working.

arifintajul4 commented 7 months ago

some here, sticker cant be download

orkestral commented 5 months ago

New Release: npm i venom-bot@5.1.0 We have support for Venom for just $15 per month, if you are interested, call our support via the link: https://web.whatsapp.com/send?phone=5561985290357