Skip to content

Instantly share code, notes, and snippets.

@Nick-Gabe
Created April 2, 2022 14:26
Show Gist options
  • Save Nick-Gabe/7cdcc25baafd42292193d18e27a3d32b to your computer and use it in GitHub Desktop.
Save Nick-Gabe/7cdcc25baafd42292193d18e27a3d32b to your computer and use it in GitHub Desktop.
Código pra mandar gatos pelo zap
const { default: axios } = require('axios');
const qrcode = require('qrcode-terminal');
const { Client, MessageMedia } = require('whatsapp-web.js');
const client = new Client();
client.on('qr', (qr) => {
// Generate and scan this code with your phone
qrcode.generate(qr, {small: true});
});
client.on('ready', async () => {
console.log('🧛‍♂️', 'Logged in')
})
client.on('message', async msg => {
if(msg.body.toLowerCase().includes('gato')) {
const url = (await axios.get('https://api.thecatapi.com/v1/images/search'))?.data?.[0].url
const media = await MessageMedia.fromUrl(url, { unsafeMime: true });
msg.reply(media)
}
})
client.initialize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment