mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-09 17:06:15 +00:00
feat: Update examples in DesktopFlow and MobileFlow for clarity and consistency
This commit is contained in:
@@ -43,9 +43,11 @@ export class DesktopFlow {
|
||||
* @throws {Error} If critical operation fails (login, browser init)
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const flow = new DesktopFlow(bot)
|
||||
* const result = await flow.run(account)
|
||||
* console.log(`Collected ${result.collectedPoints} points`)
|
||||
* // result.collectedPoints contains points earned
|
||||
* ```
|
||||
*/
|
||||
async run(account: Account): Promise<DesktopFlowResult> {
|
||||
this.bot.log(false, 'DESKTOP-FLOW', 'Starting desktop automation flow')
|
||||
|
||||
@@ -46,9 +46,11 @@ export class MobileFlow {
|
||||
* @throws {Error} If critical operation fails (login, OAuth)
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const flow = new MobileFlow(bot)
|
||||
* const result = await flow.run(account)
|
||||
* console.log(`Mobile: ${result.collectedPoints} points`)
|
||||
* // result.collectedPoints contains mobile points earned
|
||||
* ```
|
||||
*/
|
||||
async run(
|
||||
account: Account,
|
||||
|
||||
25
src/index.ts
25
src/index.ts
@@ -1,24 +1,12 @@
|
||||
// -------------------------------
|
||||
// REFACTORING STATUS: COMPLETED ✅
|
||||
// -------------------------------
|
||||
// Successfully modularized into separate flow modules:
|
||||
// ✅ DesktopFlow.ts (Desktop automation logic) - INTEGRATED
|
||||
// ✅ MobileFlow.ts (Mobile automation logic) - INTEGRATED
|
||||
// ✅ SummaryReporter.ts (Report generation) - INTEGRATED
|
||||
// This improved testability and maintainability by 31% code reduction.
|
||||
// -------------------------------
|
||||
|
||||
import { spawn } from 'child_process'
|
||||
import { spawn } from 'child_process'
|
||||
import type { Worker } from 'cluster'
|
||||
import cluster from 'cluster'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import type { Page } from 'playwright'
|
||||
import { createInterface } from 'readline'
|
||||
|
||||
import BrowserFunc from './browser/BrowserFunc'
|
||||
import BrowserUtil from './browser/BrowserUtil'
|
||||
|
||||
import Axios from './util/Axios'
|
||||
import { detectBanReason } from './util/BanDetector'
|
||||
import Humanizer from './util/Humanizer'
|
||||
@@ -255,15 +243,18 @@ export class MicrosoftRewardsBot {
|
||||
}
|
||||
|
||||
private getVersion(): string {
|
||||
const DEFAULT_VERSION = '2.56.0'
|
||||
try {
|
||||
const pkgPath = path.join(__dirname, '../', 'package.json')
|
||||
if (fs.existsSync(pkgPath)) {
|
||||
const raw = fs.readFileSync(pkgPath, 'utf-8')
|
||||
const pkg = JSON.parse(raw)
|
||||
return pkg.version || '2.51.0'
|
||||
return pkg.version || DEFAULT_VERSION
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return '2.51.0'
|
||||
} catch (error) {
|
||||
// Ignore: Fall back to default version if package.json is unavailable
|
||||
}
|
||||
return DEFAULT_VERSION
|
||||
}
|
||||
|
||||
// Return summaries (used when clusters==1)
|
||||
@@ -652,7 +643,7 @@ export class MicrosoftRewardsBot {
|
||||
const { ConclusionWebhook } = await import('./util/ConclusionWebhook')
|
||||
await ConclusionWebhook(
|
||||
this.config,
|
||||
'🚫 Ban Detected',
|
||||
'🚫 Ban Detected',
|
||||
`**Account:** ${email}\n**Reason:** ${reason || 'detected by heuristics'}`,
|
||||
undefined,
|
||||
DISCORD.COLOR_RED
|
||||
|
||||
@@ -2,15 +2,10 @@ import { BrowserFingerprintWithHeaders } from 'fingerprint-generator'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { BrowserContext, Cookie } from 'rebrowser-playwright'
|
||||
|
||||
import { Account } from '../interface/Account'
|
||||
import { Config, ConfigBrowser, ConfigSaveFingerprint, ConfigScheduling } from '../interface/Config'
|
||||
import { Util } from './Utils'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const utils = new Util()
|
||||
|
||||
let configCache: Config
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import axios from 'axios'
|
||||
import chalk from 'chalk'
|
||||
|
||||
import { DISCORD, TIMEOUTS } from '../constants'
|
||||
import { sendErrorReport } from './ErrorReportingWebhook'
|
||||
import { loadConfig } from './Load'
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import axios from 'axios'
|
||||
import { BrowserFingerprintWithHeaders } from 'fingerprint-generator'
|
||||
|
||||
import { Architecture, ChromeVersion, EdgeVersion, Platform } from '../interface/UserAgentUtil'
|
||||
import { log } from './Logger'
|
||||
import { Retry } from './Retry'
|
||||
|
||||
import { Architecture, ChromeVersion, EdgeVersion, Platform } from '../interface/UserAgentUtil'
|
||||
|
||||
interface UserAgentMetadata {
|
||||
mobile: boolean
|
||||
isMobile: boolean
|
||||
|
||||
Reference in New Issue
Block a user