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:
		
							
								
								
									
										53
									
								
								V4.py
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								V4.py
									
									
									
									
									
								
							| @@ -73,6 +73,7 @@ LogPath = config["PATH"]["logpath"] | |||||||
| #discord configurations | #discord configurations | ||||||
| SuccessLink = config["DISCORD"]["successlink"] | SuccessLink = config["DISCORD"]["successlink"] | ||||||
| ErrorLink = config["DISCORD"]["errorlink"] | ErrorLink = config["DISCORD"]["errorlink"] | ||||||
|  | discord_enabled = config["DISCORD"]["enabled"] | ||||||
| #base settings | #base settings | ||||||
| FidelityLink = config["SETTINGS"]["FidelityLink"] | FidelityLink = config["SETTINGS"]["FidelityLink"] | ||||||
| embeds = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed | embeds = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed | ||||||
| @@ -92,27 +93,30 @@ g = open(MotPath, "r", encoding="utf-8") | |||||||
| Liste_de_mot = list(g.readline().split(",")) | Liste_de_mot = list(g.readline().split(",")) | ||||||
| g.close() | g.close() | ||||||
|  |  | ||||||
| webhookSuccess = Webhook.from_url(SuccessLink, adapter=RequestsWebhookAdapter()) |  | ||||||
| webhookFailure = Webhook.from_url(ErrorLink, 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) : | def setup_proxy(ip, port) : | ||||||
|     PROXY = f"{ip}:{port}" |     PROXY = f"{ip}:{port}" | ||||||
|     webdriver.DesiredCapabilities.FIREFOX['proxy'] = { |     webdriver.DesiredCapabilities.FIREFOX['proxy'] = { | ||||||
|     "httpProxy": PROXY, |         "httpProxy": PROXY, | ||||||
|     "sslProxy": PROXY, |         "sslProxy": PROXY, | ||||||
|     "proxyType": "MANUAL", |         "proxyType": "MANUAL", | ||||||
|     } |     } | ||||||
|  |  | ||||||
| def setup_MySQL(): | def setup_MySQL(): | ||||||
|     mydb = mysql.connector.connect( |     mydb = mysql.connector.connect( | ||||||
|     host=sql_host, |         host=sql_host, | ||||||
|     user=sql_usr, |         user=sql_usr, | ||||||
|     password=sql_pwd, |         password=sql_pwd, | ||||||
|     database = sql_database |         database = sql_database | ||||||
|     ) |     ) | ||||||
|     mycursor = mydb.cursor() |     return(mydb.cursor()) | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def add_row(compte, points): | def add_row(compte, points): | ||||||
|     sql = "INSERT INTO daily (compte, points, date) VALUES (%s, %s, current_date())" |     sql = "INSERT INTO daily (compte, points, date) VALUES (%s, %s, current_date())" | ||||||
| @@ -128,6 +132,7 @@ def update_row(compte, points): | |||||||
|     mydb.commit() |     mydb.commit() | ||||||
|     printf(mycursor.rowcount, "record(s) updated") |     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 | 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 :  |     if same_points :  | ||||||
|         mycursor.execute(f"SELECT * FROM daily WHERE points = {points} AND compte = '{compte}' AND date = current_date() ;") |         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() |     myresult = mycursor.fetchall() | ||||||
|     return(len(myresult) == 1) |     return(len(myresult) == 1) | ||||||
|  |  | ||||||
|  |  | ||||||
| def add_to_database(compte, points): | 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 |     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") |         printf("les points sont deja bon") | ||||||
| @@ -147,7 +153,6 @@ def add_to_database(compte, points): | |||||||
|         printf("row added") |         printf("row added") | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def FirefoxDriver(mobile=False, Headless=Headless): | def FirefoxDriver(mobile=False, Headless=Headless): | ||||||
|     if proxy_enabled : |     if proxy_enabled : | ||||||
|         setup_proxy(proxy_adress,proxy_port) |         setup_proxy(proxy_adress,proxy_port) | ||||||
| @@ -806,23 +811,27 @@ def LogPoint(account="unknown"):  # log des points sur discord | |||||||
|                 point = search('availablePoints":([\d]+)', driver.page_source)[1] |                 point = search('availablePoints":([\d]+)', driver.page_source)[1] | ||||||
|             except Exception as e: |             except Exception as e: | ||||||
|                 LogError(f"LogPoint - 2 - {e}") |                 LogError(f"LogPoint - 2 - {e}") | ||||||
|                 point = "erreur" |                 point = -1 | ||||||
|         return(points) |         return(point) | ||||||
|  |  | ||||||
|     points = get_points() |     points = get_points() | ||||||
|     CustomSleep(uniform(3, 20)) |     CustomSleep(uniform(3, 20)) | ||||||
|  |  | ||||||
|     account = account.split("@")[0] |     account = account.split("@")[0] | ||||||
|  |  | ||||||
|     if embeds: |     if discord_enabled: | ||||||
|         embed = discord.Embed( |  | ||||||
|             title=f"{account} actuellement à {str(point)} points", colour=Colour.green() |  | ||||||
|         ) |  | ||||||
|         embed.set_footer(text=account) |  | ||||||
|         webhookSuccess.send(embed=embed) |  | ||||||
|     else: |  | ||||||
|         webhookSuccess.send(f"{account} actuellement à {str(point)} points") |  | ||||||
|  |  | ||||||
|  |         if embeds: | ||||||
|  |             embed = discord.Embed( | ||||||
|  |                 title=f"{account} actuellement à {str(point)} points", colour=Colour.green() | ||||||
|  |             ) | ||||||
|  |             embed.set_footer(text=account) | ||||||
|  |             webhookSuccess.send(embed=embed) | ||||||
|  |         else: | ||||||
|  |             webhookSuccess.send(f"{account} actuellement à {str(point)} points") | ||||||
|  |  | ||||||
|  |     if sql_enabled : | ||||||
|  |         add_to_database(account, points) | ||||||
|  |  | ||||||
| def Fidelite(): | def Fidelite(): | ||||||
|     try: |     try: | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								config
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								config
									
									
									
									
									
								
							| @@ -13,7 +13,7 @@ Headless = True | |||||||
|  |  | ||||||
| successlink = https://discord.com/api/webhooks/[put your webhook here] | successlink = https://discord.com/api/webhooks/[put your webhook here] | ||||||
| errorlink =https://discord.com/api/webhooks/[put your webhook here] | errorlink =https://discord.com/api/webhooks/[put your webhook here] | ||||||
|  | enabled = True | ||||||
| [PROXY] | [PROXY] | ||||||
|  |  | ||||||
| enabled = False | enabled = False | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user