.conf eingeführt
This commit is contained in:
parent
c21cb0bdfd
commit
fc1ae86be7
1 changed files with 37 additions and 2 deletions
39
lotto2py.py
39
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue