-
-
Save esteves67/83a8c07f54c18b9f44933e40e375ba12 to your computer and use it in GitHub Desktop.
WA-Automate codes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { decryptMedia } = require('@open-wa/wa-decrypt') | |
const mime = require('mime-types') | |
const nrc = require('node-run-cmd') | |
const fs = require('fs-extra') | |
const sizeOf = require('image-size') | |
const buffer = await decryptMedia(message) | |
const fileName = `temp${from}.${mime.extension(mimetype)}` | |
fs.writeFile(fileName, buffer, function (err) {}) | |
await nrc.run(`convert ${fileName} ${from}.png`) | |
var dimensions = await sizeOf(`${from}.png`) | |
console.log(dimensions) | |
//await nrc.run('convert '+ from + '.png -resize 64x64\! ' + from + '.png') | |
if (dimensions.width < dimensions.height) { | |
let cmd = 'mogrify -bordercolor transparent -border ' + (dimensions.height - dimensions.width) / 2 +' '+ from + '.png' | |
console.log(cmd) | |
await nrc.run(cmd) | |
} else if (dimensions.width > dimensions.height) { | |
let cmd = 'mogrify -bordercolor transparent -border 0x' + (dimensions.width - dimensions.height) / 2 +' '+ from + '.png' | |
//this is just to see which command is being executed | |
console.log(cmd) | |
await nrc.run(cmd) | |
} else { | |
} | |
const stickerData = await fs.readFile(`${from}.png`, {encoding: 'base64'}) | |
console.log(stickerData.length) | |
client.sendImageAsSticker(from, `data:image/png;base64,${stickerData.toString('base64')}`) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment