From fc1ae86be7f7d976db7f8a1056cc23a050526f4b Mon Sep 17 00:00:00 2001 From: hubobel Date: Thu, 24 Jul 2025 16:11:16 +0200 Subject: [PATCH] =?UTF-8?q?.conf=20eingef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lotto2py.py | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/lotto2py.py b/lotto2py.py index bf155df..b8be1a1 100644 --- a/lotto2py.py +++ b/lotto2py.py @@ -3,10 +3,41 @@ from bs4 import BeautifulSoup import re from datetime import datetime import pymysql +import json +import os +import sys -telegram_chat_id = "322673713" -telegram_token ='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4' +def conf(): + appname = os.path.basename(sys.argv[0]) + appname = appname.replace(".py", ".conf") + absFilePath = os.path.abspath(__file__) + absFilePath = absFilePath.replace(".py", ".conf") + if os.path.isfile(absFilePath) is False: + print(appname + ' scheint es nicht zu geben.') + print('Ich lege eine neue Datei ' + appname + ' an.') + passw = {'mail': + { + "mail_pass": "", + "mail_user": "", + "mail_host": "", + "mail_folder": "" + }, + 'Telegram': + { + "Chat_ID": "", + "TOKEN": "" + } + } + + print(str(appname) + ' bitte entsprechend befüllen.') + with open(absFilePath, 'w') as fp: + json.dump(passw, fp, sort_keys=True, indent=4) + quit() + else: + with open(absFilePath) as file: + passw = json.load(file) + return passw def notify_telegram(text): params = {"parse_mode": "HTML", "chat_id": telegram_chat_id, "text": text} url = f"https://api.telegram.org/bot{telegram_token}/sendMessage" @@ -232,6 +263,10 @@ def SQLmittwoch(data): cursor.close() connection.close() +passw = conf() +telegram_chat_id = passw['Telegram']['Chat_ID'] +telegram_token = passw['Telegram']['TOKEN'] + wochentag = datetime.today().weekday() wochentag = 2