From 49cf33c78053b88067e5eebfe8f26f9090a640e8 Mon Sep 17 00:00:00 2001 From: piair Date: Tue, 11 Oct 2022 21:40:41 +0200 Subject: [PATCH] a lot easier to edit after. --- V4.py | 20 +++++++++++--------- config | 7 ++++--- main.py | 22 ++++++---------------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/V4.py b/V4.py index dccbac5..b4126b2 100755 --- a/V4.py +++ b/V4.py @@ -55,7 +55,7 @@ FAST = args.fast if CUSTOM_START : LOG = True -#SOON (maybe) +#SOON (maybe) (no) #logpath = ("/".join(__file__.split("/")[:-1])+"/LogFile.out") #logfile = open(logpath, "w") @@ -87,24 +87,26 @@ CREDENTIALS_PATH = config["PATH"]["logpath"] # discord configuration DISCORD_SUCCESS_LINK = config["DISCORD"]["successlink"] DISCORD_ERROR_LINK = config["DISCORD"]["errorlink"] -DISCORD_ENABLED = config["DISCORD"]["enabled"] +DISCORD_ENABLED_ERROR = config["DISCORD"]["DiscordErrorEnabled"] +DISCORD_ENABLED_SUCCESS = config["DISCORD"]["DiscordSuccessEnabled"] -if DISCORD_ENABLED: +if ErrorEnabled: webhookFailure = Webhook.from_url(DISCORD_ERROR_LINK, adapter=RequestsWebhookAdapter()) +if SuccessEnabled: webhookSuccess = Webhook.from_url(DISCORD_SUCCESS_LINK, adapter=RequestsWebhookAdapter()) # base settings FidelityLink = config["SETTINGS"]["FidelityLink"] -embeds = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed +DISCORD_EMBED = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed Headless = config["SETTINGS"]["headless"] == "True" # proxy settings -proxy_enabled = config["PROXY"]["enabled"] == "True" +proxy_enabled = config["PROXY"]["proxy_enabled"] == "True" proxy_address = config["PROXY"]["url"] proxy_port = config["PROXY"]["port"] # MySQL settings -sql_enabled = config["SQL"]["enabled"] == "True" +sql_enabled = config["SQL"]["sql_enabled"] == "True" sql_usr = config["SQL"]["usr"] sql_pwd = config["SQL"]["pwd"] sql_host = config["SQL"]["host"] @@ -266,7 +268,7 @@ def LogError(message, log=FULL_LOG, Mobdriver=None): else: gdriver = driver - if LINUX_HOST and DISCORD_ENABLED: + if LINUX_HOST and DISCORD_ENABLED_ERROR: with open("page.html", "w") as f: f.write(gdriver.page_source) @@ -911,9 +913,9 @@ def LogPoint(account="unknown"): # log des points sur discord account = account.split("@")[0] - if DISCORD_ENABLED: + if DISCORD_ENABLED_SUCCESS: - if embeds: + if DISCORD_EMBED: embed = discord.Embed( title=f"{account} actuellement à {str(points)} points", colour=Colour.green() ) diff --git a/config b/config index 12740ab..380b887 100644 --- a/config +++ b/config @@ -11,19 +11,20 @@ Headless = True [DISCORD] -enabled = True +DiscordErrorEnabled = True +DiscordSuccessEnabled = True successlink = https://discord.com/api/webhooks/[put your webhook here] errorlink =https://discord.com/api/webhooks/[put your webhook here] [PROXY] -enabled = False +proxy_enabled = False url = Null port = 0 [SQL] -enabled = False +sql_enabled = False host = Null database = MsRewards usr = root diff --git a/main.py b/main.py index 9f3d7a6..58ee6c6 100644 --- a/main.py +++ b/main.py @@ -32,7 +32,7 @@ text = {"fr" : { "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 points sur discord ?", + "discorde" : "voulez vous envoyer les erreurs sur discord ?", "w1" : "entrez le lien du WebHook pour envoyer les points (https://support.discord.com/hc/fr/articles/228383668-Utiliser-les-Webhooks)", "w2" : "entrez le lien du WebHook pour envoyer les erreurs", "msqle" : "voulez vous untiliser une base de donnée", @@ -76,18 +76,6 @@ def setup_comptes(): edit_config_txt("logpath",f'{os.getcwd()}/login.csv') -def edit_config_ligne(ligne, contenu): - f = open(config_path, "r") - txt = f.readlines() - txt[ligne] = f'{txt[ligne].split("=")[0]}= {contenu}\n' - f.close() - - f = open(config_path, "w") - for i in txt : - f.write(i) - f.close() - - def edit_config_txt(ligne, contenu): f = open(config_path, "r") txt = f.readlines() @@ -121,7 +109,9 @@ def general(): def discord(): enabled = confirm(t["discorde"], default = True) if enabled : - edit_config_ligne(13, True) + edit_config_txt("DiscordErrorEnabled", True) + + edit_config_txt('DiscordSuccessEnabled', confirm("send success ?", default = True)) w1 = input(t["w1"]) edit_config_txt("successlink",w1) w2 = input(t["w2"]) @@ -130,7 +120,7 @@ def discord(): def sql() : enabled = confirm(t["msqle"], default = False) if enabled : - edit_config_ligne(25, True) + edit_config_txt("sql_enabled", True) lien = input(t["msqll"]) edit_config_txt("host",lien) table = input(t["msqlt"]) @@ -143,7 +133,7 @@ def sql() : def proxy() : enabled = confirm(t["proxye"], default = False) if enabled : - edit_config_ligne(19, True) + edit_config_txt("proxy_enabled", True) lien = input(t["proxyl"]) edit_config_txt("url",lien) port = input(t["proxyp"])