mirror of
https://github.com/cheveguerra/Bot-Whatsapp-Buttons.git
synced 2026-04-17 19:26:12 +00:00
Initial commit
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/node_modules
|
||||
/node_modules/*
|
||||
.wwebjs_auth
|
||||
2
README.md
Normal file
2
README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# Bot-Whatsapp-Buttons
|
||||
Ejemplo sencillo de envio de botones
|
||||
43
bot.js
Normal file
43
bot.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const { Client,LocalAuth,Buttons} = require('whatsapp-web.js');
|
||||
const qrcode = require('qrcode-terminal');
|
||||
|
||||
client = new Client({
|
||||
authStrategy: new LocalAuth(),
|
||||
puppeteer: { headless: true }
|
||||
|
||||
|
||||
});
|
||||
client.on('qr', qr => {
|
||||
qrcode.generate(qr, {small: true});
|
||||
});
|
||||
|
||||
client.on('authenticated', () => {
|
||||
console.log('AUTHENTICATED');
|
||||
});
|
||||
|
||||
client.on('loading_screen', (percent, message) => {
|
||||
console.log('LOADING SCREEN', percent, message);
|
||||
});
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log('Client is ready!');
|
||||
});
|
||||
|
||||
client.on('message', msg => {
|
||||
console.log(msg);
|
||||
if (msg.body == '!ping') {
|
||||
msg.reply('pong');
|
||||
}else if (msg.body === '!buttons') {
|
||||
let button = new Buttons('Button body',[{body:'bt1'},{body:'bt2'},{body:'bt3'}],'title','footer');
|
||||
client.sendMessage(msg.from, button);
|
||||
}else if (msg.body ==='bt1'){
|
||||
client.sendMessage(msg.from, 'Este es el boton 1');
|
||||
}else if (msg.body ==='bt2'){
|
||||
client.sendMessage(msg.from, 'Este es el boton 2');
|
||||
}else if (msg.body ==='bt3'){
|
||||
client.sendMessage(msg.from,'Este es el boton 3');
|
||||
}
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
|
||||
1209
package-lock.json
generated
Normal file
1209
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
package.json
Normal file
16
package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "bot-whatsapp-botones",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "bot.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"qrcode-terminal": "^0.12.0",
|
||||
"whatsapp-web.js": "github:cheveguerra/whatsapp-web.js#WaWJS"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user