mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-29 08:31:01 +00:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user