From 378aeb746940aaf29353c8dc04c3f8531ce15a09 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Tue, 4 Jun 2024 01:36:45 -0400 Subject: [PATCH] adding .env --- .gitignore | 1 + chatBot/bot.js | 7 ++++--- chatBot/env.default | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 chatBot/env.default diff --git a/.gitignore b/.gitignore index 8b96adf..c1c80ec 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules package-lock.json shared-storage storage +chatBot/.env \ No newline at end of file diff --git a/chatBot/bot.js b/chatBot/bot.js index a3a4b96..1c356f2 100644 --- a/chatBot/bot.js +++ b/chatBot/bot.js @@ -1,13 +1,14 @@ import fs from 'fs'; import path from 'path'; import chatBot from './includes/chatBot.js'; // Adjust the import path as necessary +import 'dotenv/config' // Generate a Buffer from the hexadecimal topic value -const topicHex = '669c83fa3c559f2c330f71a34e351a9134cecc6c255e4ef7689177bf0d7fd52a'; +const topicHex = process.env.LINKUP_ROOM_ID; const topicBuffer = Buffer.from(topicHex, 'hex'); // Create a new instance of the chatBot class with a valid botName -const botName = 'MyBot'; // Replace 'MyBot' with the desired bot name +const botName = process.env.BOT_NAME;; // Replace 'MyBot' with the desired bot name // Load commands from the 'commands' directory const commandsDir = path.join(new URL('./commands/', import.meta.url).pathname); @@ -65,7 +66,7 @@ loadCommands().then(commands => { // Wait for 2 seconds for the bot to connect setTimeout(() => { // Send a message - bot.sendMessage('Hello, world!'); + bot.sendMessage(process.env.ON_READY_MESSAGE); }, 2000); // Adjust the delay as necessary }).catch(error => { console.error('Error loading commands:', error); diff --git a/chatBot/env.default b/chatBot/env.default new file mode 100644 index 0000000..f677e9c --- /dev/null +++ b/chatBot/env.default @@ -0,0 +1,5 @@ +LINKUP_ROOM_ID= + +BOT_NAME=myBot + +ON_READY_MESSAGE="Hello, I am a bot. I am here to help you. Please type 'help' to see the list of commands." \ No newline at end of file