MsRewards-Reborn/main.py

163 lines
4.5 KiB
Python
Raw Normal View History

2022-06-22 12:30:08 +02:00
#/usr/bin/python3.10
import configparser
import os
2022-10-16 14:52:55 +02:00
import shutil
2022-06-22 12:30:08 +02:00
config = configparser.ConfigParser()
2022-10-16 15:20:57 +02:00
try :
config_path = f"{os.path.abspath( os.path.dirname( __file__ ) )}/user_data/config.cfg"
2022-11-06 17:44:35 +01:00
if config.read(config_path)==[] :
raise NameError("le fichier n'existe pas")
except : #doesn't work
2022-10-16 15:20:57 +02:00
default_config = f"{os.path.abspath( os.path.dirname( __file__ ) )}/user_data/config.default"
shutil.copyfile(default_config, config_path)
config.read(config_path)
2022-06-22 20:16:04 +02:00
def confirm(texte, default = False):
if default :
txt = '[Y/n]'
2022-06-22 21:18:08 +02:00
else :
txt = '[y/N]'
2022-06-22 20:16:04 +02:00
yes = ['y', 'yes', 'o', 'oui']
no = ['n', 'non', 'no']
a = input(f"{texte} {txt}").lower()
if a in yes :
return True
elif a in no :
return False
return default
2022-06-22 12:30:08 +02:00
lang = "fr"
text = {"fr" : {
"compte" : "entrer l'adresse mail du compte ",
"mdp" : "entrez le mot de passe du compte ",
2022-10-16 14:00:35 +02:00
"next" : "voulez vous ajouter un compte ? ",
"finc" : "comptes en cours d'ajout ",
"ajout" : "comptes ajouté ",
"fidelity" : "avez vous un lien sur lequel le lien vers la page fidelité du mois est le seul contenu de la page ? ",
"lien" : "entrez le lien ",
"discorde" : "voulez vous envoyer les erreurs sur discord ? ",
"w1" : "entrez le lien du WebHook pour envoyer les points ",
"w2" : "entrez le lien du WebHook pour envoyer les erreurs ",
"msqle" : "voulez vous untiliser une base de donnée ",
"msqll" : "entrez le lien de la base de donnée ",
"msqlu" : "entrez l'utilisateur de la base de donnée ",
"msqlp" : "entrez le mot de passe de la base de donnée ",
"msqlt" : "entrez le nom de la table de la base de donnée ",
"proxye" : "voulez vous utiliser un proxy ",
"proxyl" : "entrez le lien du proxy ",
"proxyp" : "entrez le port du proxy "
2022-06-22 12:30:08 +02:00
}
}
t = text[lang]
def setup():
setup_comptes()
setup_settings()
def setup_comptes():
lc = []
2022-06-22 20:16:04 +02:00
compte = input(t["compte"])
mdp = input(t["mdp"])
2022-06-22 12:30:08 +02:00
lc.append(f"{compte},{mdp}")
for i in range(5):
2022-06-22 20:22:52 +02:00
if confirm(t["next"], default = True):
2022-06-22 20:16:04 +02:00
compte = input(t["compte"])
mdp = input(t["mdp"])
2022-06-22 12:30:08 +02:00
lc.append(f"{compte},{mdp}\n")
else:
print(t["finc"])
break
2022-10-16 14:19:18 +02:00
f = open('./user_data/login.csv', "w")
2022-06-22 12:30:08 +02:00
for i in lc :
f.write(i)
f.close()
print(t["ajout"])
#modifie le fichier de configuration
2022-10-16 14:19:18 +02:00
edit_config_txt("logpath",f'{os.getcwd()}/user_data/login.csv')
2022-06-22 12:30:08 +02:00
2022-10-09 13:33:13 +02:00
def edit_config_txt(ligne, contenu):
f = open(config_path, "r")
txt = f.readlines()
f.close()
if txt.count(txt) >1:
raise NameError("il y a plus d'une occurence, echec de la modification")
for i in range(len(txt)) :
name = txt[i].split(" = ")[0]
if name == ligne:
2022-10-16 14:00:35 +02:00
txt[i] = name + " = " + str(contenu) + "\n"
2022-10-09 13:33:13 +02:00
f = open(config_path, "w")
for i in txt :
f.write(i)
f.close()
2022-06-22 12:30:08 +02:00
def setup_settings():
general()
discord()
proxy()
sql()
2022-10-09 13:33:13 +02:00
amazon()
2022-06-22 12:30:08 +02:00
def general():
2022-06-22 20:22:52 +02:00
if confirm(t["fidelity"]):
2022-06-22 20:16:04 +02:00
lien = input(t["lien"])
2022-10-09 13:33:13 +02:00
edit_config_txt('FidelityLink',lien)
2022-06-22 12:30:08 +02:00
def discord():
2022-06-22 20:22:52 +02:00
enabled = confirm(t["discorde"], default = True)
2022-06-22 12:30:08 +02:00
if enabled :
2022-10-11 21:40:41 +02:00
edit_config_txt("DiscordErrorEnabled", True)
edit_config_txt('DiscordSuccessEnabled', confirm("send success ?", default = True))
2022-06-22 20:16:04 +02:00
w1 = input(t["w1"])
2022-10-09 13:33:13 +02:00
edit_config_txt("successlink",w1)
2022-06-22 20:16:04 +02:00
w2 = input(t["w2"])
2022-10-09 13:33:13 +02:00
edit_config_txt("errorlink",w2)
2022-06-22 12:30:08 +02:00
def sql() :
2022-06-22 20:22:52 +02:00
enabled = confirm(t["msqle"], default = False)
2022-06-22 12:30:08 +02:00
if enabled :
2022-10-11 21:40:41 +02:00
edit_config_txt("sql_enabled", True)
2022-06-22 20:16:04 +02:00
lien = input(t["msqll"])
2022-10-09 13:33:13 +02:00
edit_config_txt("host",lien)
2022-06-22 20:16:04 +02:00
table = input(t["msqlt"])
2022-10-09 13:33:13 +02:00
edit_config_txt("database",table)
2022-06-22 20:16:04 +02:00
user = input(t["msqlu"])
2022-10-09 13:33:13 +02:00
edit_config_txt("usr",user)
2022-06-22 20:16:04 +02:00
pwd = input(t["msqlp"])
2022-10-09 13:33:13 +02:00
edit_config_txt("pwd",pwd)
2022-06-22 12:30:08 +02:00
def proxy() :
2022-06-22 20:22:52 +02:00
enabled = confirm(t["proxye"], default = False)
2022-06-22 12:30:08 +02:00
if enabled :
2022-10-11 21:40:41 +02:00
edit_config_txt("proxy_enabled", True)
2022-06-22 20:16:04 +02:00
lien = input(t["proxyl"])
2022-10-09 13:33:13 +02:00
edit_config_txt("url",lien)
2022-06-22 20:16:04 +02:00
port = input(t["proxyp"])
2022-10-09 13:33:13 +02:00
edit_config_txt("port",port)
2022-06-22 12:30:08 +02:00
2022-10-09 13:33:13 +02:00
def amazon():
enabled = confirm("claim les recompenses automatiquement sur amazon ?", default = False)
edit_config_txt("claim_amazon",enabled)
2022-06-22 12:30:08 +02:00
LogPath = config["PATH"]["logpath"]
if LogPath == "/your/path/to/loginandpass.csv" :
setup()
else :
os.system("python3.10 V4.py")