open-wa / wa-automate-nodejs

πŸ’¬ πŸ€– The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.05k stars 588 forks source link

Error "STICKER_TOO_LARGE" on files less then 1mb big, even 200kB ones fail? #3175

Open TVARecordings opened 3 months ago

TVARecordings commented 3 months ago

Are you using the latest version of the library?

What type of session are you experiencing this issue on?

Multi-device and I have set multiDevice to true in my config OR am using the --multi-device flag

What type of host account are you experiencing this issue on?

Business account

Mode

EASY API/CLI

Current Behavior

Dear,

Sometimes when users send in media or a url to be converted into a WA-Sticker, it returns the error _"Error processing media: STICKER_TOOLARGE: maxContentLength size of 1500000 exceeded".

However, i've inspected multiple of those errors and 9 out of 10 cases, it was NOT too big.

Usually it errors when media is 10+ seconds, even though the media is of low quality (FPS, resolution) and perhaps only 300kB's big.

Expected Behavior

Properly return the sent media as a sticker.

Steps To Reproduce

Code:

} else if (message.type === 'chat') {
              try {

                let splitmessage = mediaMessage.body.split(' ')[1] || mediaMessage.caption.split(' ')[1]
                let link = splitmessage.toString()
                console.log(`Link = ${link}`)
                if (splitmessage.startsWith('http') || splitmessage.startsWith('www') || splitmessage.startsWith('https')) {
                  console.log(`sendStickerfromUrl`)
                  // Create a new Date object to get the current date
                  const currentDate = new Date();
                  const day = currentDate.getDate().toString().padStart(2, '0'); // Get the day and pad with leading zero if needed
                  const month = (currentDate.getMonth() + 1).toString().padStart(2, '0'); // Get the month (months are zero-based) and pad with leading zero if needed
                  const year = currentDate.getFullYear().toString().slice(-2); //
                  //await client.sendStickerfromUrl(from, splitmessage, {}, { crop: false, startTime: '00:00:00.0', endTime: '00:00:09.0', loop: 0, author: `πŸ€– Ameca ${day}/${month}/${year}`, pack: `πŸ“± www.tva-community.chat`, keepScale: true, discord: '234717932175884288' })
                  await client.sendStickerfromUrl(from, link, {},{author: `πŸ€– Ameca ${day}/${month}/${year}`, pack: `πŸ“± www.tva-community.chat`})
                  if (IsBotChat) {
                    await client.sendStickerfromUrl(`120363030456570843@g.us`, link,{}, { author: `πŸ€– Ameca ${day}/${month}/${year}`, pack: `πŸ“± www.tva-community.chat`})
                    //client.sendStickerfromUrl(`120363030456570843@g.us`, splitmessage, {}, { crop: false, startTime: '00:00:00.0', endTime: '00:00:09.0', loop: 0, author: `πŸ€– Ameca ${day}/${month}/${year}`, pack: `πŸ“± www.tva-community.chat`, keepScale: true, discord: '234717932175884288' });
                  }
                } else {
                  client.reply(from, `Please, send an \`\`\`GIF/IMAGE\`\`\` or a \`\`\`URL\`\`\` with your message\nMake sure url's start with 'http', 'https' or 'www'`, id);
                }

              } catch (error) {
                errorLog(`Error processing "message.type === chat" for case 'sticker': ${error}`)
                console.error(error)
                client.sendTextWithMentions(from, `@${message.sender.id.split('@')[0]}: ${error}`)
              };

A link that does result in error: https://c.tenor.com/asuzYlr9bmAAAAAd/tenor.gif According program "MediaInfo" on my PC: Format: GIF Format/Info: Graphics Interchange Format Format profile: 89a (don't know what this means...) Width: 554 pixels Height: 640 pixels Compression Mode: Lossless

create() code OR full CLI command + CONFIG

const configObject = {
  sessionId: '???',
  authTimeout: 0,
  cacheEnabled: false,
  useChrome: true,
  cachedPatch: true, // Setting this to true will save a local copy of the patches.json file (as patches.ignore.data.json) which will be used in subsequent instantiations of the session.
  devtools: false,
  // chromiumArgs: ['--no-sandbox'],
  disableSpins: true,
  headless: true, //new
  popup: false,
  qrTimeout: 0,
  messagePreprocessor: "AUTO_DECRYPT", //"AUTO_DECRYPT","SCRUB"
  linkParser: "https://link.openwa.cloud/api",
  restartOnCrash: startBot,
  logInternalEvents: false, //ONLY TURN THIS ON IF ASKED TO!
  discord: '???',
  ezqr: true,
  //callTimeout: 60000, // 600000
  licenseKey: "???", // Ain't sharing that :D
  screenshotOnInitializationBrowserError: false,
  //maxchats: 15,
  ensureHeadfulIntegrity: true,
  hostNotificationLang: 'nl-nl',
  killProcessOnBrowserClose: true,
  killProcessOnTimeout: false,
  logConsole: false,
  logConsoleErrors: true,
  logFile: true,
  onError: "LOG_AND_FALSE",
  //pQueueDefault: true,
  //intervalCap: 4,
  // interval: 2000,
  // concurrency: 1,
  // timeout: 100, 
  // carryoverConcurrencyCount: true 
};

DEBUG INFO

{
  "WA_VERSION": "2.2411.2",
  "WA_AUTOMATE_VERSION": "4.68.0",
  "BROWSER_VERSION": "Chrome/122.0.6261.112",
  "START_TS": 1710289040067,
  "RAM_INFO": "Total: 68.62 GB | Free: 47.40 GB",
  "PPTR_VERSION": "19.11.1",
  "LATEST_VERSION": true,
  "CLI": false,
  "PATCH_HASH": "CACHED-67662",
  "LAUNCH_TIME_MS": 14946,
  "ACC_TYPE": "BUSINESS",
  "chats": 112,
  "messages": 198,
  "contacts": 3172,
  "isBiz": true,
  "isMd": true,
  "INSTANCE_ID": "2695ea9e-30a7-48f6-8836-00c070035e92"
}

Environment

- OS: Windows 10
- Node: 20.11.1
- npm: 10.2.4

Screenshots/Logs

No response

Anything else?

Please, allow users to convert larger file sizes (Perhaps make it a paid feature :D )

Vinnybrunn00 commented 3 months ago

Hello, @TVARecordings.

I've never used the sendStickerfromUrl() function, but I've had this same problem with sendMp4AsSticker().

I solved the problem by adding endTime to the processOptions? parameter.

here is an example:

if (message.type === 'image' || message.type === 'video') {
            const isType = message.type
            if (message.caption === '!sticker') {
                if (message.chat.isGroup) {
                    await bot.sendReplyWithMentions(message.chat.id, `\`\`\`[${timers}] - Solicitado por ${message.notifyName}\`\`\` \n\nAguarde...βŒ›`, message.id)
                    const decrypt = await decryptMedia(message)
                    const sticker = `data:${message.mimetype};base64,${decrypt.toString('base64')}`
                    if (isType === 'image') {
                        await bot.sendImageAsSticker(message.chat.id, sticker, {
                            author: `${message.notifyName}`,
                            keepScale: true,
                            pack: 'hubberBot',
                        })
                        await utils.saveLog(pathLog, `${timersLog}: [${author}] [INFO] Gerando sticker com imagem... '${message.chat.name}' => [ !sticker ]`)
                        return;
                    }
                    await bot.sendMp4AsSticker(message.chat.id, sticker, { endTime: '00:00:07.0' }, {
                        author: `${message.notifyName}`,
                        pack: 'hubberBot',
                    })
                    await utils.saveLog(pathLog, `${timersLog}: [${author}] [INFO] Gerando sticker com vΓ­deo... '${message.chat.name}' => [ !sticker ]`)
                    return;
                }
            }
        }

Based on this example, with several tests I did, wa-automate does not accept generating animated stickers longer than 8 seconds.

I hope it helps! :)