bump version.
This commit is contained in:
parent
9857607eb3
commit
da6ca1cdfc
64
V6.py
64
V6.py
@ -1,15 +1,13 @@
|
|||||||
#!/usr/bin/python3.10
|
#!/usr/bin/python3.10
|
||||||
from modules.Classes.DiscordLogger import DiscordLogger
|
|
||||||
from modules.config import *
|
|
||||||
from modules.error import *
|
|
||||||
from modules.driver_tools import *
|
|
||||||
from modules.cards import *
|
|
||||||
import modules.globals as g
|
|
||||||
|
|
||||||
from modules.Classes.Config import Config
|
from modules.Classes.Config import Config
|
||||||
|
from modules.Classes.DiscordLogger import DiscordLogger
|
||||||
from modules.Classes.UserCredentials import UserCredentials
|
from modules.Classes.UserCredentials import UserCredentials
|
||||||
from modules.Tools.logger import warning, info, debug, error, critical
|
from modules.Tools.logger import warning, info, debug, error, critical
|
||||||
from modules.Tools.tools import format_error
|
from modules.cards import *
|
||||||
|
from modules.config import *
|
||||||
|
from modules.db import add_to_database
|
||||||
|
from modules.driver_tools import *
|
||||||
|
from modules.error import *
|
||||||
|
|
||||||
|
|
||||||
# create a webdriver
|
# create a webdriver
|
||||||
@ -30,8 +28,8 @@ def create_driver(mobile=False):
|
|||||||
else:
|
else:
|
||||||
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
|
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
|
||||||
# disabled as it may cause detection
|
# disabled as it may cause detection
|
||||||
if g.proxy_enabled:
|
if config.proxy.is_enabled():
|
||||||
chrome_options.add_argument(f'--proxy-server={g.proxy_address}:{g.proxy_port}')
|
chrome_options.add_argument(f'--proxy-server={config.proxy.ip}:{config.proxy.port}')
|
||||||
driver = uc.Chrome(options=chrome_options)
|
driver = uc.Chrome(options=chrome_options)
|
||||||
set_language(driver)
|
set_language(driver)
|
||||||
return driver
|
return driver
|
||||||
@ -129,7 +127,8 @@ def play_quiz4(override: int = None):
|
|||||||
if not override:
|
if not override:
|
||||||
try: # fidelity quiz are much longer than usual ones
|
try: # fidelity quiz are much longer than usual ones
|
||||||
override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1])
|
override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1])
|
||||||
except:
|
except Exception as err:
|
||||||
|
debug(err)
|
||||||
override = 3
|
override = 3
|
||||||
debug(f"Override : {override}")
|
debug(f"Override : {override}")
|
||||||
|
|
||||||
@ -191,15 +190,15 @@ def all_cards():
|
|||||||
log_error("Less than 10 cards. Most likely an error with login.")
|
log_error("Less than 10 cards. Most likely an error with login.")
|
||||||
return ("PAS ASSEZ DE CARTES")
|
return ("PAS ASSEZ DE CARTES")
|
||||||
if (len(liste) < 20): # most likely not in france
|
if (len(liste) < 20): # most likely not in france
|
||||||
printf("moins de 20 cartes. Probablement pas en France.")
|
error("moins de 20 cartes. Probablement pas en France.")
|
||||||
for i in range(len(liste)):
|
for i in range(len(liste)):
|
||||||
printf(f"carte {i}")
|
debug(f"carte {i}")
|
||||||
try:
|
try:
|
||||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
||||||
except StaleElementReferenceException:
|
except StaleElementReferenceException:
|
||||||
driver.refresh()
|
driver.refresh()
|
||||||
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||||
printf(f"staled, {len(liste)}")
|
warning(f"staled, {len(liste)}")
|
||||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
@ -210,24 +209,20 @@ def all_cards():
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
if i == len(liste) & i > 15:
|
if i == len(liste) & i > 15:
|
||||||
checked = False
|
checked = False
|
||||||
# input("2")
|
|
||||||
if checked:
|
if checked:
|
||||||
custom_sleep(1.5)
|
custom_sleep(1.5)
|
||||||
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
|
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
|
||||||
custom_sleep(1.5)
|
custom_sleep(1.5)
|
||||||
# input("3")
|
|
||||||
liste[i].click()
|
liste[i].click()
|
||||||
# input("4")
|
|
||||||
if len(driver.window_handles) > 1:
|
if len(driver.window_handles) > 1:
|
||||||
driver.switch_to.window(driver.window_handles[1])
|
driver.switch_to.window(driver.window_handles[1])
|
||||||
# input("5")
|
|
||||||
try_play(driver.title)
|
try_play(driver.title)
|
||||||
close_tab(driver.window_handles[1])
|
close_tab(driver.window_handles[1])
|
||||||
try:
|
try:
|
||||||
driver.refresh()
|
driver.refresh()
|
||||||
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||||
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")):
|
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")):
|
||||||
printf(f"carte {i} not okay. Retrying.")
|
warning(f"carte {i} not okay. Retrying.")
|
||||||
try:
|
try:
|
||||||
liste[i].click()
|
liste[i].click()
|
||||||
except:
|
except:
|
||||||
@ -259,7 +254,7 @@ def all_cards():
|
|||||||
try:
|
try:
|
||||||
welcome_tour(liste[i], driver)
|
welcome_tour(liste[i], driver)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf("no new windows" + format_error(e))
|
error("no new windows" + format_error(e))
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
|
|
||||||
@ -282,10 +277,8 @@ def promo():
|
|||||||
try:
|
try:
|
||||||
elm.click()
|
elm.click()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# log_error(e, driver)
|
|
||||||
driver.execute_script("arguments[0].click();", elm)
|
driver.execute_script("arguments[0].click();", elm)
|
||||||
# log_error(e, driver)
|
warning(f"that should't be there (promo), but the workarround seemed to work {e}")
|
||||||
printf(f"that should't be there (promo), but the workarround seemed to work {e}")
|
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
if len(driver.window_handles) > 1:
|
if len(driver.window_handles) > 1:
|
||||||
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
|
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
|
||||||
@ -360,7 +353,7 @@ def try_play(nom="inconnu"):
|
|||||||
play(answer_number)
|
play(answer_number)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
printf(f"Nothing to do on page `{nom}`")
|
info(f"Nothing to do on page `{nom}`")
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
|
|
||||||
|
|
||||||
@ -476,6 +469,7 @@ def bing_pc_search(override=randint(35, 40)):
|
|||||||
def log_points():
|
def log_points():
|
||||||
driver = config.WebDriver.driver
|
driver = config.WebDriver.driver
|
||||||
account = config.UserCredentials.get_mail()
|
account = config.UserCredentials.get_mail()
|
||||||
|
|
||||||
def get_points():
|
def get_points():
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
custom_sleep(1)
|
custom_sleep(1)
|
||||||
@ -483,7 +477,8 @@ def log_points():
|
|||||||
try:
|
try:
|
||||||
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
|
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}")
|
log_error(
|
||||||
|
f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}")
|
||||||
error("Can't get points.")
|
error("Can't get points.")
|
||||||
return -1
|
return -1
|
||||||
return point
|
return point
|
||||||
@ -501,6 +496,7 @@ def log_points():
|
|||||||
# todo: refactor and check if it works at all
|
# todo: refactor and check if it works at all
|
||||||
def fidelity():
|
def fidelity():
|
||||||
driver = config.WebDriver.driver
|
driver = config.WebDriver.driver
|
||||||
|
|
||||||
def sub_fidelity():
|
def sub_fidelity():
|
||||||
try:
|
try:
|
||||||
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
|
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
|
||||||
@ -536,11 +532,11 @@ def fidelity():
|
|||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
try:
|
try:
|
||||||
close_tab(driver.window_handles[2], 1)
|
close_tab(driver.window_handles[2], 1)
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
printf(e)
|
error(err)
|
||||||
printf("fidelity - done")
|
info("fidelity - done")
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
log_error(e)
|
log_error(err)
|
||||||
|
|
||||||
if driver.current_url != "https://rewards.bing.com":
|
if driver.current_url != "https://rewards.bing.com":
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
@ -549,8 +545,8 @@ def fidelity():
|
|||||||
f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]') # mettre le truc en pause
|
f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]') # mettre le truc en pause
|
||||||
pause.click()
|
pause.click()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf(f"erreur lors du click de pause: probablement pas de cartes {e}")
|
error(f"erreur lors du click de pause: probablement pas de cartes {e}")
|
||||||
return ("no cards")
|
return "no cards"
|
||||||
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
|
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
|
||||||
nb_cartes = len(cartes)
|
nb_cartes = len(cartes)
|
||||||
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
|
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
|
||||||
@ -722,7 +718,7 @@ def json_start(json_entry, cred: UserCredentials):
|
|||||||
try:
|
try:
|
||||||
log_points()
|
log_points()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf(f"CustomStart {e}")
|
error(f"CustomStart {e}")
|
||||||
driver.close()
|
driver.close()
|
||||||
cred.next_account()
|
cred.next_account()
|
||||||
config.display.stop()
|
config.display.stop()
|
||||||
@ -768,7 +764,7 @@ def log_error(msg):
|
|||||||
def check_updated():
|
def check_updated():
|
||||||
if config.has_been_updated():
|
if config.has_been_updated():
|
||||||
config.discord.wh.send(f"Updated to {config.version}", username="update",
|
config.discord.wh.send(f"Updated to {config.version}", username="update",
|
||||||
avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
|
avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user