Browse Source

fix wrong weekday selection bug

master
angerstoner 3 years ago
parent
commit
dd5956f965
  1. 27
      mensa.py

27
mensa.py

@ -3,21 +3,19 @@ from telegram import ParseMode, Update
import requests
from telegram.ext import CallbackContext
DISABLED_GROUPS = [-1001301570558]
DIETS = {
"veggy": ["Vegetarisch", "Vegan"],
"vegan": ["Vegan"]
}
WEEKDAYS = {
"montag": 1,
"dienstag": 2,
"mittwoch": 3,
"donnerstag": 4,
"freitag": 5,
"samstag": 6,
"sonntag": 7
"montag": 0,
"dienstag": 1,
"mittwoch": 2,
"donnerstag": 3,
"freitag": 4,
"samstag": 5,
"sonntag": 6
}
MENSA_URL = {
@ -77,8 +75,6 @@ def linux_mensa(update: Update, context: CallbackContext):
def mensa(update: Update, context: CallbackContext):
if update.message.chat_id in DISABLED_GROUPS:
return
which = "zentral"
filter_categories = MODES["light"]
diet = [""]
@ -92,8 +88,13 @@ def mensa(update: Update, context: CallbackContext):
elif arg in MODES:
filter_categories = MODES[arg]
elif arg in WEEKDAYS:
date_offset = (6 - today.weekday() + WEEKDAYS[arg])
today += datetime.timedelta(days=date_offset)
day = WEEKDAYS[arg]
offset = 0
if day > today.weekday():
offset = day - today.weekday()
elif day < today.weekday():
offset = (7 - today.weekday() + WEEKDAYS[arg])
today += datetime.timedelta(days=offset)
auto_next_day = False
elif arg in DIETS:
diet = DIETS[arg]

Loading…
Cancel
Save