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