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)
|
||||
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 var:
|
||||
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)
|
||||
|
||||
|
||||
async def get_essen():
|
||||
async def get_essen(only_today):
|
||||
global datum, essen, var # , ctx
|
||||
essen = []
|
||||
try:
|
||||
|
@ -158,7 +158,7 @@ async def get_essen():
|
|||
if date_dt >= day:
|
||||
break
|
||||
|
||||
if date_dt < day:
|
||||
if date_dt < day or (only_today and date_dt != day):
|
||||
return
|
||||
datum = date_dt
|
||||
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 send_status("Aufwachen um 10 Uhr")
|
||||
status = "Essen abrufen"
|
||||
await get_essen()
|
||||
await get_essen(True)
|
||||
await send_status("%i Essen gefunden" % len(essen))
|
||||
status = "Essen senden"
|
||||
if len(essen) > 0:
|
||||
|
|
Loading…
Reference in a new issue