mirror of
				https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
				synced 2025-11-04 15:43:53 +01:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
			dev
			...
			d2ad467d4e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					d2ad467d4e | ||
| 
						 | 
					b45e9e549f | ||
| 
						 | 
					200b0d8a86 | ||
| 
						 | 
					4a5af6455d | ||
| 
						 | 
					49b691d736 | ||
| 
						 | 
					9549a6dea3 | 
							
								
								
									
										16
									
								
								V6.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								V6.py
									
									
									
									
									
								
							@@ -152,7 +152,7 @@ def play_quiz4(override: int = None):
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        log_error(e)
 | 
			
		||||
        raise ValueError(e)
 | 
			
		||||
    info("Quiz 8 done.")
 | 
			
		||||
    info("Quiz 4 done.")
 | 
			
		||||
    custom_sleep(3)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -165,6 +165,8 @@ def do_poll():
 | 
			
		||||
        try:
 | 
			
		||||
            answer_elem.click()
 | 
			
		||||
        except exceptions.ElementNotInteractableException:
 | 
			
		||||
            warning("element not clickable. Waiting a bit and retrying.")
 | 
			
		||||
            custom_sleep(uniform(2, 2.5))
 | 
			
		||||
            driver.execute_script("arguments[0].click();", answer_elem)
 | 
			
		||||
        custom_sleep(uniform(2, 2.5))
 | 
			
		||||
    except Exception as err:
 | 
			
		||||
@@ -610,9 +612,11 @@ def daily_routine(cred: UserCredentials, custom=False):
 | 
			
		||||
    try:
 | 
			
		||||
        if not custom:  # custom already is logged in
 | 
			
		||||
            login()
 | 
			
		||||
 | 
			
		||||
    except Banned:
 | 
			
		||||
        log_error("This account is locked.")
 | 
			
		||||
        return
 | 
			
		||||
        raise Banned()
 | 
			
		||||
 | 
			
		||||
    except Identity:
 | 
			
		||||
        log_error("This account has an issue.")
 | 
			
		||||
        return
 | 
			
		||||
@@ -680,7 +684,7 @@ def json_start(json_entry, cred: UserCredentials):
 | 
			
		||||
                login()
 | 
			
		||||
            try:
 | 
			
		||||
                if str(account_id) in json_entry["tout"]:
 | 
			
		||||
                    daily_routine(cred)
 | 
			
		||||
                    daily_routine(cred, True)
 | 
			
		||||
            except KeyError:
 | 
			
		||||
                pass
 | 
			
		||||
            else:
 | 
			
		||||
@@ -744,12 +748,16 @@ def default_start():
 | 
			
		||||
            config.WebDriver.pc_driver.quit()
 | 
			
		||||
            config.display.stop()
 | 
			
		||||
            break
 | 
			
		||||
        except Banned:
 | 
			
		||||
            warning("this account is banned. Switching to next account")
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            log_error(f"Error not caught. Skipping this account. " + format_error(e))
 | 
			
		||||
            critical(f"Error not caught. Skipping this account. {e}")
 | 
			
		||||
            config.WebDriver.pc_driver.quit()
 | 
			
		||||
 | 
			
		||||
        config.UserCredentials.next_account()
 | 
			
		||||
        finally:
 | 
			
		||||
            config.UserCredentials.next_account()
 | 
			
		||||
 | 
			
		||||
    config.display.stop()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ class DiscordLogger:
 | 
			
		||||
        )
 | 
			
		||||
        file = File("screenshot.png")
 | 
			
		||||
        embed.set_image(url="attachment://screenshot.png")
 | 
			
		||||
        embed.set_footer(text=self.config.UserCredentials.creds.get_mail())
 | 
			
		||||
        embed.set_footer(text=self.config.UserCredentials.get_mail() + " - " + self.config.WebDriver.current_driver())
 | 
			
		||||
 | 
			
		||||
        self.config.discord.wh.send(embed=embed, username="error", file=file, avatar_url=self.config.discord.avatar_url)
 | 
			
		||||
        self.config.discord.wh.send(username="error", file=File("page.html"), avatar_url=self.config.discord.avatar_url)
 | 
			
		||||
 
 | 
			
		||||
@@ -20,3 +20,6 @@ class Driver:
 | 
			
		||||
 | 
			
		||||
            case _:
 | 
			
		||||
                raise ValueError("The driver must be either pc or mobile")
 | 
			
		||||
 | 
			
		||||
    def current_driver(self):
 | 
			
		||||
        return "PC" if self.pc_driver == self.driver else "Mobile"
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ class UserCredentials:
 | 
			
		||||
    def get_tfa(self):
 | 
			
		||||
        if not self.tfa_enable():
 | 
			
		||||
            warning("Warning: TFA is not enabled. Calling get_tfa is an expected behaviour.")
 | 
			
		||||
        return TOTP(self.data[self.current]["tfa"])
 | 
			
		||||
        return TOTP(self.data[self.current]["2fa"])
 | 
			
		||||
 | 
			
		||||
    def next_account(self):
 | 
			
		||||
        self.current += 1
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								modules/Tools/generate_error.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								modules/Tools/generate_error.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
import undetected_chromedriver as uc
 | 
			
		||||
from pyvirtualdisplay.smartdisplay import SmartDisplay
 | 
			
		||||
 | 
			
		||||
display = SmartDisplay(size=(1920, 1080))
 | 
			
		||||
display.start()
 | 
			
		||||
driver = uc.Chrome()
 | 
			
		||||
driver.close()
 | 
			
		||||
driver.close()
 | 
			
		||||
@@ -30,7 +30,7 @@ class ColoredFormatter(logging.Formatter):
 | 
			
		||||
 | 
			
		||||
# Set up the root logger
 | 
			
		||||
root_logger = logging.getLogger(__name__)
 | 
			
		||||
root_logger.setLevel(logging.DEBUG)
 | 
			
		||||
root_logger.setLevel(logging.INFO)
 | 
			
		||||
 | 
			
		||||
# Create a console handler and set the formatter
 | 
			
		||||
ch = logging.StreamHandler()
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ def get_domain(driver):
 | 
			
		||||
 | 
			
		||||
def custom_sleep(temps):
 | 
			
		||||
    try:
 | 
			
		||||
        if True:  # todo: change this awful condition
 | 
			
		||||
        if False:  # todo: change this awful condition
 | 
			
		||||
            points = ["⢿", "⣻", "⣽", "⣾", "⣷", "⣯", "⣟", "⡿"]
 | 
			
		||||
            passe = 0
 | 
			
		||||
            for _ in range(int(temps)):
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										48
									
								
								modules/Tools/update_chrome.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								modules/Tools/update_chrome.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
import requests
 | 
			
		||||
import re
 | 
			
		||||
from packaging import version
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
from logger import critical, info, error
 | 
			
		||||
 | 
			
		||||
errorMessage = subprocess.run(['python3', 'generate_error.py'], check=False, stdout=subprocess.PIPE,
 | 
			
		||||
                              stderr=subprocess.PIPE).stderr.decode("utf-8")
 | 
			
		||||
 | 
			
		||||
versionPattern = "This version of ChromeDriver only supports Chrome version ([0-9]+)"
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    versionN = re.search(versionPattern, errorMessage)[1]
 | 
			
		||||
except Exception as e:
 | 
			
		||||
    critical("Can't get version number from error")
 | 
			
		||||
    error(e)
 | 
			
		||||
    exit(0)
 | 
			
		||||
 | 
			
		||||
info(f"Needed version : '{versionN}'")
 | 
			
		||||
 | 
			
		||||
downloadUrl = "http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/"
 | 
			
		||||
r = requests.get(downloadUrl)
 | 
			
		||||
 | 
			
		||||
content = r.text
 | 
			
		||||
 | 
			
		||||
exactVersionList = re.findall(f"(google-chrome-stable_({versionN}.[0-9.]+)[^<^>^\"]+)", content)
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    best = exactVersionList[0]
 | 
			
		||||
except Exception as e:
 | 
			
		||||
    critical("No version matches required version")
 | 
			
		||||
    error(e)
 | 
			
		||||
    exit(0)
 | 
			
		||||
 | 
			
		||||
for i in exactVersionList:
 | 
			
		||||
    if version.parse(i[1]) > version.parse(best[1]):
 | 
			
		||||
        best = i
 | 
			
		||||
 | 
			
		||||
chromeDebURL = f"http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/{best[0]}"
 | 
			
		||||
info(f"chrome deb URL : {chromeDebURL}")
 | 
			
		||||
info("downloading chrome")
 | 
			
		||||
 | 
			
		||||
subprocess.call(['wget', "-O", "/tmp/chrome.deb", chromeDebURL])
 | 
			
		||||
info("Chrome deb downloaded. Installing chrome")
 | 
			
		||||
 | 
			
		||||
subprocess.call(["dpkg", "-i", "/tmp/chrome.deb"])
 | 
			
		||||
info("Chrome installed")
 | 
			
		||||
		Reference in New Issue
	
	Block a user