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":"
Sexy Mustard Sandwich: 5 | Skooty: 2 | Josh: 5
Propose and get a yes
Ask someone to suck cheeto dust off fingers
Nickelodeon cartoon avatar
Giant Nose with boogers
Sing with someone
","subsTracker":1057,"bitsTracker":80612,"donationsTracker":2119.5205564735597,"completedSpins":3}
\ No newline at end of file
+{
+ "last_turn_type": false,
+ "deeze_nutz": 2650,
+ "turn_count": 2501,
+ "youtubes_watched": 74,
+ "notification": "Sexy Mustard Sandwich: 5 | Skooty: 2 | Josh: 5
Propose and get a yes
Ask someone to suck cheeto dust off fingers
Nickelodeon cartoon avatar
Giant Nose with boogers
Sing with someone
",
+ "subsTracker": 1057,
+ "bitsTracker": 80612,
+ "donationsTracker": 2119.5205564735597,
+ "completedSpins": 3,
+ "queue_open": false
+}
diff --git a/server.js b/server.js
index ffab2d0..2e2d504 100644
--- a/server.js
+++ b/server.js
@@ -3,6 +3,8 @@ const request = require("request");
const express = require("express");
const app = express();
const port = 3000;
+const jsoning = require("jsoning");
+const settings_db = new jsoning("db/queue_settings.json");
const client = new tmi.Client({
options: { debug: true },
@@ -14,8 +16,8 @@ const client = new tmi.Client({
});
client.connect();
-//Queue closed by default
-var queue_open = false;
+//Queue closed by default unless stored in db
+var queue_open = settings_db.get('queue_open') || false;
var queue = [];
var turn_counter = [];
var firsts_first = false;
@@ -357,6 +359,7 @@ client.on("message", (channel, tags, message, self) => {
if (isBroadcaster || tags.username == "zilchgnu") {
//set queue_open to true
queue_open = true;
+ settings_db.set('queue_open', true);
//let the chat know what is up
client.say(channel, `@${tags["display-name"]} has opened the queue!`);
}
@@ -367,6 +370,7 @@ client.on("message", (channel, tags, message, self) => {
if (isBroadcaster|| tags.username == "zilchgnu") {
//set queue_open to true
queue_open = false;
+ settings_db.set('queue_open', false);
//let the chat know what is up
client.say(channel, `@${tags["display-name"]} has closed the queue!`);
}