mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-20 05:33:56 +00:00
Refactor: Simplify bot login handling in DesktopFlow and MobileFlow; initialize Login instance in MicrosoftRewardsBot
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
* - Desktop searches
|
||||
*/
|
||||
|
||||
import type { Page } from 'playwright'
|
||||
import type { MicrosoftRewardsBot } from '../index'
|
||||
import type { Account } from '../interface/Account'
|
||||
import { saveSessionData } from '../util/Load'
|
||||
@@ -49,8 +48,7 @@ export class DesktopFlow {
|
||||
this.bot.log(false, 'DESKTOP-FLOW', 'Browser started successfully')
|
||||
|
||||
// Login into MS Rewards, then optionally stop if compromised
|
||||
const login = (this.bot as unknown as { login: { login: (page: Page, email: string, password: string, totp?: string) => Promise<void> } }).login
|
||||
await login.login(this.bot.homePage, account.email, account.password, account.totp)
|
||||
await this.bot.login.login(this.bot.homePage, account.email, account.password, account.totp)
|
||||
|
||||
if (this.bot.compromisedModeActive) {
|
||||
// User wants the page to remain open for manual recovery. Do not proceed to tasks.
|
||||
@@ -116,20 +114,17 @@ export class DesktopFlow {
|
||||
|
||||
// Complete daily set
|
||||
if (this.bot.config.workers.doDailySet) {
|
||||
const workers = (this.bot as unknown as { workers: { doDailySet: (page: Page, data: unknown) => Promise<void> } }).workers
|
||||
await workers.doDailySet(workerPage, data)
|
||||
await this.bot.workers.doDailySet(workerPage, data)
|
||||
}
|
||||
|
||||
// Complete more promotions
|
||||
if (this.bot.config.workers.doMorePromotions) {
|
||||
const workers = (this.bot as unknown as { workers: { doMorePromotions: (page: Page, data: unknown) => Promise<void> } }).workers
|
||||
await workers.doMorePromotions(workerPage, data)
|
||||
await this.bot.workers.doMorePromotions(workerPage, data)
|
||||
}
|
||||
|
||||
// Complete punch cards
|
||||
if (this.bot.config.workers.doPunchCards) {
|
||||
const workers = (this.bot as unknown as { workers: { doPunchCard: (page: Page, data: unknown) => Promise<void> } }).workers
|
||||
await workers.doPunchCard(workerPage, data)
|
||||
await this.bot.workers.doPunchCard(workerPage, data)
|
||||
}
|
||||
|
||||
// Do desktop searches
|
||||
|
||||
Reference in New Issue
Block a user