I need a better solution

This commit is contained in:
piair338 2022-10-25 08:03:24 +00:00
parent 0af267e628
commit c665144b28
2 changed files with 95 additions and 100 deletions

181
V4.py
View File

@ -69,14 +69,14 @@ def claim_amazon():
webhookFailure.send(_mail +" - "+ fcode) webhookFailure.send(_mail +" - "+ fcode)
return(1) return(1)
else : else :
LogError("impossible de localiser le code ", driver) LogError("impossible de localiser le code ", driver, _mail)
return(1) return(1)
else : else :
LogError("la recuperation ne peux pas être automatique", driver) LogError("la recuperation ne peux pas être automatique", driver, _mail)
return(0) return(0)
except Exception as e : except Exception as e :
LogError(f'problème dans la recuperation : {str(e)}', driver) LogError(f'problème dans la recuperation : {str(e)}', driver, _mail)
def setup_proxy(ip, port) : def setup_proxy(ip, port) :
@ -133,7 +133,7 @@ def CustomSleep(temps):
else: else:
sleep(temps) sleep(temps)
except KeyboardInterrupt : except KeyboardInterrupt :
printf("attente annulée") printf("attente annulée", _mail)
@ -171,7 +171,7 @@ PlayQuiz[N]([int : override]) make the quizz with N choice each time. They usual
override is the number of question, by default, it's the number of question in this specific quizz. Can be usefull in some case, where the programm crashes before finishing the quizz override is the number of question, by default, it's the number of question in this specific quizz. Can be usefull in some case, where the programm crashes before finishing the quizz
""" """
def PlayQuiz2(override=10): def PlayQuiz2(override=10):
printf("début de PlayQuiz2") printf("début de PlayQuiz2", _mail)
for j in range(override): for j in range(override):
try: try:
RGPD() RGPD()
@ -200,13 +200,13 @@ def PlayQuiz2(override=10):
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
except Exception as e: except Exception as e:
LogError("PlayQuiz2" + str(e), driver) LogError("PlayQuiz2" + str(e), driver, _mail)
break break
printf("PlayQuiz2 finis") printf("PlayQuiz2 finis", _mail)
def PlayQuiz8(override=3): def PlayQuiz8(override=3):
printf(f"PlayQuiz8 : start, override : {override}") printf(f"PlayQuiz8 : start, override : {override}", _mail)
try: try:
c = 0 c = 0
for i in range(override): for i in range(override):
@ -219,7 +219,7 @@ def PlayQuiz8(override=3):
if 'iscorrectoption="True" ' in Card.get_attribute("outerHTML"): if 'iscorrectoption="True" ' in Card.get_attribute("outerHTML"):
ListeOfGood.append(f"rqAnswerOption{i-1}") # premier div = 3 ? ListeOfGood.append(f"rqAnswerOption{i-1}") # premier div = 3 ?
except Exception as e: except Exception as e:
LogError(f"playquiz8 - 1 - {e}", driver) LogError(f"playquiz8 - 1 - {e}", driver, _mail)
shuffle(ListeOfGood) shuffle(ListeOfGood)
for i in ListeOfGood: for i in ListeOfGood:
@ -233,7 +233,7 @@ def PlayQuiz8(override=3):
try: try:
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
except Exception as e: except Exception as e:
LogError(f"playquizz8 - 2 - {e}", driver) LogError(f"playquizz8 - 2 - {e}", driver, _mail)
except exceptions.NoSuchElementException as e : except exceptions.NoSuchElementException as e :
try : try :
driver.refresh() driver.refresh()
@ -241,25 +241,25 @@ def PlayQuiz8(override=3):
elem = driver.find_element(By.ID, i) elem = driver.find_element(By.ID, i)
elem.click() elem.click()
except Exception as e : except Exception as e :
LogError(f"playquizz8 - 5 - {e}", driver) LogError(f"playquizz8 - 5 - {e}", driver, _mail)
except Exception as e: except Exception as e:
if CUSTOM_START: if CUSTOM_START:
printf(f"playquiz8 - 3 - {e}") # may append during printf(f"playquiz8 - 3 - {e}", _mail) # may append during
else: else:
LogError(f"playquizz8 - 3 - {e}", driver) LogError(f"playquizz8 - 3 - {e}", driver, _mail)
except Exception as e: except Exception as e:
LogError(f"PlayQuiz8 - 4 - {e} \n ListOfGood : {str(ListeOfGood)}", driver) LogError(f"PlayQuiz8 - 4 - {e} \n ListOfGood : {str(ListeOfGood)}", driver, _mail)
printf("PlayQuiz8 : fin ") printf("PlayQuiz8 : fin ", _mail)
def PlayQuiz4(override=None): def PlayQuiz4(override=None):
printf("PlayQuiz4 : start") printf("PlayQuiz4 : start", _mail)
if not override: if not override:
try: # permet de gerer les truc de fidélité, qui sont plus long try: # permet de gerer les truc de fidélité, qui sont plus long
override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1]) override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1])
printf(f"Override : {override}") printf(f"Override : {override}", _mail)
except: except:
override = 3 override = 3
@ -270,8 +270,8 @@ def PlayQuiz4(override=None):
RGPD() RGPD()
reponse = search('correctAnswer":"([^"]+)', txt)[1] # je suis pas sur qu'il y ait un espace reponse = search('correctAnswer":"([^"]+)', txt)[1] # je suis pas sur qu'il y ait un espace
reponse = reponse.replace("\\u0027", "'") # il faut cancel l'unicode avec un double \ (on replacer les caracteres en unicode en caracteres utf-8) reponse = reponse.replace("\\u0027", "'") # il faut cancel l'unicode avec un double \ (on replacer les caracteres en unicode en caracteres utf-8)
printf(f"validation de la reponse ") printf(f"validation de la reponse ", _mail)
printf(f"validation de la reponse {i+1}/{override} {reponse}") printf(f"validation de la reponse {i+1}/{override} {reponse}", _mail)
try: try:
elem = driver.find_element( elem = driver.find_element(
By.CSS_SELECTOR, f'[data-option="{reponse}"]' By.CSS_SELECTOR, f'[data-option="{reponse}"]'
@ -281,16 +281,16 @@ def PlayQuiz4(override=None):
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
except Exception as e: except Exception as e:
LogError(f"PlayQuiz4 {str(e)}", driver) LogError(f"PlayQuiz4 {str(e)}", driver, _mail)
raise ValueError(e) raise ValueError(e)
printf("PlayQuiz4 : end") printf("PlayQuiz4 : end", _mail)
""" """
PlayPoll() reply a random thing to poll, on of daily activities PlayPoll() reply a random thing to poll, on of daily activities
""" """
def PlayPoll(): def PlayPoll():
printf("PlayPoll : start") printf("PlayPoll : start", _mail)
try: try:
try: try:
elem = driver.find_element(By.ID, f"btoption{choice([0,1])}") elem = driver.find_element(By.ID, f"btoption{choice([0,1])}")
@ -299,9 +299,9 @@ def PlayPoll():
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
CustomSleep(uniform(2, 2.5)) CustomSleep(uniform(2, 2.5))
except Exception as e: except Exception as e:
LogError("PlayPoll" + str(e), driver) LogError("PlayPoll" + str(e), driver, _mail)
raise ValueError(e) raise ValueError(e)
printf("PlayPoll : end") printf("PlayPoll : end", _mail)
def AllCard(): # fonction qui clique sur les cartes def AllCard(): # fonction qui clique sur les cartes
@ -314,7 +314,7 @@ def AllCard(): # fonction qui clique sur les cartes
).click() ).click()
else: else:
driver.switch_to.window(driver.window_handles[1]) driver.switch_to.window(driver.window_handles[1])
printf(f"fermeture : {driver.current_url}") printf(f"fermeture : {driver.current_url}", _mail)
driver.close() driver.close()
driver.switch_to.window(driver.window_handles[0]) driver.switch_to.window(driver.window_handles[0])
reset(Partie2) reset(Partie2)
@ -324,7 +324,7 @@ def AllCard(): # fonction qui clique sur les cartes
for i in range(3): for i in range(3):
CustomSleep(uniform(3, 5)) CustomSleep(uniform(3, 5))
try: try:
printf("dailycards - show pannels") printf("dailycards - show pannels", _mail)
titre = "erreur" titre = "erreur"
driver.find_element( driver.find_element(
By.XPATH,f"/html/body/div/div/div[3]/div[2]/div[1]/div[2]/div/div[{i+1}]/a/div/div[2]", By.XPATH,f"/html/body/div/div/div[3]/div[2]/div[1]/div[2]/div/div[{i+1}]/a/div/div[2]",
@ -334,16 +334,16 @@ def AllCard(): # fonction qui clique sur les cartes
TryPlay(titre) TryPlay(titre)
sleep(1) sleep(1)
reset() reset()
printf(f"DailyCard {titre} ok ") printf(f"DailyCard {titre} ok ", _mail)
except Exception as e: except Exception as e:
printf(f"Allcard card {titre} error ({e})") printf(f"Allcard card {titre} error ({e})", _mail)
except Exception as e: except Exception as e:
LogError(f"Dailycards {e}", driver) LogError(f"Dailycards {e}", driver, _mail)
try: try:
dailyCards() dailyCards()
except Exception as e: except Exception as e:
printf(f"erreur dans les quetes de la semaine {e}") printf(f"erreur dans les quetes de la semaine {e}", _mail)
def weekly_cards(): def weekly_cards():
try: try:
@ -360,12 +360,12 @@ def AllCard(): # fonction qui clique sur les cartes
pass pass
for i in range(20): for i in range(20):
printf("début de l'une des cartes") printf("début de l'une des cartes", _mail)
driver.find_element( driver.find_element(
By.XPATH, By.XPATH,
"/html/body/div/div/div[3]/div[2]/div[2]/div[3]/div/div[1]/a/div/div[2]", "/html/body/div/div/div[3]/div[2]/div[2]/div[3]/div/div[1]/a/div/div[2]",
).click() ).click()
printf("carte cliquée") printf("carte cliquée", _mail)
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1]) driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
sleep(1) sleep(1)
titre = driver.title titre = driver.title
@ -384,7 +384,7 @@ def AllCard(): # fonction qui clique sur les cartes
weekly_cards() weekly_cards()
break break
except Exception as e: except Exception as e:
LogError(f"weekly_cards, try n°{i+1} \n {e}", driver) LogError(f"weekly_cards, try n°{i+1} \n {e}", driver, _mail)
if i == 0 : if i == 0 :
driver.refresh() driver.refresh()
else : else :
@ -400,7 +400,7 @@ it uses global variable _mail and _password to login
def login(): def login():
global driver global driver
def sub_login(): def sub_login():
printf("sublogin : start") printf("sublogin : start", _mail)
driver.get("https://www.bing.com/rewardsapp/flyout") driver.get("https://www.bing.com/rewardsapp/flyout")
try: try:
driver.find_element(By.CSS_SELECTOR, f'[title="Rejoindre"]').click() # depend of the language of the page driver.find_element(By.CSS_SELECTOR, f'[title="Rejoindre"]').click() # depend of the language of the page
@ -429,7 +429,7 @@ def login():
elm.send_keys(Keys.ENTER) elm.send_keys(Keys.ENTER)
except : except :
pass pass
printf("login completed") printf("login completed", _mail)
RGPD() RGPD()
CustomSleep(uniform(3,5)) CustomSleep(uniform(3,5))
driver.get("https://www.bing.com/rewardsapp/flyout") driver.get("https://www.bing.com/rewardsapp/flyout")
@ -440,7 +440,7 @@ def login():
sub_login() sub_login()
return (driver.current_window_handle) return (driver.current_window_handle)
except Exception as e: except Exception as e:
LogError("login - 3 - " + str(e), driver) LogError("login - 3 - " + str(e), driver, _mail)
driver.close() driver.close()
CustomSleep(1200) CustomSleep(1200)
driver = FirefoxDriver() driver = FirefoxDriver()
@ -467,7 +467,7 @@ def BingPcSearch(override=randint(35, 40)):
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), mot) send_keys_wait(driver.find_element(By.ID, "sb_form_q"), mot)
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER) driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
except Exception as e : except Exception as e :
printf(e) printf(e, _mail)
sleep(10) sleep(10)
driver.get('https://www.bing.com/search?q=pls') driver.get('https://www.bing.com/search?q=pls')
sleep(3) sleep(3)
@ -480,12 +480,12 @@ def BingPcSearch(override=randint(35, 40)):
try: try:
driver.find_element(By.ID, "sb_form_q").clear() driver.find_element(By.ID, "sb_form_q").clear()
except Exception as e: except Exception as e:
printf(e) printf(e, _mail)
try: try:
driver.get('https://www.bing.com/search?q=pls') driver.get('https://www.bing.com/search?q=pls')
driver.find_element(By.ID, "sb_form_q").clear() driver.find_element(By.ID, "sb_form_q").clear()
except Exception as e: except Exception as e:
LogError(f"BingPcSearch - clear la barre de recherche - {e}", driver) LogError(f"BingPcSearch - clear la barre de recherche - {e}", driver, _mail)
print("\n\n") print("\n\n")
@ -494,34 +494,34 @@ def BingPcSearch(override=randint(35, 40)):
def TryPlay(nom="inconnu"): def TryPlay(nom="inconnu"):
RGPD() RGPD()
printf("TryPlay en cours") printf("TryPlay en cours", _mail)
def play(number, override=None): def play(number, override=None):
if number == 8 or number == 9: if number == 8 or number == 9:
try: try:
printf(f"\033[96m Quiz 8 détecté sur la page {nom} \033[0m") printf(f"\033[96m Quiz 8 détecté sur la page {nom} \033[0m", _mail)
PlayQuiz8() PlayQuiz8()
printf(f"\033[92m Quiz 8 reussit sur {nom} \033[0m") printf(f"\033[92m Quiz 8 reussit sur {nom} \033[0m", _mail)
except Exception as e: except Exception as e:
printf(f"echec de PlayQuiz 8. Aborted {e} \033[0m") printf(f"echec de PlayQuiz 8. Aborted {e} \033[0m", _mail)
elif number == 5 or number == 4: elif number == 5 or number == 4:
try: try:
printf(f"\033[96m Quiz 4 détecté sur la page {nom} \033[0m") printf(f"\033[96m Quiz 4 détecté sur la page {nom} \033[0m", _mail)
PlayQuiz4() PlayQuiz4()
printf(f"\033[92m Quiz 4 reussit sur {nom} \033[0m") printf(f"\033[92m Quiz 4 reussit sur {nom} \033[0m", _mail)
except Exception as e: except Exception as e:
printf(f"echec de PlayQuiz 4. Aborted {e} \033[0m") printf(f"echec de PlayQuiz 4. Aborted {e} \033[0m", _mail)
elif number == 3 or number == 2: elif number == 3 or number == 2:
try: try:
printf(f"\033[96m Quiz 2 détecté sur la page {nom}\033[0m") printf(f"\033[96m Quiz 2 détecté sur la page {nom}\033[0m", _mail)
PlayQuiz2() PlayQuiz2()
printf(f"\033[92m Quiz 2 reussit sur la page {nom}\033[0m") printf(f"\033[92m Quiz 2 reussit sur la page {nom}\033[0m", _mail)
except Exception as e: except Exception as e:
printf(f"echec de PlayQuiz 2. Aborted {e}") printf(f"echec de PlayQuiz 2. Aborted {e}", _mail)
else: else:
LogError("probleme dans la carte : il y a un bouton play et aucun quiz detecté", driver) LogError("probleme dans la carte : il y a un bouton play et aucun quiz detecté", driver, _mail)
try: try:
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
@ -529,15 +529,15 @@ def TryPlay(nom="inconnu"):
play(number) play(number)
except Exception as e: except Exception as e:
# printf(e) normal error here # printf(e, _mail) normal error here
if "bt_PollRadio" in driver.page_source: if "bt_PollRadio" in driver.page_source:
try: try:
printf("Poll détected", end="\r") printf("Poll détected", _mail)
RGPD() RGPD()
PlayPoll() PlayPoll()
printf("Poll reussit ") printf("Poll reussit ", _mail)
except Exception as e: except Exception as e:
printf(f"TryPlay - 1 - Poll aborted {e}") printf(f"TryPlay - 1 - Poll aborted {e}", _mail)
elif "rqQuestionState" in driver.page_source: elif "rqQuestionState" in driver.page_source:
try: try:
@ -549,10 +549,10 @@ def TryPlay(nom="inconnu"):
'"rqQuestionState.?." class="filledCircle"', driver.page_source '"rqQuestionState.?." class="filledCircle"', driver.page_source
) )
) )
printf(f"recovery détecté. quiz : {number}, restant : {restant +1}") printf(f"recovery détecté. quiz : {number}, restant : {restant +1}", _mail)
play(number-1, override=restant + 1) play(number-1, override=restant + 1)
except Exception as e: except Exception as e:
printf("TryPlay - 2 - " + e) printf("TryPlay - 2 - " + e, _mail)
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source): elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
print("fidélité") print("fidélité")
@ -560,7 +560,7 @@ def TryPlay(nom="inconnu"):
Fidelite() Fidelite()
else: else:
printf(f"rien à faire sur la page {nom}") printf(f"rien à faire sur la page {nom}", _mail)
RGPD() RGPD()
CustomSleep(uniform(3, 5)) CustomSleep(uniform(3, 5))
@ -592,11 +592,11 @@ def LogPoint(account="unknown"): # log des points sur discord
break break
except Exception as e: except Exception as e:
CustomSleep(300) CustomSleep(300)
printf(f"LogPoints : {e}") printf(f"LogPoints : {e}", _mail)
points = None points = None
if not points : if not points :
LogError(f"impossible d'avoir les points : {e}", driver) LogError(f"impossible d'avoir les points : {e}", driver, _mail)
CustomSleep(uniform(3, 20)) CustomSleep(uniform(3, 20))
account = account.split("@")[0] account = account.split("@")[0]
@ -630,12 +630,12 @@ def Fidelite():
try : try :
result = get(FidelityLink) #get the url of fidelity page result = get(FidelityLink) #get the url of fidelity page
except Exception as e : except Exception as e :
printf(e) printf(e, _mail)
result = False result = False
if result : if result :
lien = result.content.decode("UTF-8") lien = result.content.decode("UTF-8")
printf(lien) printf(lien, _mail)
if (lien.split(":")[0] == "https") or (lien.split(":")[0] == "http") : if (lien.split(":")[0] == "https") or (lien.split(":")[0] == "http") :
@ -663,7 +663,7 @@ def Fidelite():
t = driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]') t = driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]')
t.click() t.click()
except Exception as e2 : except Exception as e2 :
LogError(f"fidélité - double erreur - e1 : {e1} - e2 {e2}", driver) LogError(f"fidélité - double erreur - e1 : {e1} - e2 {e2}", driver, _mail)
break break
CustomSleep(uniform(3, 5)) CustomSleep(uniform(3, 5))
driver.switch_to.window(driver.window_handles[1]) driver.switch_to.window(driver.window_handles[1])
@ -673,19 +673,19 @@ def Fidelite():
try: try:
Close(driver.window_handles[1]) Close(driver.window_handles[1])
except Exception as e: except Exception as e:
printf(e) printf(e, _mail)
printf("fidelité - done") printf("fidelité - done", _mail)
else : else :
printf("lien invalide") printf("lien invalide", _mail)
except Exception as e: except Exception as e:
LogError("Fidélité" + str(e), driver) LogError("Fidélité" + str(e), driver, _mail)
def Mlogin(echec): def Mlogin(echec):
try: try:
MobileDriver.get("https://www.bing.com/search?q=test+speed") MobileDriver.get("https://www.bing.com/search?q=test+speed")
MRGPD() MRGPD()
printf("début du login") printf("début du login", _mail)
MobileDriver.find_element(By.ID, "mHamburger").click() MobileDriver.find_element(By.ID, "mHamburger").click()
CustomSleep(uniform(1, 2)) CustomSleep(uniform(1, 2))
MobileDriver.find_element(By.ID, "hb_s").click() MobileDriver.find_element(By.ID, "hb_s").click()
@ -710,19 +710,17 @@ def Mlogin(echec):
MobileDriver.find_element(By.ID, "idSIButton9").click() MobileDriver.find_element(By.ID, "idSIButton9").click()
except Exception as e: except Exception as e:
pass pass
printf("fin du Mlogin") printf("fin du Mlogin", _mail)
except Exception as e: except Exception as e:
echec += 1 echec += 1
if echec <= 3: if echec <= 3:
printf( printf(f"echec du login sur la version mobile. on reesaye ({echec}/3), {e}", _mail)
f"echec du login sur la version mobile. on reesaye ({echec}/3), {e}"
)
CustomSleep(uniform(5, 10)) CustomSleep(uniform(5, 10))
Mlogin(echec) Mlogin(echec)
else: else:
LogError( LogError(
f"login impossible 3 fois de suite. {e}", MobileDriver f"login impossible 3 fois de suite. {e}", MobileDriver, _mail
) )
MobileDriver.quit() MobileDriver.quit()
return True return True
@ -744,10 +742,7 @@ def Alerte():
except exceptions.NoAlertPresentException as e: except exceptions.NoAlertPresentException as e:
pass pass
except Exception as e: except Exception as e:
LogError( LogError(f"mobile.py -> Alerte : {e}", MobileDriver, _mail)
f"mobile.py -> Alerte : {e}",
driver=MobileDriver,
)
def BingMobileSearch(override=randint(22, 25)): def BingMobileSearch(override=randint(22, 25)):
@ -758,7 +753,7 @@ def BingMobileSearch(override=randint(22, 25)):
MobileDriver = FirefoxDriver(mobile=True) MobileDriver = FirefoxDriver(mobile=True)
MobileDriver.implicitly_wait(15) MobileDriver.implicitly_wait(15)
except Exception as e: except Exception as e:
LogError("BingMobileSearch - 1 - echec de la creation du driver mobile", MobileDriver) LogError("BingMobileSearch - 1 - echec de la creation du driver mobile", MobileDriver, _mail)
echec = 0 echec = 0
if not Mlogin(echec): if not Mlogin(echec):
@ -773,7 +768,7 @@ def BingMobileSearch(override=randint(22, 25)):
send_keys_wait(MobileDriver.find_element(By.ID, "sb_form_q"), mot) send_keys_wait(MobileDriver.find_element(By.ID, "sb_form_q"), mot)
MobileDriver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER) MobileDriver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
progressBar(i, override, name="Mobile") progressBar(i, override, name="Mobile")
printf(MobileDriver.current_url) printf(MobileDriver.current_url, _mail)
CustomSleep(uniform(5, 20)) CustomSleep(uniform(5, 20))
Alerte() # verifie si il y a des alertes (demande de positions ....) Alerte() # verifie si il y a des alertes (demande de positions ....)
@ -786,7 +781,7 @@ def BingMobileSearch(override=randint(22, 25)):
MobileDriver.quit() MobileDriver.quit()
except Exception as e: except Exception as e:
LogError("BingMobileSearch - 4 - " + str(e), MobileDriver) LogError("BingMobileSearch - 4 - " + str(e), MobileDriver, _mail)
MobileDriver.quit() MobileDriver.quit()
@ -800,31 +795,31 @@ def DailyRoutine(custom = False):
try: try:
AllCard() AllCard()
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - AllCard - \n{e}", driver) LogError(f"DailyRoutine - AllCard - \n{e}", driver, _mail)
try: try:
BingPcSearch() BingPcSearch()
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - BingPcSearch - \n{e}", driver) LogError(f"DailyRoutine - BingPcSearch - \n{e}", driver, _mail)
CustomSleep(uniform(3, 20)) CustomSleep(uniform(3, 20))
try: try:
Fidelite() Fidelite()
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - Fidelité - \n{e}", driver) LogError(f"DailyRoutine - Fidelité - \n{e}", driver, _mail)
try: try:
BingMobileSearch() BingMobileSearch()
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - BingMobileSearch - \n{e}", driver) LogError(f"DailyRoutine - BingMobileSearch - \n{e}", driver, _mail)
CustomSleep(uniform(3, 20)) CustomSleep(uniform(3, 20))
try: try:
LogPoint(_mail) LogPoint(_mail)
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - LogPoint - \n{e}", driver) LogError(f"DailyRoutine - LogPoint - \n{e}", driver, _mail)
else : else :
LogError(f"probleme de login sur le comte {_mail}", driver) LogError(f"probleme de login sur le comte {_mail}", driver, _mail)
def close(): def close():
@ -865,31 +860,31 @@ def CustomStart(Credentials):
try: try:
AllCard() AllCard()
except Exception as e: except Exception as e:
LogError(f"AllCards - {e} -- override", driver) LogError(f"AllCards - {e} -- override", driver, _mail)
if "pc" in Actions: if "pc" in Actions:
try: try:
BingPcSearch() BingPcSearch()
except Exception as e: except Exception as e:
LogError(f"il y a eu une erreur dans BingPcSearch, {e} -- override", driver) LogError(f"il y a eu une erreur dans BingPcSearch, {e} -- override", driver, _mail)
if "mobile" in Actions: if "mobile" in Actions:
try: try:
BingMobileSearch() BingMobileSearch()
except Exception as e: except Exception as e:
LogError(f"BingMobileSearch - {e} -- override", driver) LogError(f"BingMobileSearch - {e} -- override", driver, _mail)
if "Fidelite" in Actions: if "Fidelite" in Actions:
try : try :
Fidelite() Fidelite()
except Exception as e : except Exception as e :
LogError(f"Fidelite - {e} -- override", driver) LogError(f"Fidelite - {e} -- override", driver, _mail)
if "dev" in Actions: if "dev" in Actions:
try: try:
dev() dev()
except Exception as e: except Exception as e:
printf(e) printf(e, _mail)
break break
if not "tout" in Actions: if not "tout" in Actions:
@ -914,16 +909,16 @@ else:
print("\n\n") print("\n\n")
print(_mail) print(_mail)
CustomSleep(1) CustomSleep(1)
printf("début du driver") printf("début du driver", _mail)
driver = FirefoxDriver() driver = FirefoxDriver()
printf("driver demarré") printf("driver demarré", _mail)
driver.implicitly_wait(7) driver.implicitly_wait(7)
try: try:
DailyRoutine() DailyRoutine()
driver.quit() driver.quit()
attente = uniform(1200, 3600) attente = uniform(1200, 3600)
printf(f"finis. attente de {round(attente/60)}min") printf(f"finis. attente de {round(attente/60)}min", _mail)
CustomSleep(attente) CustomSleep(attente)
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@ -8,8 +8,9 @@ from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAd
) )
from modules.config import * from modules.config import *
global _mail
_mail = "undefined" _mail = "undefined"
""" """
send_keys_wait([selenium element:element, str:keys]) send the different keys to the field element, with a random time between each press to simulate human action. send_keys_wait([selenium element:element, str:keys]) send the different keys to the field element, with a random time between each press to simulate human action.
keys can be an string, but alos selenium keys keys can be an string, but alos selenium keys
@ -22,6 +23,7 @@ def send_keys_wait(element, keys):
else : else :
sleep(uniform(0.1, 0.3)) sleep(uniform(0.1, 0.3))
def LogError(message, driver, _mail, log=FULL_LOG): def LogError(message, driver, _mail, log=FULL_LOG):
print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n") print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n")
if DISCORD_ENABLED_ERROR: if DISCORD_ENABLED_ERROR:
@ -50,19 +52,17 @@ def LogError(message, driver,_mail, log=FULL_LOG):
# add the time arround the text given in [text] # add the time arround the text given in [text]
# [text] : string # [text] : string
def Timer(text="undefined"): def Timer(text="undefined", mail=_mail):
return(f"[{_mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text)) return(f"[{_mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
# replace the function print, with more options # replace the function print, with more options
# [txt] : string, [driver] : selenium wbdriver # [txt] : string, [driver] : selenium wbdriver
def printf(txt, LOG = LOG): def printf(txt, mail = _mail, LOG = LOG):
if LOG: if LOG:
print(Timer(txt)) print(Timer(txt, _mail))