Browse Source

filter handling, formatting

quotes
angerstoner 7 years ago
parent
commit
ba9570b671
  1. 62
      schneiderbot.py

62
schneiderbot.py

@ -23,72 +23,36 @@ MENSA_NAME = {
"turm": "Turmmensa" "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",
HIDE_CATEGORIES_LIGHT = {
"CampusCurry", "CampusCurry",
"natürlich fit", "natürlich fit",
"Al dente",
"Pasta und Gratins",
"Fitnesscenter", "Fitnesscenter",
"Salatbuffet", "Salatbuffet",
"Studentenfutter", "Studentenfutter",
"Süße Versuchung", "Süße Versuchung",
"Süße Spezial Tagesangebot", "Süße Spezial Tagesangebot",
"Kartoffeln und Co.",
"Vollwert & Co. Stärke", "Vollwert & Co. Stärke",
"Vollwert & Co. Gemüse", "Vollwert & Co. Gemüse",
"Bio-Beilagen", "Bio-Beilagen",
"Dessertbuffet", "Dessertbuffet",
"Last Minute ab 14:30 Uhr", "Last Minute ab 14:30 Uhr",
## Nordmensa: ## Nordmensa:
"Stamm 1 vegetarisch",
"Nordmensa-Fit",
"Stamm 2",
"Stamm 3",
"Salatbuffet/Pastapoint", "Salatbuffet/Pastapoint",
"Last Minute ab 13:30 Uhr", "Last Minute ab 13:30 Uhr",
## Turmmensa: ## Turmmensa:
"Turm vegetarisch Kombi",
"Turm 2b",
"Turm 3a",
"Turm Vegan",
"Regionale Linie",
"Beilagen", "Beilagen",
"Last Minute ab 14:00Uhr" "Last Minute ab 14:00Uhr"
} }
HIDE_CATEGORIES_FULL = {
"Last Minute ab 14:30 Uhr",
"Last Minute ab 13:30 Uhr",
"Last Minute ab 14:00Uhr"
}
MODES = { MODES = {
"light" : CATEGORIES_LIGHT,
"full" : CATEGORIES_FULL
"light" : HIDE_CATEGORIES_LIGHT,
"full" : HIDE_CATEGORIES_FULL
} }
@ -153,12 +117,12 @@ def manta(bot, update):
def mensa(bot, update, args): def mensa(bot, update, args):
which = "zentral" which = "zentral"
categories = CATEGORIES_LIGHT
filter_categories = MODES["light"]
for arg in args: for arg in args:
if arg in MENSA_NAME: if arg in MENSA_NAME:
which = args[0] which = args[0]
elif arg in MODES: elif arg in MODES:
categories = MODES[arg]
filter_categories = MODES[arg]
else: else:
update.message.reply_text("Falscher Aufruf! RTFM und versuchs nochmal.") update.message.reply_text("Falscher Aufruf! RTFM und versuchs nochmal.")
return return
@ -175,11 +139,11 @@ def mensa(bot, update, args):
request.encoding = 'utf-8' request.encoding = 'utf-8'
data = request.json() data = request.json()
message = "Das Essen für %s in der %s \n" % (data["date"], MENSA_NAME[which])
message = "Das Essen für %s in der %s \n\n" % (data["date"], MENSA_NAME[which])
if len(data["meals"]) > 1: if len(data["meals"]) > 1:
for meal in data["meals"]: for meal in data["meals"]:
if meal["category"] in categories:
if meal["category"] not in filter_categories:
meal_line = "*%s*\n" % meal["category"] meal_line = "*%s*\n" % meal["category"]
meal_line += meal["title"].strip() + "\n" meal_line += meal["title"].strip() + "\n"

Loading…
Cancel
Save