check if discord works
This commit is contained in:
parent
ced633dd68
commit
8d332f1c3c
34
V6.py
34
V6.py
@ -54,8 +54,12 @@ def play_quiz2(override=10) -> None:
|
|||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
js_function = """
|
js_function = """
|
||||||
function get_correct_answer(){
|
function get_correct_answer(){
|
||||||
function br(n) { for (var r, t = 0, i = 0; i < n.length; i++)t += n.charCodeAt(i); return r = parseInt(_G.IG.substr(_G.IG.length - 2), 16), t += r, t.toString() } // Ms check function
|
function br(n) {
|
||||||
function namedRAValue() { //allow calls to getRAvalue
|
for (var r, t = 0, i = 0; i < n.length; i++)
|
||||||
|
t += n.charCodeAt(i);
|
||||||
|
return r = parseInt(_G.IG.substr(_G.IG.length - 2), 16), t += r, t.toString()
|
||||||
|
} // Ms check function
|
||||||
|
function namedRAValue() { //allow calls to getRAValue
|
||||||
return _w.getRAValue()
|
return _w.getRAValue()
|
||||||
};
|
};
|
||||||
if (br(document.getElementById("rqAnswerOption0").attributes["data-option"].value) == namedRAValue()){
|
if (br(document.getElementById("rqAnswerOption0").attributes["data-option"].value) == namedRAValue()){
|
||||||
@ -259,7 +263,7 @@ def promo():
|
|||||||
if not elm:
|
if not elm:
|
||||||
break
|
break
|
||||||
if i > 3:
|
if i > 3:
|
||||||
log_error("plus de 3 promo cards, probablement une pa skipable")
|
log_error("There is more than 3 promo cards, most likely an unskippable one.")
|
||||||
try:
|
try:
|
||||||
driver.find_element(By.CSS_SELECTOR,
|
driver.find_element(By.CSS_SELECTOR,
|
||||||
'i[class="mee-icon pull-left icon mee-icon-Cancel ng-scope"]').click()
|
'i[class="mee-icon pull-left icon mee-icon-Cancel ng-scope"]').click()
|
||||||
@ -270,7 +274,7 @@ def promo():
|
|||||||
elm.click()
|
elm.click()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
driver.execute_script("arguments[0].click();", elm)
|
driver.execute_script("arguments[0].click();", elm)
|
||||||
warning(f"that should't be there (promo), but the workarround seemed to work {e}")
|
warning(f"that shouldn't be there (promo), but the workaround 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])
|
||||||
@ -279,15 +283,15 @@ def promo():
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
spotify(driver)
|
spotify(driver)
|
||||||
except:
|
except Exception as e:
|
||||||
warning("no new windows")
|
warning(f"no new windows {format_error(e)}")
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
driver.refresh()
|
driver.refresh()
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
|
|
||||||
|
|
||||||
# Find out which type of action to do
|
# Find out which type of action to do
|
||||||
def try_play(nom="inconnu"):
|
def try_play(nom="unknown"):
|
||||||
driver = config.WebDriver.driver
|
driver = config.WebDriver.driver
|
||||||
rgpd_popup(config)
|
rgpd_popup(config)
|
||||||
|
|
||||||
@ -341,7 +345,7 @@ def try_play(nom="inconnu"):
|
|||||||
|
|
||||||
elif "rqQuestionState" in driver.page_source:
|
elif "rqQuestionState" in driver.page_source:
|
||||||
number = driver.page_source.count("rqAnswerOption")
|
number = driver.page_source.count("rqAnswerOption")
|
||||||
warning(f"recovery détecté. quiz : {number}")
|
warning(f"recovery detected. quiz : {number}")
|
||||||
play(number - 1)
|
play(number - 1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -505,15 +509,15 @@ def fidelity():
|
|||||||
try:
|
try:
|
||||||
button_text = search('<span class="pull-left margin-right-15">([^<^>]+)</span>',
|
button_text = search('<span class="pull-left margin-right-15">([^<^>]+)</span>',
|
||||||
card_elem.get_attribute("innerHTML"))[1]
|
card_elem.get_attribute("innerHTML"))[1]
|
||||||
bouton_card = driver.find_element(By.XPATH, f'//span[text()="{button_text}"]')
|
button_card = driver.find_element(By.XPATH, f'//span[text()="{button_text}"]')
|
||||||
bouton_card.click()
|
button_card.click()
|
||||||
except Exception as e1:
|
except Exception as e1:
|
||||||
try:
|
try:
|
||||||
recover_elem = driver.find_element(By.XPATH,
|
recover_elem = driver.find_element(By.XPATH,
|
||||||
'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]/a')
|
'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]/a')
|
||||||
recover_elem.click()
|
recover_elem.click()
|
||||||
except Exception as e2:
|
except Exception as e2:
|
||||||
log_error(f"fidélité - double erreur - e1 : {format_error(e1)} - e2 {format_error(e2)}")
|
log_error(f"Fidelity: Multiples error - e1 : {format_error(e1)} - e2 {format_error(e2)}")
|
||||||
break
|
break
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
driver.switch_to.window(driver.window_handles[2])
|
driver.switch_to.window(driver.window_handles[2])
|
||||||
@ -530,17 +534,16 @@ def fidelity():
|
|||||||
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")
|
||||||
try:
|
try:
|
||||||
pause = driver.find_element(By.CSS_SELECTOR,
|
pause = driver.find_element(By.CSS_SELECTOR, f'[class="c-action-toggle c-glyph f-toggle glyph-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:
|
||||||
error(f"erreur lors du click de pause: probablement pas de cartes {e}")
|
error(f"Error while clicking pause. Probably no cards. {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"]')
|
||||||
for i in range(nb_cartes):
|
for i in range(nb_cartes):
|
||||||
cartes[i].click() # affiche la bonne carte
|
cartes[i].click()
|
||||||
checked_txt = checked_list_all[i].get_attribute("innerHTML")
|
checked_txt = checked_list_all[i].get_attribute("innerHTML")
|
||||||
ok = checked_txt.count("StatusCircleOuter checkmark")
|
ok = checked_txt.count("StatusCircleOuter checkmark")
|
||||||
total = checked_txt.count("StatusCircleOuter")
|
total = checked_txt.count("StatusCircleOuter")
|
||||||
@ -753,6 +756,7 @@ def log_error(msg):
|
|||||||
|
|
||||||
|
|
||||||
def check_updated():
|
def check_updated():
|
||||||
|
debug(f"updated: {config.has_been_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")
|
||||||
|
Loading…
Reference in New Issue
Block a user