feat: Enhance Microsoft Rewards Bot with recovery email normalization and improved logging

- Added `normalizeRecoveryEmail` utility function for consistent recovery email validation.
- Improved logging functionality in `Logger.ts` with enhanced edge case handling and null checks.
- Centralized browser cleanup logic in `BrowserFactory.ts` to eliminate duplication.
- Refactored error handling and message formatting in `Utils.ts` for better clarity and consistency.
- Updated various log messages for improved readability and consistency across the codebase.
- Implemented periodic cleanup of webhook buffers in `Logger.ts` using centralized constants.
This commit is contained in:
2025-11-11 12:31:27 +01:00
parent 6b7b07cc1f
commit 088a3a024f
7 changed files with 277 additions and 199 deletions

View File

@@ -14,7 +14,7 @@
function parseEnvNumber(key: string, defaultValue: number, min: number, max: number): number {
const raw = process.env[key]
if (!raw) return defaultValue
const parsed = Number(raw)
if (!Number.isFinite(parsed)) {
queueMicrotask(() => {
@@ -26,7 +26,7 @@ function parseEnvNumber(key: string, defaultValue: number, min: number, max: num
})
return defaultValue
}
if (parsed < min || parsed > max) {
queueMicrotask(() => {
import('./util/Logger').then(({ log }) => {
@@ -37,7 +37,7 @@ function parseEnvNumber(key: string, defaultValue: number, min: number, max: num
})
return defaultValue
}
return parsed
}
@@ -115,4 +115,9 @@ export const DISCORD = {
COLOR_GRAY: 0x95A5A6,
WEBHOOK_USERNAME: 'Microsoft-Rewards-Bot',
AVATAR_URL: 'https://raw.githubusercontent.com/Obsidian-wtf/Microsoft-Rewards-Bot/main/assets/logo.png'
} as const
export const LOGGER_CLEANUP = {
BUFFER_MAX_AGE_MS: TIMEOUTS.ONE_HOUR,
BUFFER_CLEANUP_INTERVAL_MS: TIMEOUTS.TEN_MINUTES
} as const