bug fix: daily message was sent on every day
If the mensa is closed (e. g. weekends), this message shouldn't be send. After b56bdf9382
, the food for the next day was sent, even if this was monday
Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
parent
b56bdf9382
commit
b6fef40174
1 changed files with 4 additions and 4 deletions
|
@ -80,7 +80,7 @@ class HSMensaW(telepot.aio.helper.ChatHandler):
|
||||||
chat = get_chat_name(msg)
|
chat = get_chat_name(msg)
|
||||||
await send_status("Essen angefordert für Chat %s (ID: %i)" % (chat, chat_id))
|
await send_status("Essen angefordert für Chat %s (ID: %i)" % (chat, chat_id))
|
||||||
|
|
||||||
await get_essen()
|
await get_essen(False)
|
||||||
if len(essen) == 0:
|
if len(essen) == 0:
|
||||||
if var:
|
if var:
|
||||||
await bot.sendMessage(chat_id, "Es ist ein Fehler aufgetreten. Bitte später erneut versuchen.")
|
await bot.sendMessage(chat_id, "Es ist ein Fehler aufgetreten. Bitte später erneut versuchen.")
|
||||||
|
@ -125,7 +125,7 @@ async def send_status(text):
|
||||||
await bot.sendMessage(chat_id, text)
|
await bot.sendMessage(chat_id, text)
|
||||||
|
|
||||||
|
|
||||||
async def get_essen():
|
async def get_essen(only_today):
|
||||||
global datum, essen, var # , ctx
|
global datum, essen, var # , ctx
|
||||||
essen = []
|
essen = []
|
||||||
try:
|
try:
|
||||||
|
@ -158,7 +158,7 @@ async def get_essen():
|
||||||
if date_dt >= day:
|
if date_dt >= day:
|
||||||
break
|
break
|
||||||
|
|
||||||
if date_dt < day:
|
if date_dt < day or (only_today and date_dt != day):
|
||||||
return
|
return
|
||||||
datum = date_dt
|
datum = date_dt
|
||||||
menus = et.findall("./menus/day[date='" + datum.isoformat() + "']/menu")
|
menus = et.findall("./menus/day[date='" + datum.isoformat() + "']/menu")
|
||||||
|
@ -211,7 +211,7 @@ async def essen_loop():
|
||||||
await asyncio.sleep((next_day - now).seconds)
|
await asyncio.sleep((next_day - now).seconds)
|
||||||
await send_status("Aufwachen um 10 Uhr")
|
await send_status("Aufwachen um 10 Uhr")
|
||||||
status = "Essen abrufen"
|
status = "Essen abrufen"
|
||||||
await get_essen()
|
await get_essen(True)
|
||||||
await send_status("%i Essen gefunden" % len(essen))
|
await send_status("%i Essen gefunden" % len(essen))
|
||||||
status = "Essen senden"
|
status = "Essen senden"
|
||||||
if len(essen) > 0:
|
if len(essen) > 0:
|
||||||
|
|
Loading…
Reference in a new issue