mirror of
https://github.com/cheveguerra/botLeiferAurik-Mod_2.0.git
synced 2026-04-19 12:19:19 +00:00
Inicial
This commit is contained in:
48
appBaileys.js
Normal file
48
appBaileys.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* ⚡⚡⚡ DECLARAMOS LAS LIBRERIAS y CONSTANTES A USAR! ⚡⚡⚡
|
||||
*/
|
||||
require('dotenv').config()
|
||||
global.provider = process.env.PROVIDER || 'wwebjs';
|
||||
const { Client } = require('whatsapp-web.js');
|
||||
const { generateImage, cleanNumber, checkEnvFile, createClient, isValidNumber } = require('./controllers/handle')
|
||||
const { initBot, traeVariables } = require('./provider/baileys')
|
||||
const { sendMedia, sendMessage, lastTrigger, sendMessageButton, sendMessageList, readChat } = require('./controllers/send_baileys');
|
||||
let enviado = false
|
||||
|
||||
function listenMessage(client){
|
||||
client.ev.on('messages.upsert', async msg => {
|
||||
let {from, body, nombre} = traeVariables(msg)
|
||||
if (from === 'status@broadcast' || msg.type !== 'notify') { return }
|
||||
client.theMsg = msg;
|
||||
console.log("######################### INICIO ############################")
|
||||
console.log("from, Body y Nombre = ", "|", from, "|", body, "|", nombre, "|", msg?.type)
|
||||
console.log("CLIENT:", client)
|
||||
// console.log('KEY=', msg.messages.key)
|
||||
// console.log('MESSAGES=', msg.messages)
|
||||
console.log('MESSAGE__=', msg.messages[0])
|
||||
// await sock.sendMessage(m.messages[0].key.remoteJid, { text: 'hola como estas' })
|
||||
if(!enviado) {
|
||||
console.log("########## Enviamos mensaje")
|
||||
sendMessage(client, "5215554192439@s.whatsapp.net", "hola")
|
||||
|
||||
const buttonMessage = [
|
||||
{"body":"boton 1"},
|
||||
{"body":"boton 2"}
|
||||
]
|
||||
|
||||
console.log("Enviamos botones = ", from, buttonMessage)
|
||||
sendMessageButton(client, "5215554192439@s.whatsapp.net", "texto", buttonMessage)
|
||||
|
||||
|
||||
enviado = true
|
||||
}
|
||||
|
||||
})
|
||||
enviado = false
|
||||
}
|
||||
|
||||
async function inicializaBot(){
|
||||
const ib = await initBot()
|
||||
listenMessage(ib)
|
||||
}
|
||||
inicializaBot()
|
||||
Reference in New Issue
Block a user