feat: Refactor configuration and enhance error reporting functionality

This commit is contained in:
2026-01-02 17:58:08 +01:00
parent 4ee648e5cb
commit 57e98e6f03
11 changed files with 194 additions and 71 deletions

View File

@@ -76,10 +76,10 @@ export class AccountHistory {
const data = this.loadHistory(filePath)
if (data && !activeEmails.includes(data.email)) {
fs.unlinkSync(filePath)
console.log(`[HISTORY] Cleaned up removed account: ${data.email}`)
// Silent: Removed account cleanup is internal maintenance
}
} catch (error) {
// Ignore invalid files
// Expected: Invalid history files may exist from previous versions
}
}
}
@@ -91,7 +91,7 @@ export class AccountHistory {
const content = fs.readFileSync(filePath, 'utf8')
return JSON.parse(content) as AccountHistoryData
} catch (error) {
console.error(`[HISTORY] Failed to load ${filePath}:`, error)
// Expected: File may be corrupted or from incompatible version
return null
}
}
@@ -153,7 +153,7 @@ export class AccountHistory {
try {
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8')
} catch (error) {
console.error(`[HISTORY] Failed to save ${email}:`, error)
// Non-critical: History persistence failure doesn't affect bot operation
}
}

View File

@@ -162,25 +162,13 @@ function normalizeConfig(raw: unknown): Config {
n.humanization.gestureScrollProb = !n.humanization.enabled ? 0 : 0.25
}
// Vacation mode (monthly contiguous off-days)
if (!n.vacation) n.vacation = {}
if (typeof n.vacation.enabled !== 'boolean') n.vacation.enabled = false
const vMin = Number(n.vacation.minDays)
const vMax = Number(n.vacation.maxDays)
n.vacation.minDays = isFinite(vMin) && vMin > 0 ? Math.floor(vMin) : 3
n.vacation.maxDays = isFinite(vMax) && vMax > 0 ? Math.floor(vMax) : 5
if (n.vacation.maxDays < n.vacation.minDays) {
const t = n.vacation.minDays; n.vacation.minDays = n.vacation.maxDays; n.vacation.maxDays = t
}
// Vacation mode (monthly contiguous off-days) - REMOVED (not implemented)
const riskRaw = (n.riskManagement ?? {}) as Record<string, unknown>
const hasRiskCfg = Object.keys(riskRaw).length > 0
const riskManagement = hasRiskCfg ? {
enabled: riskRaw.enabled === true,
autoAdjustDelays: riskRaw.autoAdjustDelays !== false,
stopOnCritical: riskRaw.stopOnCritical === true,
banPrediction: riskRaw.banPrediction === true,
riskThreshold: typeof riskRaw.riskThreshold === 'number' ? riskRaw.riskThreshold : undefined
stopOnCritical: riskRaw.stopOnCritical === true
} : undefined
const queryDiversityRaw = (n.queryDiversity ?? {}) as Record<string, unknown>
@@ -236,7 +224,6 @@ function normalizeConfig(raw: unknown): Config {
ntfy,
update: n.update,
passesPerRun: passesPerRun,
vacation: n.vacation,
crashRecovery: n.crashRecovery || {},
riskManagement,
dryRun,