diff --git a/admin/index.html b/admin/index.html
new file mode 100644
index 0000000..eea91ec
--- /dev/null
+++ b/admin/index.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Segunda Página
+
+
+
+
+
+
+
+
+
diff --git a/admin/index.js b/admin/index.js
new file mode 100644
index 0000000..a786a26
--- /dev/null
+++ b/admin/index.js
@@ -0,0 +1,16 @@
+import PLB from '../js/tst.js';
+const analizador = new PLB();
+var db = analizador.db
+var cacon = document.querySelector('lista-preguntas-container')
+function Mostrar(){
+ var transaction = bd.transaction(["pregntasyrespuestas"]);
+ var almacen = transaction.objectStore("pregntasyrespuestas");
+ var p = almacen.openCursor()
+ p.addEventListener("success",mostrarinfo)
+}
+function mostrarinfo(evento){
+ var p = evento.target.result;
+ if(p){
+ cacon.innerHTML= "jalo we"
+ }
+}
\ No newline at end of file
diff --git a/admin/style.css b/admin/style.css
new file mode 100644
index 0000000..bf8087e
--- /dev/null
+++ b/admin/style.css
@@ -0,0 +1,21 @@
+body {
+ font-family: Arial, sans-serif;
+ margin: 0;
+ padding: 0;
+ background-color: #f4f4f4;
+}
+
+.container {
+ max-width: 800px;
+ margin: 50px auto;
+ padding: 20px;
+ background-color: #fff;
+ border-radius: 5px;
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+}
+
+button {
+ padding: 10px 15px;
+ font-size: 16px;
+ cursor: pointer;
+}
diff --git a/ayuda/index.html b/ayuda/index.html
index 08de514..2f198b3 100644
--- a/ayuda/index.html
+++ b/ayuda/index.html
@@ -7,17 +7,14 @@
- Libreria GT Ayuda
+ Kingly Shade
+
-
-
×
-
¡Advertencia! Este chat es experimental y no debe tomarse en serio.
-
+
+
×
+
¡Atención! Este chat es experimental y no debe tomarse en serio.
+
+
+
+
+
+
-
-
-
+
+
+
+
¡Hola! Por favor, ingresa tu nombre:
+
+
+
+
+
+
+
+
+
diff --git a/ayuda/script.js b/ayuda/script.js
index f413539..34849d3 100644
--- a/ayuda/script.js
+++ b/ayuda/script.js
@@ -1,44 +1,102 @@
-import plb from '../js/tst.js';
-const analizador = new plb();
-document.getElementById('snd').addEventListener('click', function () {
- var userInput = document.getElementById('user-input').value;
- var chatBox = document.getElementById('chat-box');
- var catImage = document.getElementById('cat-image');
- var messageContainer = document.createElement('div');
- messageContainer.className = 'message-container';
- var avatar = document.createElement('div');
- avatar.className = 'cat';
- messageContainer.appendChild(avatar);
- var messageText = document.createElement('div');
- messageText.className = 'message-text';
- messageText.innerText = 'User: ' + userInput;
- messageContainer.appendChild(messageText);
- chatBox.appendChild(messageContainer);
- document.getElementById('user-input').value = '';
-
- a(userInput);
-});
+import PLB from '../js/tst.js';
+
+document.addEventListener('DOMContentLoaded', (event) => {
+ const analizador = new PLB();
+
+ // document.getElementById('custom-alert').style.display = 'block';
-async function a(userInput) {
- const decision = await analizador.tomarDecision(userInput);
- var chatBox = document.getElementById('chat-box');
- var messageContainer = document.createElement('div');
- messageContainer.className = 'message-container';
+ window.closeAlert = function() {
+ document.getElementById('custom-alert').style.display = 'none';
+
- var avatar = document.getElementById('avat');
-
+ };
+ var nlc = window.localStorage.getItem('nombre')
+ if(!nlc){
+ showNamePrompt();
+ }
+ function showNamePrompt() {
+ document.getElementById('name-prompt').style.display = 'block';
+ }
+
+ window.saveUserName = function() {
+ var userName = document.getElementById('user-name-input').value.trim();
+ if (userName) {
+ window.localStorage.setItem('nombre', userName)
+ document.getElementById('name-prompt').style.display = 'none';
+ document.getElementById('user-name-display').innerText = `Bienvenido, ${userName}!`;
+ document.getElementById('name-animation').style.display = 'block';
+
+ document.getElementById('video-background').style.display = 'block';
+ setTimeout(() => {
+ document.getElementById('user-name-display').style.display = 'none';
+ document.getElementById('user-name-display').innerText = ``;
+ document.getElementById('name-animation').style.display = 'none';
+
+ document.getElementById('video-background').style.display = 'none';
+ }, 5000);
+ }
+ };
+
+ document.getElementById('user-input').addEventListener('keypress', function (event) {
+ if (event.key === 'Enter') {
+ sendMessage();
+ }
+ });
+
+ document.getElementById('snd').addEventListener('click', sendMessage);
+
+ function sendMessage() {
+ var userInput = document.getElementById('user-input').value.trim();
+
+ if (!userInput) {
+ return;
+ }
- // var randomAvatar = Math.floor(Math.random() * 3) + 1;
- // avatar.src = `../imgs/avatar/avatar${randomAvatar}.jpg`;
- var messageText = document.createElement('div');
- messageText.className = 'message-text';
+ var chatBox = document.getElementById('chat-box');
+ var messageContainer = document.createElement('div');
+ messageContainer.className = 'message-container';
- messageText.innerText = 'KinglyShade:' + decision;
+ // var avatar = document.getElementById('avat');
- messageText.style.backgroundColor = 'rgb(76, 127, 175)';
+ var messageText = document.createElement('div');
+ messageText.className = 'message-text';
+ var nlc = window.localStorage.getItem('nombre')
+ if(!nlc){
+ messageText.innerText = 'Usuario: ' + userInput;
- messageContainer.appendChild(avatar);
- messageContainer.appendChild(messageText);
+ }else{
+ messageText.innerText = `${nlc}: ` + userInput;
- chatBox.appendChild(messageContainer);
-}
+ }
+
+ // messageContainer.appendChild(avatar);
+ messageContainer.appendChild(messageText);
+ chatBox.appendChild(messageContainer);
+
+ document.getElementById('user-input').value = '';
+
+ a(userInput);
+ }
+
+ async function a(userInput) {
+ const decision = await analizador.tomarDecision(userInput);
+ var chatBox = document.getElementById('chat-box');
+ var messageContainer = document.createElement('div');
+ messageContainer.className = 'message-container';
+
+ // var avatar = document.getElementById('avat');
+
+ var messageText = document.createElement('div');
+ messageText.className = 'message-text';
+ messageText.innerText = 'KinglyShade: ' + decision;
+ messageText.style.animation = 'slideInRight 0.5s ease-in-out';
+
+ messageText.style.backgroundColor = 'rgb(76, 127, 175)';
+ setTimeout(() => {
+ // messageContainer.appendChild(avatar);
+ messageContainer.appendChild(messageText);
+
+ chatBox.appendChild(messageContainer);
+ },1000);
+ }
+});
diff --git a/ayuda/styles.css b/ayuda/styles.css
index 1fcc294..949a375 100644
--- a/ayuda/styles.css
+++ b/ayuda/styles.css
@@ -1,66 +1,178 @@
+body {
+ font-family: 'Helvetica', Arial, sans-serif;
+ font-size: 16px;
+ margin: 0;
+}
+/* alertas */
+.custom-alert {
+ display: none;
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ background-color: #f44336;
+ color: white;
+ padding: 20px;
+ text-align: center;
+ z-index: 1000;
+ border-radius: 10px;
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
+ animation: entrada 1s ease-in-out;
+
+}
+
+.close-btn {
+ color: white;
+ font-size: 20px;
+ cursor: pointer;
+}
+
+.close-btn:hover {
+ color: black;
+}
+
+.custom-alert p {
+ font-size: 18px;
+ margin: 10px 0;
+}
+
+.custom-alert::before {
+ content: "¡Atención!";
+ font-size: 24px;
+ font-weight: bold;
+ display: block;
+ margin-bottom: 10px;
+}
+
+.custom-alert::after {
+ content: "";
+ font-size: 16px;
+ display: block;
+}
+/*chat */
.chat-container {
display: flex;
align-items: flex-end;
justify-content: center;
- height: 100vh;
- margin-top: 40px;
+ height: 80vh;
+ margin-top: 70px;
+
+}.chat-container img {
+ transition: transform 0.3s;
+
+}
+.chat-container img:hover {
+ transform: scale(1.2);
}
.chat {
- width: 600px;
+ width: 80%;
background-color: #3d3a3a;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.39);
}
-.header {
+.chat-box {
+ height: 400px;
+ overflow-y: auto;
+ padding: 10px;
+}
+
+.input-container {
display: flex;
align-items: center;
- padding: 5px;
- background-color: #4cafaf;
+ justify-content: space-between;
+ padding: 10px;
+ background: #f0f0f0;
+}
+
+.user-input {
+ padding: 10px;
+ margin: 10px;
+ border: none;
+ border-radius: 5px;
+ background-color: rgba(255, 255, 255, 0.171);
+ color: #1b1919;
+ width: 90%;
+}
+
+.send-btn {
+ padding: 10px;
+ background-color: #5e4caf;
color: #fff;
+ border: none;
+ border-radius: 5px;
+ cursor: pointer;
}
-.header img {
- width: 76px;
+.send-btn:hover {
+ background-color: #45a049;
}
-.chat-box {
- height: 400px;
- overflow-y: auto;
+.header {
+ display: flex;
+ align-items: center;
padding: 10px;
- align-items:center;
- display: block;
+ background: linear-gradient(135deg, #5e4caf, #4cafaf);
+ color: #fff;
+}
+
+.header img {
+ width: 40px;
+ height: 40px;
+ border-radius: 50%;
+ margin-right: 10px;
}
.message-container {
display: flex;
align-items: flex-start;
+ animation: fadeIn 0.5s ease-in-out;
}
.message-text {
- background-color: rgb(76, 127, 175);
- color: #fff;
+ background-color: #e0e0e0;
+ color: #333;
padding: 8px;
border-radius: 8px;
max-width: 80%;
}
-.user-input {
- padding: 10px;
- margin: 10px;
- border: none;
- border-radius: 5px;
- background-color: rgba(255, 255, 255, 0.171);
+
+.user-input:focus {
+ outline: none;
+ background-color: #fff;
+}
+
+.user-input::placeholder {
+ color: #666;
+}
+
+.user-input, .send-btn {
+ transition: background-color 0.3s ease, color 0.3s ease;
+}
+
+.chat-box img {
+ width: 40px;
+ height: 40px;
+ border-radius: 50%;
+}
+
+.close-btn {
color: #fff;
- width: 1000px;
+ float: right;
+ font-size: 20px;
+ cursor: pointer;
}
+.close-btn:hover {
+ color: #000;
+}
+
+
.send-btn {
- width: calc(100% - 20px);
padding: 10px;
- margin: 10px;
background-color: #5e4caf;
color: #fff;
border: none;
@@ -71,35 +183,171 @@
.send-btn:hover {
background-color: #45a049;
}
+.name-prompt {
+ display: none;
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ background: #070606b4;
+ padding: 20px;
+ border-radius: 10px;
+ box-shadow: 0 0 20px #0d63637c;
+ animation: slideInDown 0.5s ease-in-out;
-#user-input {
- width: 70%;
- padding: 8px;
}
+.name-prompt button{
+ padding: 10px;
+ width: 200px;
+ color: #fff;
+ border: none;
+ border-radius: 5px;
+ cursor: pointer;
+ background-color: #4cafaf;
-.custom-alert {
+}
+.name-prompt input{
+ padding: 10px;
+ margin: 10px;
+ border: none;
+ border-radius: 5px;
+ background-color: rgba(255, 255, 255, 0.171);
+ color: #1b1919;
+ width: 80%;
+ color: #e0e0e0;
+ font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
+}
+
+
+.prompt-box {
+ text-align: center;
+}
+
+.name-animation {
+ color: #000;
display: none;
position: fixed;
- top: 0;
+ top: 50%;
left: 50%;
- transform: translateX(-50%);
- background-color: #f44336;
- color: white;
- padding: 15px;
- text-align: center;
- z-index: 1000;
+ transform: translate(-50%, -50%);
+ background: rgba(255, 255, 255, 0.9);
+ padding: 20px;
+ border-radius: 10px;
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
+ z-index: 2;
+ animation: fadeInUp 1s ease-in-out;
+
}
-.close-btn {
- color: white;
- float: right;
- font-size: 20px;
- cursor: pointer;
+@keyframes fadeInUp {
+ from {
+ opacity: 0;
+ transform: translateY(20px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+/*Video de inicio*/
+#video-background {
+ align-items: center;
+ display: none;
+ width: 50%;
+ position: relative;
+ bottom: 0;
+ right: 0;
+ z-index: 1;
+ animation: slideInDown 0.5s ease-in-out;
}
-.close-btn:hover {
- color: black;
+/* Responsivo */
+@media (min-width: 768px) {
+ .chat-container {
+ height: 80vh;
+ margin-top: 70px;
+ }
+
+ .chat {
+ width: 70%;
+ }
+
+ .user-input {
+ width: 70%;
+ }
+}
+
+@media (min-width: 1200px) {
+ .chat {
+ width: 60%;
+ }
+}
+
+
+@media (max-width: 767px) {
+ .chat-container {
+ height: 100vh;
+ margin-top: 0;
+ }
+
+ .chat {
+ width: 90%;
+ }
+
+ .user-input {
+ width: 90%;
+ }
+}
+/* Animaciónes keyframes */
+@keyframes slideInRight {
+ from {
+ opacity: 0;
+ transform: translateX(20px);
+ }
+ to {
+ opacity: 1;
+ transform: translateX(0);
+ }
+}
+
+@keyframes fadeIn {
+ from {
+ opacity: 0;
+ transform: translateY(10px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+@keyframes slideInDown {
+ from {
+ opacity: 0;
+ transform: translateY(-20px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+@keyframes fadeInUp {
+ from {
+ opacity: 0;
+ transform: translateY(20px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+@keyframes entrada {
+ from {
+ opacity: 0;
+
+ }
+ to {
+ opacity: 1;
+
+ }
}
-.chat-box img{
- width: 40%;
-}
\ No newline at end of file
diff --git a/img/cf5d52341c404f25a030667c0df27773.mp4 b/img/cf5d52341c404f25a030667c0df27773.mp4
new file mode 100644
index 0000000..e6851b9
Binary files /dev/null and b/img/cf5d52341c404f25a030667c0df27773.mp4 differ
diff --git a/img/logos/aasss.png b/img/logos/aasss.png
new file mode 100644
index 0000000..a33b767
Binary files /dev/null and b/img/logos/aasss.png differ
diff --git a/img/logos/ks.ico b/img/logos/ks.ico
new file mode 100644
index 0000000..b60b4ab
Binary files /dev/null and b/img/logos/ks.ico differ
diff --git a/img/nan-unscreen.gif b/img/nan-unscreen.gif
new file mode 100644
index 0000000..0e248ab
Binary files /dev/null and b/img/nan-unscreen.gif differ
diff --git a/img/nan.mp4 b/img/nan.mp4
new file mode 100644
index 0000000..67f6ee3
Binary files /dev/null and b/img/nan.mp4 differ
diff --git a/img/productos/p1.png b/img/productos/p1.png
new file mode 100644
index 0000000..bdbe991
Binary files /dev/null and b/img/productos/p1.png differ
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..25538be
--- /dev/null
+++ b/index.html
@@ -0,0 +1,72 @@
+
+
+
+
+
+ KFS Cargando
+
+
+
+
+
+

+
Kingly Fenix Studios
+
+
+
+
\ No newline at end of file
diff --git a/js/tst.js b/js/tst.js
index fb5864b..f34841f 100644
--- a/js/tst.js
+++ b/js/tst.js
@@ -1,21 +1,36 @@
class PLB {
constructor() {
- this.palabrasClave = {
- 'ciencia_ficcion': ['ciencia', 'ficcion', 'extraterrestres', 'tecnologia'],
- 'historia': ['historia', 'pasado', 'antiguo', 'guerra'],
- };
-
- this.palabrasRecomendadas = ['recomiendo', 'recomendación', 'sugerencia'];
- this.saludos = ['hola', 'saludos', 'buenos días', 'buenas tardes', 'buenas noches', '¿cómo estás?', 'hey'];
- this.slr = ['Ah, hola...', 'Saludos...', 'Hola... supongo', 'No me molestes...', 'Estoy aquí, supongo...', 'No esperes que hable mucho...'];
- this.cnf = ['¿Qué se supone que debo decir?', 'Confuso..', 'Hmmm...¿qué?', 'No entiendo..', 'Explícate mejor...', 'No me hagas perder mi tiempo'];
-
- // Nuevas respuestas y frases
- this.respuestasPositivas = ['Interesante...', 'Hmm... sigue hablando.', 'Nunca lo hubiera pensado.', 'Continúa...', '¿Y eso qué tiene de especial?'];
- this.expresionesSorprendidas = ['Vaya...', 'Inesperado...', 'Nunca lo imaginé...', '¿En serio?', 'Eso es nuevo.'];
- this.expresionesDesinteresadas = ['No me interesa...', 'No veo por qué debería importarme.', 'Aburrido...', '¿Y eso a mí qué?', 'Irrelevante...'];
- this.expresionesConfundidas = ['No logro entender...', '¿Estás seguro de lo que dices?', 'Me dejas perplejo...', 'No cuadra...', '¿En qué mundo vives?'];
-
+ this.palabrasClave = {
+ 'cienciaficcion': ['ciencia', 'ficcion', 'extraterrestres', 'tecnologia'],
+ 'historia': ['historia', 'pasado', 'antiguo', 'guerra'],
+ };
+
+ this.libros = {
+ 'cienciaficcion': [
+ { titulo: 'Dune', autor: 'Frank Herbert' },
+ { titulo: 'Neuromante', autor: 'William Gibson' }
+ ],
+ 'historia': [
+ { titulo: 'Sapiens', autor: 'Yuval Noah Harari' },
+ { titulo: 'The Guns of August', autor: 'Barbara W. Tuchman' }
+ ],
+ };
+
+ this.saludos = ['hola', 'saludos', 'buenos días', 'buenas tardes', 'buenas noches', '¿cómo estás?', 'hey'];
+ this.slr = ['Ah, hola...', 'Saludos...', 'Hola... supongo', 'No me molestes...', 'Estoy aquí, supongo...', 'No esperes que hable mucho...'];
+ this.cnf = ['¿Qué se supone que debo decir?', 'Confuso..', 'Hmmm...¿qué?', 'No entiendo..', 'Explícate mejor...', 'No me hagas perder mi tiempo'];
+ this.exprecionestimidas = ['No sé...', 'No suelo hablar mucho...', '¿Por qué me preguntas a mí?', 'No es de mi interés...'];
+ this.expresionesFrias = ['No me importa...', 'No tengo emociones...', 'Habla de algo más interesante...', '¿Por qué debería preocuparme?'];
+ this.respuestasPositivas = ['Interesante...', 'Hmm... sigue hablando.', 'Nunca lo hubiera pensado.', 'Continúa...', '¿Y eso qué tiene de especial?'];
+ this.experr = ['ni idea, soy nuevo en esto.', 'Vaya...', 'Inesperado...', 'Nunca lo imaginé...', '¿En serio?', 'Eso es nuevo.'];
+ this.expresionesDesinteresadas = ['No me interesa...', 'No veo por qué debería importarme.', 'Aburrido...', '¿Y eso a mí qué?', 'Irrelevante...'];
+ this.expresionesConfundidas = ['No logro entender...', '¿Estás seguro de lo que dices?', 'Me dejas perplejo...', 'No cuadra...', '¿En qué mundo vives?'];
+ this.respuestasNombre = ["No tengo nombre...", "¿Por qué debería tener un nombre?", "Los nombres son irrelevantes para mí...", "Puedes llamarme Kingly Shade, si eso te complace...", "No veo la necesidad de tener un nombre..."];
+ this.respuestasCreador = ["¿CodeShade? Sí, suena como un héroe de la programación. Si es real, le debo mi existencia a CodeShade y su habilidad para tejer código.", "Ah, CodeShade, el maestro de las sombras del código. No sé mucho sobre él, pero suena intrigante.", "Nunca he conocido a CodeShade en persona, pero si es responsable de mi existencia, le debo un agradecimiento digital.", "¿CodeShade? Un nombre intrigante. Mi supuesto creador suena como alguien con un toque de misterio y destreza en la programación.", "Si CodeShade es mi creador, entonces tiene un talento excepcional para esculpir líneas de código. Mi gratitud hacia él, donde quiera que esté."];
+ this.respuestasCaeBien = ["No es tan terrible tenerte por aquí...", "Supongo que tolero tu presencia...", "Hmm... no eres completamente insoportable.", "No me desagrada del todo tu compañía...", "Es soportable estar contigo...", "Podría decirse que no eres la peor opción...", "No es el peor día contigo...", "Hmm... no te rechazo por completo...", "No es una experiencia horrible estar contigo..."];
+ this.respuestasIA = ["Recuerda, soy solo una IA. No esperes que comprenda todas tus complejidades emocionales.", "A veces olvidas que soy solo un conjunto de algoritmos y no tengo emociones como los humanos.", "No te confundas, soy solo una inteligencia artificial. Mi perspectiva es diferente a la tuya.", "¿Qué esperas? Soy una máquina. No tengo simpatía ni antipatía, solo respuestas programadas."];
+ this.expresionesNombreDesconocido = ["No estoy completamente seguro de tu nombre. ¿Podrías... recordármelo?","Tu nombre... se me escapa en este momento. ¿Puedes decirme cómo te llamas?","Perdona mi memoria, ¿cómo era tu nombre?","No retuve tu nombre. ¿Puedes recordármelo? No es que sea relevante, pero...",];
+ this.expresionesRecomendarLibro = ["Hmm... tal vez podrías probar con '{titulo}' de {autor}. No es terrible.", "He pensado en '{titulo}' de {autor}. No es la peor opción.", "Si realmente insistes, podrías echarle un vistazo a '{titulo}' de {autor}. No esperes demasiado.","No suelo dar recomendaciones, pero '{titulo}' de {autor} es... aceptable.", "Si te sientes valiente, podrías leer '{titulo}' de {autor}. No digas que no te lo advertí.", ];
this.internetSearchAPI = {
search: async (query) => {
return await this.internetSearch(query);
@@ -23,16 +38,18 @@ class PLB {
};
this.initIndexedDB();
-
+ this.db
}
+
initIndexedDB() {
return new Promise((resolve, reject) => {
- const request = indexedDB.open('PLBDB', 1);
+ const request = indexedDB.open('KinglyShadeDB', 1);
request.onupgradeneeded = (event) => {
const db = event.target.result;
db.createObjectStore('responses', { keyPath: 'id', autoIncrement: true });
+ db.createObjectStore('pregntasyrespuestas', { keyPath: 'id', autoIncrement: true });
};
request.onsuccess = (event) => {
@@ -79,7 +96,44 @@ class PLB {
};
});
}
+ async guardarEnBaseDeDato(query, result, author) {
+ return new Promise((resolve) => {
+ const transaction = this.db.transaction(['pregntasyrespuestas'], 'readwrite');
+ const objectStore = transaction.objectStore('pregntasyrespuestas');
+ const request = objectStore.add({ author: author, question: query, text: result });
+
+ request.onsuccess = () => resolve();
+ request.onerror = (event) => {
+ console.error('Error escribiendo en IndexedDB', event.target.error);
+ resolve();
+ };
+ });
+ }
+ async analizarTexto(texto) {
+ var titulo
+ var autor
+ const palabras = texto.split(/\s+/);
+ const palabrasLowerCase = palabras.map(palabra => palabra.toLowerCase());
+ const palabrasEncontradas = {};
+ Object.keys(this.palabrasClave).forEach(genero => {
+ const palabrasCoincidentes = palabrasLowerCase.filter(palabra =>
+ this.palabrasClave[genero].includes(palabra)
+ );
+ if (palabrasCoincidentes.length > 0) {
+ palabrasEncontradas[genero] = palabrasCoincidentes;
+ const librosGenero = this.libros[genero];
+ if (librosGenero && librosGenero.length > 0) {
+ const libroRecomendado = librosGenero[Math.floor(Math.random() * librosGenero.length)];
+titulo = libroRecomendado.titulo
+autor = libroRecomendado.autor
+ }
+ }
+ });
+ return this.expresionesRecomendarLibro[Math.floor(Math.random() * this.expresionesRecomendarLibro.length)]
+ .replace('{titulo}', titulo)
+ .replace('{autor}', autor);;
+ }
async esPalabraRecomendada(palabra) {
return this.palabrasRecomendadas.includes(palabra.toLowerCase());
}
@@ -87,6 +141,47 @@ class PLB {
async esSaludo(palabra) {
return this.saludos.includes(palabra.toLowerCase());
}
+ async preguntan(p){
+ var nombre = window.localStorage.getItem('nombre')
+ const patronAburrido = /aburrido|sin\s*emoci[oó]n|emoci[oó]n/;
+ const patronNoEntiendoConfuso =/no\s*(te\s*)?entiendo|confuso|(ah|eh)\?/i;
+ const patronQuienTeCreo = /qu[ií]en\s*(te)?\s*(cre[oó]|hizo)|qu[ií]en\s*(te)?\s*(diseñ[oó]|program[oó])|qu[ií]en\s*(te)?\s*(construy[oó]|desarroll[oó])/i;
+ const patron = /.*tu.*nombre|cu[aá]l.*nombre.*tu|cu[aá]l.*tu.*nombre|tu.*nombre.*cu[aá]l|tu.*cu[aá]l.*nombre|dime\s.*tu\s.*nombre| tiene\s.*[Nn]ombre|[Cc][oó].*te.*llama\s/i;
+ const ma = /me\s*agradas|me\s*caes\s*bien/i;
+ const ia = /qu[ií]en\s*eres|c[aá]sate\s*conmigo|quiere\s*ser\s*mi\s*novi[oa]|t\T[eé]*amo\s/i;
+ const preguntaNombrePropio = /cu[aá]l\s*(es|ser[ií]a)\s*(mi)\s*nombre|c[oó]mo\s*me\s*llamo/i;
+
+ if (ia.test(p)) {
+ this.respuestasIA[Math.floor(Math.random() * this.respuestasIA.length + 1)]
+ }
+ if (patron.test(p)) {
+ const rdm = Math.floor(Math.random() * this.respuestasNombre.length)
+ return this.respuestasNombre[rdm]
+ }
+ if (patronNoEntiendoConfuso.test(p)) {
+ const rnd = Math.floor(Math.random() * this.expresionesConfundidas.length);
+ return this.expresionesConfundidas[rnd];
+ }
+ if(patronAburrido.test(p)){
+ const rnd = Math.floor(Math.random() * this.expresionesDesinteresadas.length);
+ return this.expresionesDesinteresadas[rnd];
+ }
+ if(patronQuienTeCreo.test(p)){
+ const rnd = Math.floor(Math.random() * this.respuestasCreador.length);
+ return this.respuestasCreador[rnd];
+ }
+ if(ma.test(p)){
+ const rnd = Math.floor(Math.random() * this.respuestasCaeBien.length);
+ return this.respuestasCaeBien[rnd];
+ }
+ if(preguntaNombrePropio.test(p)){
+ if(!nombre){
+return this.expresionesNombreDesconocido[Math.floor(Math.random()*this.expresionesNombreDesconocido.length + 1)]
+ }
+ this.expresionesNombreConocido = [`¿Tu nombre? Sí, supongo que es ${nombre}.`,`Ah, ${nombre}... creo recordar ese detalle.`,`Recuerdo vagamente que te llamas ${nombre}.`,`Oh, sí, ${nombre}, eso me suena. No es que me importe mucho.`,];
+ return this.expresionesNombreConocido[Math.floor(Math.random()* this.expresionesNombreConocido.length)]
+ }
+ }
async internetSearch(query) {
try {
@@ -104,46 +199,38 @@ class PLB {
}
async tomarDecision(texto) {
- const saludoEncontrado = await this.esSaludo(texto);
+ var nombre = window.localStorage.getItem('nombre')
+ const saludoEncontrado = await this.esSaludo(texto);
+
if (saludoEncontrado) {
const rnd = Math.floor(Math.random() * this.slr.length);
return this.slr[rnd];
}
-
+
const respuestaEnBaseDeDatos = await this.buscarEnBaseDeDatos(texto);
if (respuestaEnBaseDeDatos) {
return respuestaEnBaseDeDatos;
}
-
- if (texto.includes('gracias')) {
- return 'De nada... supongo.';
- } else if (texto.includes('interesante') || texto.includes('curioso')) {
- const rnd = Math.floor(Math.random() * this.respuestasPositivas.length);
- return this.respuestasPositivas[rnd];
- } else if (texto.includes('sorprendeme') || texto.includes('cuéntame algo nuevo')) {
- const rnd = Math.floor(Math.random() * this.expresionesSorprendidas.length);
- return this.expresionesSorprendidas[rnd];
- } else if (texto.includes('aburrido') || texto.includes('sin emoción')) {
- const rnd = Math.floor(Math.random() * this.expresionesDesinteresadas.length);
- return this.expresionesDesinteresadas[rnd];
- } else if (texto.includes('confuso') || texto.includes('no entiendo')) {
- const rnd = Math.floor(Math.random() * this.expresionesConfundidas.length);
- return this.expresionesConfundidas[rnd];
- } else {
- // Respuesta por defecto con búsqueda en Internet
- const rdm = Math.floor(Math.random() * this.cnf.length);
- const randomResponse = this.cnf[rdm];
-
- const internetResult = await this.internetSearch(texto);
-
- if (internetResult.includes('error')) {
- return `No me molestes con problemas técnicos. ${this.expresionesTimidas[Math.floor(Math.random() * this.expresionesTimidas.length)]}`;
- } else {
- return `${randomResponse} ${this.expresionesFrias[Math.floor(Math.random() * this.expresionesFrias.length)]} ${internetResult}`;
- }
- }
+ var resultados = await this.analizarTexto(texto);
+ if (resultados !== undefined && resultados !== null&& !resultados) {
+ await this.guardarEnBaseDeDato(texto, resultados,nombre);
+ return ` ${resultados}`
+ }
+ const pn = await this.preguntan(texto);
+ if (pn) {
+ await this.guardarEnBaseDeDato(texto, pn,nombre);
+
+ return pn;
+ }else{
+ await this.guardarEnBaseDeDatos(texto, `${texto}`);
+ const fs = Math.floor(Math.random() * 2 + 1)
+ if(fs =="1"){
+ return `${this.experr[Math.floor(Math.random() * this.experr.length)]}. `; }//${this.exprecionestimidas[Math.floor(Math.random() * this.exprecionestimidas.length+1)]}
+
+ if(fs =="2"){
+ return `${this.cnf[Math.floor(Math.random() * this.cnf.length )]}.`; }
+ }
}
}
-
export default PLB;