mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 12:39:24 +00:00
external downlaod
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
const {connection} = require('../config/mysql')
|
||||
|
||||
const getData = (option_key = '', callback) => connection.query(`SELECT * FROM db_test.keywords WHERE option_key = '${option_key}' LIMIT 1`,(error, results, fields) => {
|
||||
getData = (message = '', callback) => connection.query(
|
||||
`SELECT * FROM db_test.keywords WHERE value LIKE '%${message}%' LIMIT 1`,
|
||||
(error, results
|
||||
) => {
|
||||
const [response] = results
|
||||
let parseResponse = response?.value || '';
|
||||
parseResponse = parseResponse.split(',') || []
|
||||
callback(parseResponse)
|
||||
const key = response?.option_key || null
|
||||
callback(key)
|
||||
});
|
||||
module.exports = {getData}
|
||||
|
||||
|
||||
getReply = (option_key = '', callback) => connection.query(
|
||||
`SELECT * FROM db_test.replies WHERE option_key = '${option_key}' LIMIT 1`,
|
||||
(error, results
|
||||
) => {
|
||||
const [response] = results
|
||||
const value = {
|
||||
replyMessage:response?.value || '',
|
||||
trigger:response?.trigger || '',
|
||||
media:response?.media || ''
|
||||
}
|
||||
callback(value)
|
||||
});
|
||||
|
||||
module.exports = {getData, getReply}
|
||||
Reference in New Issue
Block a user