mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 20:49:15 +00:00
Sensitive case
This commit is contained in:
6
TODO.md
6
TODO.md
@@ -1,6 +1,6 @@
|
|||||||
- [ ] Cuando Envian Sticket devuelve mensaje raro
|
- [ ] Cuando Envian Sticket devuelve mensaje raro
|
||||||
- [ ] Posibilidad de en el capture meter todo un nuevo CTX de FLOW .addAnswer('Marca la opcion',{capture:true, join:CTX})
|
- [X] Posibilidad de en el capture meter todo un nuevo CTX de FLOW .addAnswer('Marca la opcion',{capture:true, join:CTX})
|
||||||
- [ ] .addKeyword('1') no funciona con 1 caracter
|
- [X] .addKeyword('1') no funciona con 1 caracter
|
||||||
- [ ] sensitivy viene activado por defecto
|
- [X] sensitivy viene activado por defecto
|
||||||
- [ ] colocar mensaje esperando conectando whatsapp (provider)
|
- [ ] colocar mensaje esperando conectando whatsapp (provider)
|
||||||
- [ ] fallback respuesta en hijo
|
- [ ] fallback respuesta en hijo
|
||||||
@@ -26,8 +26,24 @@ class FlowClass {
|
|||||||
let refSymbol = null
|
let refSymbol = null
|
||||||
overFlow = overFlow ?? this.flowSerialize
|
overFlow = overFlow ?? this.flowSerialize
|
||||||
|
|
||||||
|
const mapSensitiveString = (str, flag = false) => {
|
||||||
|
if (!flag && Array.isArray(str)) {
|
||||||
|
return str.map((c) => c.toLowerCase())
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flag && typeof str === 'string') {
|
||||||
|
return str.toLowerCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
const findIn = (keyOrWord, symbol = false, flow = overFlow) => {
|
const findIn = (keyOrWord, symbol = false, flow = overFlow) => {
|
||||||
|
const sensitive = refSymbol?.options?.sensitive || false
|
||||||
capture = refSymbol?.options?.capture || false
|
capture = refSymbol?.options?.capture || false
|
||||||
|
|
||||||
|
keyOrWord = mapSensitiveString(keyOrWord, sensitive)
|
||||||
|
|
||||||
if (capture) return messages
|
if (capture) return messages
|
||||||
|
|
||||||
if (symbol) {
|
if (symbol) {
|
||||||
@@ -35,7 +51,9 @@ class FlowClass {
|
|||||||
if (refSymbol?.answer) messages.push(refSymbol)
|
if (refSymbol?.answer) messages.push(refSymbol)
|
||||||
if (refSymbol?.ref) findIn(refSymbol.ref, true)
|
if (refSymbol?.ref) findIn(refSymbol.ref, true)
|
||||||
} else {
|
} else {
|
||||||
refSymbol = flow.find((c) => c.keyword.includes(keyOrWord))
|
refSymbol = flow.find((c) =>
|
||||||
|
mapSensitiveString(c.keyword, sensitive).includes(keyOrWord)
|
||||||
|
)
|
||||||
if (refSymbol?.ref) findIn(refSymbol.ref, true)
|
if (refSymbol?.ref) findIn(refSymbol.ref, true)
|
||||||
return messages
|
return messages
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user