Ausgabe der neuen DB Einträge
This commit is contained in:
parent
1e3a99b5d2
commit
0124238493
14 changed files with 252 additions and 0 deletions
139
Bahnabfrage.py
Normal file
139
Bahnabfrage.py
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
import requests
|
||||
import telebot
|
||||
import datetime
|
||||
|
||||
hour = datetime.datetime.now().hour
|
||||
TOKEN='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4'
|
||||
ChatID='322673713'
|
||||
tb = telebot.TeleBot(TOKEN)
|
||||
|
||||
antwort=''
|
||||
|
||||
def mzwi():
|
||||
url_zitat = 'https://dbf.finalrewind.org/mainzhbf.json?version=3'
|
||||
resp_zitat = requests.get(url_zitat)
|
||||
data_zitat = resp_zitat.json()
|
||||
telegramm = 'Mainz - Wiesbaden\n'
|
||||
for i in data_zitat['departures']:
|
||||
if i['train'] == "S 8":
|
||||
if i['destination'] == 'Wiesbaden Hbf':
|
||||
antwort = (i['train'] + ' ' + i['platform'] + ' ' + str(i['scheduledDeparture']))
|
||||
if i['isCancelled'] != 1:
|
||||
if i['delayDeparture'] != 0:
|
||||
antwort = antwort + (' Verspätung: ' + str(i['delayDeparture']) + ' Minuten')
|
||||
else:
|
||||
antwort = antwort + ' PÜNKTLICH'
|
||||
else:
|
||||
antwort = antwort + 'CANCELLED!!!'
|
||||
telegramm = telegramm + antwort + '\n'
|
||||
if i['train'] == "RB 75":
|
||||
if i['isCancelled'] != 1:
|
||||
if i['delayDeparture'] != 0:
|
||||
antwort = antwort + (' Verspätung: ' + str(i['delayDeparture']) + ' Minuten')
|
||||
else:
|
||||
antwort = antwort + ' PÜNKTLICH'
|
||||
else:
|
||||
antwort = antwort + 'CANCELLED!!!'
|
||||
telegramm = telegramm + antwort + '\n'
|
||||
return telegramm
|
||||
|
||||
def wimz():
|
||||
url_zitat = 'https://dbf.finalrewind.org/Wiesbadenhbf.json?version=3'
|
||||
resp_zitat = requests.get(url_zitat)
|
||||
data_zitat = resp_zitat.json()
|
||||
telegramm = 'Wiesbaden - Mainz\n'
|
||||
for i in data_zitat['departures']:
|
||||
if i['train'] == "S 8":
|
||||
if i['destination'] == 'Offenbach(Main)Ost':
|
||||
antwort = (i['train'] + ' ' + i['platform'] + ' ' + str(i['scheduledDeparture']))
|
||||
if i['isCancelled'] != 1:
|
||||
if i['delayDeparture'] != 0:
|
||||
antwort = antwort + (' Verspätung: ' + str(i['delayDeparture']) + ' Minuten')
|
||||
else:
|
||||
antwort = antwort + ' PÜNKTLICH'
|
||||
else:
|
||||
antwort = antwort + 'CANCELLED!!!'
|
||||
telegramm = telegramm + antwort + '\n'
|
||||
|
||||
if i['train'] == "RB 75":
|
||||
if i['destination'] == 'Aschaffenburg Hbf':
|
||||
antwort = (i['train'] + ' ' + i['platform'] + ' ' + str(i['scheduledDeparture']))
|
||||
if i['isCancelled'] != 1:
|
||||
if i['delayDeparture'] != 0:
|
||||
antwort = antwort + (' Verspätung: ' + str(i['delayDeparture']) + ' Minuten')
|
||||
else:
|
||||
antwort = antwort + ' PÜNKTLICH'
|
||||
else:
|
||||
antwort = antwort + 'CANCELLED!!!'
|
||||
telegramm = telegramm + antwort + '\n'
|
||||
return telegramm
|
||||
|
||||
def mzaz():
|
||||
url_zitat = 'https://dbf.finalrewind.org/mainzhbf.json?version=3'
|
||||
resp_zitat = requests.get(url_zitat)
|
||||
data_zitat = resp_zitat.json()
|
||||
telegramm = 'Mainz - Alzey\n'
|
||||
for i in data_zitat['departures']:
|
||||
if i['train'] == "RE 13":
|
||||
if i['delayDeparture'] != None:
|
||||
antwort = (i['train'] + ' ' + i['platform'] + ' ' + str(i['scheduledDeparture']))
|
||||
if i['isCancelled'] != 1:
|
||||
if i['delayDeparture'] != 0:
|
||||
antwort = antwort + (' Verspätung: ' + str(i['delayDeparture']) + ' Minuten')
|
||||
else:
|
||||
antwort = antwort + ' PÜNKTLICH'
|
||||
else:
|
||||
antwort = antwort + 'CANCELLED!!!'
|
||||
telegramm = telegramm + antwort + '\n'
|
||||
if i['train'] == "RB 31":
|
||||
if i['delayDeparture'] != None:
|
||||
antwort = (i['train'] + ' ' + i['platform'] + ' ' + str(i['scheduledDeparture']))
|
||||
if i['isCancelled'] != 1:
|
||||
if i['delayDeparture'] != 0:
|
||||
antwort = antwort + (' Verspätung: ' + str(i['delayDeparture']) + ' Minuten')
|
||||
else:
|
||||
antwort = antwort + ' PÜNKTLICH'
|
||||
else:
|
||||
antwort = antwort + 'CANCELLED!!!'
|
||||
telegramm = telegramm + antwort + '\n'
|
||||
return telegramm
|
||||
|
||||
def azmz():
|
||||
url_zitat = 'https://dbf.finalrewind.org/alzeyhbf.json?version=3'
|
||||
resp_zitat = requests.get(url_zitat)
|
||||
data_zitat = resp_zitat.json()
|
||||
telegramm = 'Alzey - Mainz\n'
|
||||
for i in data_zitat['departures']:
|
||||
# print(i)
|
||||
if i['train'] == "RE 13":
|
||||
# print(i)
|
||||
if i['destination'] == 'Mainz Hbf':
|
||||
antwort = (i['train'] + ' ' + i['platform'] + ' ' + str(i['scheduledDeparture']))
|
||||
if i['isCancelled'] != 1:
|
||||
if i['delayDeparture'] != 0:
|
||||
antwort = antwort + (' Verspätung: ' + str(i['delayDeparture']) + ' Minuten')
|
||||
else:
|
||||
antwort = antwort + ' PÜNKTLICH'
|
||||
else:
|
||||
antwort = antwort + 'CANCELLED!!!'
|
||||
telegramm = telegramm + antwort + '\n'
|
||||
if i['train'] == "RB 31":
|
||||
if i['destination'] == 'Mainz Hbf':
|
||||
antwort = (i['train'] + ' ' + i['platform'] + ' ' + str(i['scheduledDeparture']))
|
||||
if i['isCancelled'] != 1:
|
||||
if i['delayDeparture'] != 0:
|
||||
antwort = antwort + (' Verspätung: ' + str(i['delayDeparture']) + ' Minuten')
|
||||
else:
|
||||
antwort = antwort + ' PÜNKTLICH'
|
||||
else:
|
||||
antwort = antwort + 'CANCELLED!!!'
|
||||
telegramm = telegramm + antwort + '\n'
|
||||
return telegramm
|
||||
|
||||
if hour <=12:
|
||||
sendto=(azmz())+'\n'+mzwi()
|
||||
tb.send_message(ChatID, sendto)
|
||||
if hour >=13:
|
||||
sendto = (wimz()) + '\n' + mzaz()
|
||||
tb.send_message(ChatID, sendto)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue