From eb3a1eed0afa026e1d11f54abb69485f2f41b153 Mon Sep 17 00:00:00 2001 From: Kevin Huff <56265219+kevin-huff@users.noreply.github.com> Date: Tue, 17 Jun 2025 12:05:28 -0500 Subject: [PATCH] Persist queue open status --- commands/queueManagement.js | 2 ++ constants.js | 9 +++++++-- db/queue_settings.json | 13 ++++++++++++- server.js | 8 ++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/commands/queueManagement.js b/commands/queueManagement.js index d5b63e7..78c99a9 100644 --- a/commands/queueManagement.js +++ b/commands/queueManagement.js @@ -4,12 +4,14 @@ import { state } from '../constants.js'; async function handleOpenCommand(channel, tags, client, io) { state.queue_open = true; + await settings_db.set('queue_open', true); abbadabbabotSay(channel, client, tags, 'formally announce the opening of the queue to the chat'); io.emit('new_turn', `Queue Just Opened`); } async function handleCloseCommand(channel, tags, client, io) { state.queue_open = false; + await settings_db.set('queue_open', false); abbadabbabotSay(channel, client, tags, 'formally announce the closing of the queue to the chat'); io.emit('new_turn', `Queue Closed`); } diff --git a/constants.js b/constants.js index e4f57e5..83b59b9 100644 --- a/constants.js +++ b/constants.js @@ -1,16 +1,21 @@ import dotenv from 'dotenv'; import { fileURLToPath } from 'url'; -import { dirname } from 'path'; +import { dirname, join } from 'path'; +import jsoning from 'jsoning'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); +const settings_db = new jsoning(join(__dirname, 'db/queue_settings.json')); + +const persistedQueueOpen = settings_db.get('queue_open'); + dotenv.config(); export const state = { current_turn: "None... yet", end_time: 1708317900, - queue_open: false, + queue_open: persistedQueueOpen ?? false, firsts_first: true, ai_enabled: true, death_count: 0, diff --git a/db/queue_settings.json b/db/queue_settings.json index 65788ca..4c97c72 100644 --- a/db/queue_settings.json +++ b/db/queue_settings.json @@ -1 +1,12 @@ -{"last_turn_type":false,"deeze_nutz":2650,"turn_count":2501,"youtubes_watched":74,"notification":"