edit
This commit is contained in:
27
src/index.js
27
src/index.js
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user