From 39b3266b5351d0e46822dc54294b57e06a95ff91 Mon Sep 17 00:00:00 2001 From: sneedgroup-holder Date: Sat, 8 Feb 2025 03:33:18 +0000 Subject: [PATCH] Update brain.mjs --- brain.mjs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/brain.mjs b/brain.mjs index 1cfe203..64385d1 100644 --- a/brain.mjs +++ b/brain.mjs @@ -86,12 +86,14 @@ class ConsciousnessApp { // Start interactive conversation with the user async startConversation() { - this.rl.question("You can start talking to the app. Type your message: ", async (input) => { - this.handleActivity(); // Update activity when the user types + while (this.isActive) { + const input = await new Promise((resolve) => { + this.rl.question("You can start talking to the app. Type your message: ", resolve); + }); + this.handleActivity(); // Update activity when the user types await this.userTalks(input); // App replies to user input - this.startConversation(); // Continue the conversation loop - }); + } } async start() { @@ -109,7 +111,7 @@ async function main() { // Optional: Simulate the user becoming inactive after 10 seconds and then becoming active again setTimeout(() => { app.isActive = false; - this.simulator.setUserActive(false); // User inactive (dreaming) + app.simulator.setUserActive(false); // User inactive (dreaming) console.log("User is inactive... dreaming..."); }, 10000);