mirror of
				https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
				synced 2025-10-31 22:33:56 +01:00 
			
		
		
		
	WARNING this has not beeing tested yet
This commit is contained in:
		
							
								
								
									
										23
									
								
								V4.py
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								V4.py
									
									
									
									
									
								
							| @@ -73,6 +73,7 @@ LogPath = config["PATH"]["logpath"] | ||||
| #discord configurations | ||||
| SuccessLink = config["DISCORD"]["successlink"] | ||||
| ErrorLink = config["DISCORD"]["errorlink"] | ||||
| discord_enabled = config["DISCORD"]["enabled"] | ||||
| #base settings | ||||
| FidelityLink = config["SETTINGS"]["FidelityLink"] | ||||
| embeds = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed | ||||
| @@ -92,9 +93,14 @@ g = open(MotPath, "r", encoding="utf-8") | ||||
| Liste_de_mot = list(g.readline().split(",")) | ||||
| g.close() | ||||
|  | ||||
| webhookSuccess = Webhook.from_url(SuccessLink, adapter=RequestsWebhookAdapter()) | ||||
|  | ||||
| webhookFailure = Webhook.from_url(ErrorLink, adapter=RequestsWebhookAdapter()) | ||||
|  | ||||
| if sql_enabled :  | ||||
|     mycursor = setup_MySQL() | ||||
| if discord_enabled: | ||||
|     webhookSuccess = Webhook.from_url(SuccessLink, adapter=RequestsWebhookAdapter()) | ||||
|  | ||||
| def setup_proxy(ip, port) : | ||||
|     PROXY = f"{ip}:{port}" | ||||
|     webdriver.DesiredCapabilities.FIREFOX['proxy'] = { | ||||
| @@ -110,9 +116,7 @@ def setup_MySQL(): | ||||
|         password=sql_pwd, | ||||
|         database = sql_database | ||||
|     ) | ||||
|     mycursor = mydb.cursor() | ||||
|  | ||||
|  | ||||
|     return(mydb.cursor()) | ||||
|  | ||||
| def add_row(compte, points): | ||||
|     sql = "INSERT INTO daily (compte, points, date) VALUES (%s, %s, current_date())" | ||||
| @@ -128,6 +132,7 @@ def update_row(compte, points): | ||||
|     mydb.commit() | ||||
|     printf(mycursor.rowcount, "record(s) updated") | ||||
|  | ||||
|  | ||||
| def get_row(compte, points, same_points = True): #return if there is a line with the same ammount of point or with the same name as well as the same day | ||||
|     if same_points :  | ||||
|         mycursor.execute(f"SELECT * FROM daily WHERE points = {points} AND compte = '{compte}' AND date = current_date() ;") | ||||
| @@ -136,6 +141,7 @@ def get_row(compte, points, same_points = True): #return if there is a line with | ||||
|     myresult = mycursor.fetchall() | ||||
|     return(len(myresult) == 1) | ||||
|  | ||||
|  | ||||
| def add_to_database(compte, points): | ||||
|     if get_row(compte, points, True): #check if the row exist with the same ammount of points and do nothind if it does | ||||
|         printf("les points sont deja bon") | ||||
| @@ -147,7 +153,6 @@ def add_to_database(compte, points): | ||||
|         printf("row added") | ||||
|  | ||||
|  | ||||
|  | ||||
| def FirefoxDriver(mobile=False, Headless=Headless): | ||||
|     if proxy_enabled : | ||||
|         setup_proxy(proxy_adress,proxy_port) | ||||
| @@ -806,14 +811,16 @@ def LogPoint(account="unknown"):  # log des points sur discord | ||||
|                 point = search('availablePoints":([\d]+)', driver.page_source)[1] | ||||
|             except Exception as e: | ||||
|                 LogError(f"LogPoint - 2 - {e}") | ||||
|                 point = "erreur" | ||||
|         return(points) | ||||
|                 point = -1 | ||||
|         return(point) | ||||
|  | ||||
|     points = get_points() | ||||
|     CustomSleep(uniform(3, 20)) | ||||
|  | ||||
|     account = account.split("@")[0] | ||||
|  | ||||
|     if discord_enabled: | ||||
|  | ||||
|         if embeds: | ||||
|             embed = discord.Embed( | ||||
|                 title=f"{account} actuellement à {str(point)} points", colour=Colour.green() | ||||
| @@ -823,6 +830,8 @@ def LogPoint(account="unknown"):  # log des points sur discord | ||||
|         else: | ||||
|             webhookSuccess.send(f"{account} actuellement à {str(point)} points") | ||||
|  | ||||
|     if sql_enabled : | ||||
|         add_to_database(account, points) | ||||
|  | ||||
| def Fidelite(): | ||||
|     try: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user