Gate bot logic on full account authentication

This commit is contained in:
jjbrunton committed 2026-08-08 16:01:06 +01:00
1 parent 4db6de8bf5
commit 2fd92bf82c
22 files changed
+635 -65

No files matched your search

+16 -1
View File
@@ -19,6 +19,7 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
config,
logger,
browserClient,
accountAuth,
postsRepo,
messagesRepo,
redditApi,
@@ -65,7 +66,7 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
const RESPONSE_CHECK_INTERVAL_MS = Math.max(config.reddit.pollIntervalMs * 5, 60_000);
const checkResponses = async (): Promise<void> => {
if (isShuttingDown) return;
if (isShuttingDown || !accountAuth.isFullyAuthenticated()) return;
try {
logger.debug('Checking for responses to sent messages (Background Thread)...');
const responses = await responseChecker.checkForResponses();
@@ -92,11 +93,25 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
responseCheckInterval = setInterval(checkResponses, RESPONSE_CHECK_INTERVAL_MS);
let lastPausedLog = 0;
let lastAuthPausedLog = 0;
let lastCooldownLog = 0;
const COOLDOWN_LOG_INTERVAL_MS = 5 * 60_000;
while (!isShuttingDown) {
try {
if (!accountAuth.isFullyAuthenticated()) {
await accountAuth.ensureFullyAuthenticated();
}
if (!accountAuth.isFullyAuthenticated()) {
if (Date.now() - lastAuthPausedLog > PAUSED_LOG_INTERVAL_MS) {
logger.info('Bot logic is locked until full Reddit and Matrix authentication is verified.');
lastAuthPausedLog = Date.now();
}
await sleep(PAUSE_POLL_MS);
continue;
}
lastAuthPausedLog = 0;
if (webServer && !webServer.isRunning()) {
if (Date.now() - lastPausedLog > PAUSED_LOG_INTERVAL_MS) {
logger.info('Bot is paused. Use the web dashboard to start.');