This commit is contained in:
2023-03-01 04:39:01 -06:00
parent 264bc5984f
commit 6f5885ff7d
2 changed files with 7 additions and 7 deletions

View File

@@ -83,7 +83,7 @@ const createClient = () => {
const isValidNumber = (rawNumber) => { const isValidNumber = (rawNumber) => {
const regexGroup = /\@g.us\b/gm; const regexGroup = /\@g.us\b/gm;
const exist = rawNumber.match(regexGroup); const exist = rawNumber.match(regexGroup);
console.log("IsValidWawebJS", rawNumber, exist, !exist) // console.log("IsValidWawebJS", rawNumber, exist, !exist)
return !exist return !exist
} }

View File

@@ -63,19 +63,19 @@ initBot = async () => {
let waReady = false let waReady = false
// Socket IO // Socket IO
io.on('connection', async function (socket) { io.on('connection', async function (socket) {
console.log("Conectando ...") // console.log("Conectando ...")
socket.emit('ioStatus', socketioStatus); socket.emit('ioStatus', socketioStatus);
socks = socket socks = socket
await socket.emit('message', 'Conectando...'); await socket.emit('message', 'Conectando...');
socket.on('checkConn', async function () { // Si recibe mensaje, regresa "connOk" socket.on('checkConn', async function () { // Si recibe mensaje, regresa "connOk"
console.log("checking conn") // console.log("checking conn")
await socket.emit('connOk', 'Connected'); await socket.emit('connOk', 'Connected');
}) })
try { try {
client.on('message', msg => { client.on('message', msg => {
// console.log(msg) // console.log(msg)
console.log(waReady) // console.log(waReady)
socketioStatus = "wa_msg"; socket.emit('ioStatus', socketioStatus); socket.emit('wa_msg', msg.body); socketioStatus = "wa_msg"; socket.emit('ioStatus', socketioStatus); socket.emit('wa_msg', msg.body);
socket.emit('incomming', 'Message In') socket.emit('incomming', 'Message In')
waReady = true waReady = true
@@ -145,7 +145,7 @@ initBot = async () => {
body('number').notEmpty(), body('number').notEmpty(),
body('message').notEmpty(), body('message').notEmpty(),
], async (req, res) => { ], async (req, res) => {
console.log("REQUEST=", req.body) // console.log("REQUEST=", req.body)
socks.emit('incomming', 'Message In') socks.emit('incomming', 'Message In')
const errors = validationResult(req).formatWith(({ const errors = validationResult(req).formatWith(({
msg msg
@@ -181,7 +181,7 @@ initBot = async () => {
}); });
// Send buttons // Send buttons
app.post('/send-buttons', async (req, res) => { app.post('/send-buttons', async (req, res) => {
console.log("REQUEST=", req.body) // console.log("REQUEST=", req.body)
socks.emit('incomming', 'Button In') socks.emit('incomming', 'Button In')
if (client.theMsg === undefined) { if (client.theMsg === undefined) {
@@ -224,7 +224,7 @@ initBot = async () => {
}); });
// Send image // Send image
app.post('/send-image', async (req, res) => { app.post('/send-image', async (req, res) => {
console.log("REQUEST=", req.body) // console.log("REQUEST=", req.body)
socks.emit('incomming', 'Image In') socks.emit('incomming', 'Image In')
const number = phoneNumberFormatter(req.body.number); const number = phoneNumberFormatter(req.body.number);
// const filename = req.body.image || null; // const filename = req.body.image || null;