mirror of
				https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
				synced 2025-11-03 23:23:53 +01:00 
			
		
		
		
	i don't know what I am doing
This commit is contained in:
		
							
								
								
									
										61
									
								
								V4.py
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								V4.py
									
									
									
									
									
								
							@@ -22,7 +22,7 @@ from selenium.webdriver.common.by import By
 | 
				
			|||||||
from selenium.webdriver.common.keys import Keys
 | 
					from selenium.webdriver.common.keys import Keys
 | 
				
			||||||
from selenium.webdriver.firefox.options import Options
 | 
					from selenium.webdriver.firefox.options import Options
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
import mysql.connector
 | 
					from modules.MySQL import add_to_database
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
@@ -143,60 +143,6 @@ def setup_proxy(ip, port) :
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def add_row(compte, points, mycursor, mydb):
 | 
					 | 
				
			||||||
    sql = "INSERT INTO daily (compte, points, date) VALUES (%s, %s, current_date())"
 | 
					 | 
				
			||||||
    val = (compte, points)
 | 
					 | 
				
			||||||
    mycursor.execute(sql, val)
 | 
					 | 
				
			||||||
    mydb.commit()
 | 
					 | 
				
			||||||
    printf(mycursor.rowcount, "record created.")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def update_row(compte, points, mycursor, mydb):
 | 
					 | 
				
			||||||
    sql = f"UPDATE daily SET points = {points} WHERE compte = '{compte}' AND date = current_date() ;"
 | 
					 | 
				
			||||||
    mycursor.execute(sql)
 | 
					 | 
				
			||||||
    mydb.commit()
 | 
					 | 
				
			||||||
    printf(mycursor.rowcount, "record(s) updated")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def update_last(compte, points, mycursor, mydb):
 | 
					 | 
				
			||||||
    sql = f"UPDATE comptes SET last_pts = {points} WHERE compte = '{compte}';"
 | 
					 | 
				
			||||||
    mycursor.execute(sql)
 | 
					 | 
				
			||||||
    mydb.commit()
 | 
					 | 
				
			||||||
    printf(mycursor.rowcount, "record(s) updated")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def get_row(compte, points, mycursor, 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() ;")
 | 
					 | 
				
			||||||
    else :
 | 
					 | 
				
			||||||
        mycursor.execute(f"SELECT * FROM daily WHERE compte = '{compte}' AND date = current_date() ;")
 | 
					 | 
				
			||||||
    myresult = mycursor.fetchall()
 | 
					 | 
				
			||||||
    return(len(myresult) == 1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def add_to_database(compte, points):
 | 
					 | 
				
			||||||
    mydb = mysql.connector.connect(
 | 
					 | 
				
			||||||
        host=sql_host,
 | 
					 | 
				
			||||||
        user=sql_usr,
 | 
					 | 
				
			||||||
        password=sql_pwd,
 | 
					 | 
				
			||||||
        database = sql_database
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
    mycursor = mydb.cursor()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if get_row(compte, points,mycursor, True): #check if the row exist with the same ammount of points and do nothind if it does
 | 
					 | 
				
			||||||
        printf("les points sont deja bon")
 | 
					 | 
				
			||||||
    elif get_row(compte, points,mycursor, False) : #check if the row exist, but without the same ammount of points and update the point account then
 | 
					 | 
				
			||||||
        update_row(compte, points,mycursor,mydb)
 | 
					 | 
				
			||||||
        printf("row updated")
 | 
					 | 
				
			||||||
    else : # if the row don't exist, create it with the good ammount of points
 | 
					 | 
				
			||||||
        add_row(compte, points,mycursor,mydb)
 | 
					 | 
				
			||||||
        printf("row added")
 | 
					 | 
				
			||||||
    if int(points) > 10 :
 | 
					 | 
				
			||||||
        update_last(compte, points, mycursor, mydb)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    mycursor.close()
 | 
					 | 
				
			||||||
    mydb.close()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def FirefoxDriver(mobile=False, Headless=Headless):
 | 
					def FirefoxDriver(mobile=False, Headless=Headless):
 | 
				
			||||||
    if proxy_enabled :
 | 
					    if proxy_enabled :
 | 
				
			||||||
@@ -997,7 +943,7 @@ def Fidelite():
 | 
				
			|||||||
                        Close(driver.window_handles[1])
 | 
					                        Close(driver.window_handles[1])
 | 
				
			||||||
                    except Exception as e:
 | 
					                    except Exception as e:
 | 
				
			||||||
                        printf(e)
 | 
					                        printf(e)
 | 
				
			||||||
                printf("on a reussit la partie fidélité (ou pas et tout est pété)")
 | 
					                printf("fidelité - done")
 | 
				
			||||||
            else :
 | 
					            else :
 | 
				
			||||||
                printf("lien invalide")
 | 
					                printf("lien invalide")
 | 
				
			||||||
    except Exception as e:
 | 
					    except Exception as e:
 | 
				
			||||||
@@ -1145,6 +1091,3 @@ else:
 | 
				
			|||||||
        except KeyboardInterrupt:
 | 
					        except KeyboardInterrupt:
 | 
				
			||||||
            print("canceled")
 | 
					            print("canceled")
 | 
				
			||||||
            close()
 | 
					            close()
 | 
				
			||||||
 | 
					 | 
				
			||||||
if LINUX_HOST:
 | 
					 | 
				
			||||||
    system("pkill -9 firefox")
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										60
									
								
								modules/MySQL.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								modules/MySQL.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					import mysql.connector
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def add_row(compte, points, mycursor, mydb):
 | 
				
			||||||
 | 
					    sql = "INSERT INTO daily (compte, points, date) VALUES (%s, %s, current_date())"
 | 
				
			||||||
 | 
					    val = (compte, points)
 | 
				
			||||||
 | 
					    mycursor.execute(sql, val)
 | 
				
			||||||
 | 
					    mydb.commit()
 | 
				
			||||||
 | 
					    printf(mycursor.rowcount, "record created.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def update_row(compte, points, mycursor, mydb):
 | 
				
			||||||
 | 
					    sql = f"UPDATE daily SET points = {points} WHERE compte = '{compte}' AND date = current_date() ;"
 | 
				
			||||||
 | 
					    mycursor.execute(sql)
 | 
				
			||||||
 | 
					    mydb.commit()
 | 
				
			||||||
 | 
					    printf(mycursor.rowcount, "record(s) updated")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def update_last(compte, points, mycursor, mydb):
 | 
				
			||||||
 | 
					    sql = f"UPDATE comptes SET last_pts = {points} WHERE compte = '{compte}';"
 | 
				
			||||||
 | 
					    mycursor.execute(sql)
 | 
				
			||||||
 | 
					    mydb.commit()
 | 
				
			||||||
 | 
					    printf(mycursor.rowcount, "record(s) updated")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_row(compte, points, mycursor, 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() ;")
 | 
				
			||||||
 | 
					    else :
 | 
				
			||||||
 | 
					        mycursor.execute(f"SELECT * FROM daily WHERE compte = '{compte}' AND date = current_date() ;")
 | 
				
			||||||
 | 
					    myresult = mycursor.fetchall()
 | 
				
			||||||
 | 
					    return(len(myresult) == 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def add_to_database(compte, points):
 | 
				
			||||||
 | 
					    mydb = mysql.connector.connect(
 | 
				
			||||||
 | 
					        host=sql_host,
 | 
				
			||||||
 | 
					        user=sql_usr,
 | 
				
			||||||
 | 
					        password=sql_pwd,
 | 
				
			||||||
 | 
					        database = sql_database
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    mycursor = mydb.cursor()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if get_row(compte, points,mycursor, True): #check if the row exist with the same ammount of points and do nothind if it does
 | 
				
			||||||
 | 
					        #printf("les points sont deja bon")
 | 
				
			||||||
 | 
					        return(0)
 | 
				
			||||||
 | 
					    elif get_row(compte, points,mycursor, False) : #check if the row exist, but without the same ammount of points and update the point account then
 | 
				
			||||||
 | 
					        update_row(compte, points,mycursor,mydb)
 | 
				
			||||||
 | 
					        #printf("row updated")
 | 
				
			||||||
 | 
					        return(1)
 | 
				
			||||||
 | 
					    else : # if the row don't exist, create it with the good ammount of points
 | 
				
			||||||
 | 
					        add_row(compte, points,mycursor,mydb)
 | 
				
			||||||
 | 
					        return(2) #printf("row added")
 | 
				
			||||||
 | 
					    if int(points) > 10 :
 | 
				
			||||||
 | 
					        update_last(compte, points, mycursor, mydb)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mycursor.close()
 | 
				
			||||||
 | 
					    mydb.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Reference in New Issue
	
	Block a user