bot now sends plan for next lunch (after 14:00), not for current day

Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
klux2 2019-03-17 19:55:34 +01:00
parent b93b745cf0
commit b56bdf9382

View file

@ -144,9 +144,24 @@ async def get_essen():
text = data.decode('utf-8')
et = ET.fromstring(text)
date = et.findall("./menus/day/date")[0].text
datum = datetime.date(int(date[:4]), int(date[5:7]), int(date[8:10]))
menus = et.findall("./menus/day/menu")
dates = et.findall("./menus/day/date")
if datetime.datetime.now().hour > 13:
day = datetime.date.today() + datetime.timedelta(1)
else:
day = datetime.date.today()
if len(dates) == 0:
return
date_dt = None
for i in dates:
date_xml = i.text
date_dt = datetime.date(int(date_xml[:4]), int(date_xml[5:7]), int(date_xml[8:10]))
if date_dt >= day:
break
if date_dt < day:
return
datum = date_dt
menus = et.findall("./menus/day[date='" + datum.isoformat() + "']/menu")
for i in menus:
kategorie = i.findall("type")[0].text