This commit is contained in:
2026-04-23 04:49:00 +02:00
parent b1b3152d9b
commit 12baf6a12b
13 changed files with 159 additions and 118 deletions

View File

@@ -1,20 +1,21 @@
const { startAuthServer } = require("./twitch/authServer");
const { connect } = require("./twitch/websocket");
const { initFromDisk } = require("./twitch/token");
const auth = startAuthServer();
const restored = initFromDisk();
// wait for login before starting Twitch connection
const wait = setInterval(() => {
const token = auth.getToken();
if (restored) {
console.log("🚀 Using saved token, skipping login...");
connect();
} else {
const auth = startAuthServer();
const wait = setInterval(() => {
const token = auth.getToken();
if (!token) return;
if (token) {
clearInterval(wait);
// inject token into runtime config
const config = require("./config");
config.token = token;
console.log("🚀 Starting Twitch connection...");
connect();
}
}, 1000);
}, 1000);
}