Browse Source

added filtering

master
angerstoner 7 years ago
parent
commit
9c80bf8634
  1. 78
      schneiderbot.py

78
schneiderbot.py

@ -13,12 +13,82 @@ MENSA_URL = {
"nord": "nordmensa",
"turm": "turmmensa"
}
MENSA_NAME = {
"zentral": "Zentralmensa",
"nord": "Nordmensa",
"turm": "Turmmensa"
}
## TODO: rather use filter list, this is bloated; mensa italia missing
CATEGORIES_LIGHT = {
"Eintopf",
"Menü I",
"Menü II",
"Vegan",
"Vegetarisch",
"Grill III",
"Al dente",
"Pasta und Gratins",
"Kartoffeln und Co.",
## Nordmensa:
"Stamm 1 vegetarisch",
"Nordmensa-Fit",
"Stamm 2",
"Stamm 3",
## Turmmensa:
"Turm vegetarisch Kombi",
"Turm 2b",
"Turm 3a",
"Turm Vegan",
"Regionale Linie"
}
CATEGORIES_FULL = {
"Eintopf",
"Menü I",
"Menü II",
"Vegan",
"Vegetarisch",
"Grill III",
"CampusCurry",
"natürlich fit",
"Al dente",
"Pasta und Gratins",
"Fitnesscenter",
"Salatbuffet",
"Studentenfutter",
"Süße Versuchung",
"Süße Spezial Tagesangebot",
"Kartoffeln und Co.",
"Vollwert & Co. Stärke",
"Vollwert & Co. Gemüse",
"Bio-Beilagen",
"Dessertbuffet",
"Last Minute ab 14:30 Uhr",
## Nordmensa:
"Stamm 1 vegetarisch",
"Nordmensa-Fit",
"Stamm 2",
"Stamm 3",
"Salatbuffet/Pastapoint",
"Last Minute ab 13:30 Uhr",
## Turmmensa:
"Turm vegetarisch Kombi",
"Turm 2b",
"Turm 3a",
"Turm Vegan",
"Regionale Linie",
"Beilagen",
"Last Minute ab 14:00Uhr"
}
MODES = {
"light" : CATEGORIES_LIGHT,
"full" : CATEGORIES_FULL
}
# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
@ -56,8 +126,13 @@ def manta(bot, update):
def mensa(bot, update, args):
which = "zentral"
if len(args):
categories = CATEGORIES_LIGHT
for arg in args:
if arg in MENSA_NAME:
which = args[0]
elif arg in MODES:
categories = MODES[arg]
if which not in MENSA_NAME:
update.message.reply_text("Diese Mensa gibt es nicht! RTFM und versuchs nochmal.")
@ -80,6 +155,7 @@ def mensa(bot, update, args):
if len(data["meals"]) > 0:
for meal in data["meals"]:
if meal["category"] in categories:
meal_line = "*%s*\n" % meal["category"]
meal_line += meal["title"].strip() + "\n"

Loading…
Cancel
Save