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.14k stars 600 forks source link

Feature: Support sticker decryption (animated + non animated) #580

Closed smashah closed 4 years ago

smashah commented 4 years ago

@github-actions run

âš¡ Release! âš¡ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i`); exec(`npm run release-ci`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 4 years ago

Changelog

🚀 Release 1.9.103 (2020-07-21)

smashah commented 4 years ago

You are now able to decrypt sticker's (including animated stickers):


      let mediaData;
      if( message.type==='sticker') {
        let stickerDecryptable = await client.getStickerDecryptable(message.id);
        mediaData = await decryptMedia(stickerDecryptable);
      } else {
        mediaData = await decryptMedia(message);
      }

      fs.writeFile(filename, mediaData, function(err) {
        if (err) {
          return console.log(err);
        }
        console.log('The file was saved!');
      });

Note: This is an Insider's feature for now and requires a license key.

https://open-wa.github.io/wa-automate-nodejs/classes/client.html#getstickerdecryptable

MarsVard commented 4 years ago

can you explain in more detail what this does?

smashah commented 4 years ago

@MarsVard Without this, the decrypt method will result in a transparent empty webp file as that is the background of the sticker.

With getStickerDecryptable, the actual sticker message is retrieved which will allow the decrypt function to output the sticker (including an animated sticker).