diff --git a/V6.py b/V6.py index e8d1a00..4a132e5 100755 --- a/V6.py +++ b/V6.py @@ -398,7 +398,7 @@ def try_play(nom="inconnu"): # Login with password or with cookies. # The driver should be in the same state on both case -def pwd_login(ldriver, cred: UserCredentials): +def login_part_1(ldriver, cred: UserCredentials): printf("pwd_login : start") ldriver.get("https://login.live.com") wait_until_visible(By.ID, "i0116", browser=ldriver) @@ -420,71 +420,55 @@ def pwd_login(ldriver, cred: UserCredentials): log_error(e) -def cookie_login(ldriver): - printf("cookies_login : start") - ldriver.get("https://login.live.com") - try: - load_cookies(ldriver) - except FileNotFoundError: - printf("No cookies file Found.") - return (False) - except Exception as e: - # log_error(f"Error performing cookies login. Trying with password instead. \n{str(e)}", driver) - print("error with cookies login. IDK why (yet)") - return (False) - try: - ldriver.refresh() - except Exception as e: - printf(format_error(e)) - printf("FIX YOUR SITE MS.......") - - return (True) - - # Accept all cookies question, and check if the account is locked -def login_part_2(ldriver, cookies=False): +def login_part_2(ldriver): custom_sleep(5) - if ('Abuse' in ldriver.current_url): + + if 'Abuse' in ldriver.current_url: raise Banned() - if ('identity' in ldriver.current_url): + + if 'identity' in ldriver.current_url: raise Identity() - if ('notice' in ldriver.current_url): + + if 'notice' in ldriver.current_url: ldriver.find_element(By.ID, "id__0").click() - if ("proof" in ldriver.current_url): + + if "proof" in ldriver.current_url: ldriver.find_element(By.ID, "iLooksGood") - if cookies: - save_cookies(ldriver) - for id in ["iNext", "KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]: + + for elm_id in ["iNext", "KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]: if get_domain(ldriver) == "account.microsoft.com": break try: - ldriver.find_element(By.ID, id).click() + ldriver.find_element(By.ID, elm_id).click() except Exception as e: pass + wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver) # login() tries to login to your Microsoft account. # it uses global variable g._mail and g._password to login -def login(ldriver, cred: Credentials): +def login(ldriver, cred: UserCredentials): try: - pwd_login(ldriver, cred) - login_part_2(ldriver, 0) + login_part_1(ldriver, cred) + login_part_2(ldriver) ldriver.get("https://rewards.bing.com/") except Banned: raise Banned() except Identity: raise Banned() except Exception as e: + critical("Error not caught during login.") log_error(e) ldriver.quit() - return (False) + return False # Makes 30 search as PC Edge def bing_pc_search(override=randint(35, 40)): mot = choice(Liste_de_mot).replace(" ", "+") - driver.get(f"https://www.bing.com/search?q={mot}") # {choice(Liste_de_mot)}') + driver.get(f"https://www.bing.com/search?q={mot}") custom_sleep(uniform(1, 2)) rgpd_popup(driver) send_keys_wait( @@ -498,7 +482,7 @@ def bing_pc_search(override=randint(35, 40)): send_keys_wait(driver.find_element(By.ID, "sb_form_q"), word) driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER) except Exception as e: - printf(e) + error(e) sleep(10) driver.get(f'https://www.bing.com/search?q={word}') sleep(3) @@ -508,52 +492,32 @@ def bing_pc_search(override=randint(35, 40)): try: driver.find_element(By.ID, "sb_form_q").clear() except Exception as e: - printf(e) + error(e) try: driver.get('https://www.bing.com/search?q=plans') driver.find_element(By.ID, "sb_form_q").clear() except Exception as e: - log_error(f"clear la barre de recherche - {format_error(e)}") + log_error(f"clear la barre de recherche - {format_error(e)}") # what is this message ??? todo # Sends points to database, discord and whatever service you want +# todo: refactor def log_points(account="unknown"): def get_points(): driver.get("https://rewards.bing.com") custom_sleep(1) - if "/proofs/" in driver.current_url: - webhookFailure.send(f"Is /proof Useful in logpoints?", username="Dev tests", - avatar_url="https://cdn.discordapp.com/attachments/793934298977009677/1144560898879541268/image.png") - for id in ["KmsiCheckboxField", "iLooksGood", "idSIButton9", "iCancel"]: - try: - driver.find_element(By.ID, id).click() - except Exception as e: - pass wait_until_visible(By.CSS_SELECTOR, 'span[mee-element-ready="$ctrl.loadCounterAnimation()"]', browser=driver) try: point = search('availablePoints\":([\d]+)', driver.page_source)[1] except Exception as e: - sleep(5) log_error( f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}", - driver, True) - driver.refresh() - sleep(5) - point = search('availablePoints\":([\d]+)', driver.page_source)[1] - return (point) - - for _ in range(3): - try: - points = get_points() - break - except Exception as e: - custom_sleep(300) - log_error(e) - points = None - - if not points: - log_error(f"impossible d'avoir les points") + driver) + error("Can't get points.") + return -1 + return point + points = get_points() custom_sleep(uniform(3, 20)) account_name = account.split("@")[0] @@ -573,6 +537,7 @@ def log_points(account="unknown"): log_error(e) +# todo: refactor and check if it works at all def fidelity(): def sub_fidelity(): try: @@ -648,17 +613,18 @@ def mobile_alert_popup(): try: alert = mobile_driver.switch_to.alert alert.dismiss() - except exceptions.NoAlertPresentException as e: + except exceptions.NoAlertPresentException: pass - except Exception as e: - log_error(e, mobile_driver) + except Exception as err: + log_error(err, mobile_driver) -def bing_mobile_search(override=randint(22, 25)): +# todo: be coherent with pc search regarding error management +def bing_mobile_search(cred: UserCredentials, override=randint(22, 25)): global mobile_driver mobile_driver = create_driver(mobile=True) try: - login(mobile_driver) + login(mobile_driver, cred) mot = choice(Liste_de_mot).replace(" ", "+") mobile_driver.get(f"https://www.bing.com/search?q={mot}") custom_sleep(uniform(1, 2)) @@ -672,21 +638,21 @@ def bing_mobile_search(override=randint(22, 25)): custom_sleep(uniform(3, 7)) mobile_alert_popup() # check for alert (asking for position or for allowing notifications) mobile_driver.find_element(By.ID, "sb_form_q").clear() - except Exception as e: - printf(e) + except Exception as err: + error(err) mobile_driver.refresh() custom_sleep(30) i -= 1 mobile_driver.quit() - except Exception as e: - log_error(e, mobile_driver) + except Exception as err: + log_error(err, mobile_driver) mobile_driver.quit() def daily_routine(cred: UserCredentials, custom=False): try: - if not custom: # custom already login + if not custom: # custom already is logged in login(driver, cred) except Banned: log_error("This account is locked.", driver) @@ -699,55 +665,50 @@ def daily_routine(cred: UserCredentials, custom=False): all_cards() except Banned: log_error("banned", driver) - return ("BANNED") - except Exception as e: - log_error(e) + raise Banned + except Exception as err: + log_error(err) try: fidelity() - except Exception as e: - log_error(e) + except Exception as err: + log_error(err) try: bing_pc_search() - except Exception as e: - log_error(e) + except Exception as err: + log_error(err) try: - bing_mobile_search() - except Exception as e: - log_error(e) + bing_mobile_search(cred) + except Exception as err: + log_error(err) try: - log_points(g._mail) - except Exception as e: - log_error(e) + log_points(cred.get_mail()) + except Exception as err: + log_error(err) -def json_start(json): +def json_start(json_entry, cred: UserCredentials): global driver display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24) display.start() - for i in range(5): - cred = g._cred[i] - g._mail = cred[0] - g._password = cred[1] - if cred[2] != '': - g._otp = TOTP(cred[2]) + for i in range(5): start = False for j in ["unban", "tout", "pc", "mobile", "daily"]: try: - if str(i) in json[j]: + if str(i) in json_entry[j]: start = True - print(f"{g._mail} : {j}") + info(f"{cred.get_mail()} : {j}") except KeyError: pass if start: driver = create_driver() try: - if str(i) in json["unban"]: - pwd_login(driver) + if str(i) in json_entry["unban"]: + login_part_1(driver, cred) print("\nGO TO example.com TO PROCEED or wait 1200 secs.") for _ in range(1200): sleep(1) @@ -755,18 +716,18 @@ def json_start(json): print("proceeding") break else: - login(driver) + login(driver, cred) except KeyError: - login(driver) + login(driver, cred) try: - if str(i) in json["tout"]: - daily_routine(True) + if str(i) in json_entry["tout"]: + daily_routine(cred) except KeyError: pass # print("none is set to \"tout\"") else: try: - if str(i) in json["daily"]: + if str(i) in json_entry["daily"]: try: all_cards() except Exception as e: @@ -775,7 +736,7 @@ def json_start(json): pass # print("none is set to \"daily\"") try: - if str(i) in json["pc"]: + if str(i) in json_entry["pc"]: try: bing_pc_search() except Exception as e: @@ -783,9 +744,9 @@ def json_start(json): except KeyError: pass try: - if str(i) in json["mobile"]: + if str(i) in json_entry["mobile"]: try: - bing_mobile_search() + bing_mobile_search(cred) except Exception as e: log_error(e) except KeyError: @@ -794,35 +755,31 @@ def json_start(json): log_points(g._mail) except Exception as e: printf(f"CustomStart {e}") - driver.close() + cred.next_account() display.stop() -if g.very_custom: - dict_data = json.loads(g.very_custom.replace("'", "\"")) - json_start(dict_data) +c = Config(args) + +if g.json_start: + dict_data = json.loads(g.json_start.replace("'", "\"")) + json_start(dict_data, c.UserCredentials) else: - c = Config(args) + if g.vnc_enabled or g.dev: display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=g.vnc_port, color_depth=24) else: display = SmartDisplay(size=(1920, 1080)) display.start() - if g.update_version != "None": if g.discord_enabled_error: webhookFailure.send(f"Updated to {g.update_version}", username="UPDATE", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png") while c.UserCredentials.is_valid(): - g._mail = c.UserCredentials.get_mail() - g._password = c.UserCredentials.get_password() - if c.UserCredentials.tfa_enable(): - g._otp = TOTP(c.UserCredentials.get_tfa()) - custom_sleep(1) info("Starting driver.") driver = create_driver()