mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-11 17:56:15 +00:00
New structure
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
import type { MicrosoftRewardsBot } from '../index'
|
||||
import type { Account } from '../interface/Account'
|
||||
import { closeBrowserSafely, createBrowserInstance } from '../util/BrowserFactory'
|
||||
import { closeBrowserSafely, createBrowserInstance } from '../util/browser/BrowserFactory'
|
||||
import { handleCompromisedMode } from './FlowUtils'
|
||||
|
||||
export interface DesktopFlowResult {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import type { MicrosoftRewardsBot } from '../index'
|
||||
import { saveSessionData } from '../util/Load'
|
||||
import { saveSessionData } from '../util/state/Load'
|
||||
|
||||
/**
|
||||
* Handle compromised/security check mode for an account
|
||||
@@ -27,7 +27,7 @@ export async function handleCompromisedMode(
|
||||
isMobile: boolean
|
||||
): Promise<{ keepBrowserOpen: boolean }> {
|
||||
const flowContext = isMobile ? 'MOBILE-FLOW' : 'DESKTOP-FLOW'
|
||||
|
||||
|
||||
bot.log(
|
||||
isMobile,
|
||||
flowContext,
|
||||
@@ -35,10 +35,10 @@ export async function handleCompromisedMode(
|
||||
'warn',
|
||||
'yellow'
|
||||
)
|
||||
|
||||
|
||||
// Send security alert webhook
|
||||
try {
|
||||
const { ConclusionWebhook } = await import('../util/ConclusionWebhook')
|
||||
const { ConclusionWebhook } = await import('../util/notifications/ConclusionWebhook')
|
||||
await ConclusionWebhook(
|
||||
bot.config,
|
||||
isMobile ? '🔐 Security Check (Mobile)' : '🔐 Security Check',
|
||||
@@ -50,7 +50,7 @@ export async function handleCompromisedMode(
|
||||
const errorMsg = error instanceof Error ? error.message : String(error)
|
||||
bot.log(isMobile, flowContext, `Failed to send security webhook: ${errorMsg}`, 'warn')
|
||||
}
|
||||
|
||||
|
||||
// Save session for convenience (non-critical)
|
||||
try {
|
||||
await saveSessionData(bot.config.sessionPath, bot.homePage.context(), account, isMobile)
|
||||
@@ -58,6 +58,6 @@ export async function handleCompromisedMode(
|
||||
const errorMsg = error instanceof Error ? error.message : String(error)
|
||||
bot.log(isMobile, flowContext, `Failed to save session: ${errorMsg}`, 'warn')
|
||||
}
|
||||
|
||||
|
||||
return { keepBrowserOpen: true }
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
import type { MicrosoftRewardsBot } from '../index'
|
||||
import type { Account } from '../interface/Account'
|
||||
import { closeBrowserSafely, createBrowserInstance } from '../util/BrowserFactory'
|
||||
import { MobileRetryTracker } from '../util/MobileRetryTracker'
|
||||
import { closeBrowserSafely, createBrowserInstance } from '../util/browser/BrowserFactory'
|
||||
import { MobileRetryTracker } from '../util/state/MobileRetryTracker'
|
||||
import { handleCompromisedMode } from './FlowUtils'
|
||||
|
||||
export interface MobileFlowResult {
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
*/
|
||||
|
||||
import type { Config } from '../interface/Config'
|
||||
import { ConclusionWebhook } from '../util/ConclusionWebhook'
|
||||
import { JobState } from '../util/JobState'
|
||||
import { log } from '../util/Logger'
|
||||
import { Ntfy } from '../util/Ntfy'
|
||||
import { ConclusionWebhook } from '../util/notifications/ConclusionWebhook'
|
||||
import { log } from '../util/notifications/Logger'
|
||||
import { Ntfy } from '../util/notifications/Ntfy'
|
||||
import { JobState } from '../util/state/JobState'
|
||||
|
||||
export interface AccountResult {
|
||||
email: string
|
||||
@@ -54,7 +54,7 @@ export class SummaryReporter {
|
||||
const minutes = Math.floor((duration % 3600) / 60)
|
||||
const seconds = duration % 60
|
||||
|
||||
const durationText = hours > 0
|
||||
const durationText = hours > 0
|
||||
? `${hours}h ${minutes}m ${seconds}s`
|
||||
: minutes > 0
|
||||
? `${minutes}m ${seconds}s`
|
||||
@@ -67,7 +67,7 @@ export class SummaryReporter {
|
||||
for (const account of summary.accounts) {
|
||||
const status = account.errors?.length ? '❌' : '✅'
|
||||
description += `${status} ${account.email}: ${account.pointsEarned} points (${Math.round(account.runDuration / 1000)}s)\n`
|
||||
|
||||
|
||||
if (account.errors?.length) {
|
||||
description += ` ⚠️ ${account.errors[0]}\n`
|
||||
}
|
||||
@@ -95,7 +95,7 @@ export class SummaryReporter {
|
||||
|
||||
try {
|
||||
const message = `Collected ${summary.totalPoints} points across ${summary.accounts.length} account(s). Success: ${summary.successCount}, Failed: ${summary.failureCount}`
|
||||
|
||||
|
||||
await Ntfy(message, summary.failureCount > 0 ? 'warn' : 'log')
|
||||
} catch (error) {
|
||||
log('main', 'SUMMARY', `Failed to send Ntfy notification: ${error instanceof Error ? error.message : String(error)}`, 'error')
|
||||
@@ -109,7 +109,7 @@ export class SummaryReporter {
|
||||
try {
|
||||
const day = summary.endTime.toISOString().split('T')?.[0]
|
||||
if (!day) return
|
||||
|
||||
|
||||
for (const account of summary.accounts) {
|
||||
this.jobState.markAccountComplete(
|
||||
account.email,
|
||||
@@ -133,12 +133,12 @@ export class SummaryReporter {
|
||||
log('main', 'SUMMARY', '═'.repeat(80))
|
||||
log('main', 'SUMMARY', '📊 EXECUTION SUMMARY')
|
||||
log('main', 'SUMMARY', '═'.repeat(80))
|
||||
|
||||
|
||||
const duration = Math.round((summary.endTime.getTime() - summary.startTime.getTime()) / 1000)
|
||||
log('main', 'SUMMARY', `⏱️ Duration: ${Math.floor(duration / 60)}m ${duration % 60}s`)
|
||||
log('main', 'SUMMARY', `📈 Total Points Collected: ${summary.totalPoints}`)
|
||||
log('main', 'SUMMARY', `✅ Successful Accounts: ${summary.successCount}/${summary.accounts.length}`)
|
||||
|
||||
|
||||
if (summary.failureCount > 0) {
|
||||
log('main', 'SUMMARY', `❌ Failed Accounts: ${summary.failureCount}`, 'warn')
|
||||
}
|
||||
@@ -150,10 +150,10 @@ export class SummaryReporter {
|
||||
for (const account of summary.accounts) {
|
||||
const status = account.errors?.length ? '❌ FAILED' : '✅ SUCCESS'
|
||||
const duration = Math.round(account.runDuration / 1000)
|
||||
|
||||
|
||||
log('main', 'SUMMARY', `${status} | ${account.email}`)
|
||||
log('main', 'SUMMARY', ` Points: ${account.pointsEarned} | Duration: ${duration}s`)
|
||||
|
||||
|
||||
if (account.errors?.length) {
|
||||
log('main', 'SUMMARY', ` Error: ${account.errors[0]}`, 'error')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user