Created
April 2, 2022 14:26
-
-
Save Nick-Gabe/7cdcc25baafd42292193d18e27a3d32b to your computer and use it in GitHub Desktop.
Código pra mandar gatos pelo zap
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 { 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