Browse Source

added diet to bot, waiting for schneider to push

quotes
angerstoner 7 years ago
parent
commit
1e331efedb
  1. 13
      schneiderbot.py

13
schneiderbot.py

@ -11,6 +11,12 @@ import datetime
import cat import cat
import pydog import pydog
DIETS = {
"veggy" : "fleischlos",
"fleisch" : "mit Fleisch",
"fisch" : "mit Fisch/ Meeresfrüchten"
}
WEEKDAYS = { WEEKDAYS = {
"montag" : 1, "montag" : 1,
"dienstag" : 2, "dienstag" : 2,
@ -136,11 +142,10 @@ def shrug(bot, update):
"""SHRUG""" """SHRUG"""
update.message.reply_text("¯\_(ツ)_/¯") update.message.reply_text("¯\_(ツ)_/¯")
def mensa(bot, update, args): def mensa(bot, update, args):
which = "zentral" which = "zentral"
filter_categories = MODES["light"] filter_categories = MODES["light"]
diet = ""
today = datetime.datetime.now().date().weekday() + 1 today = datetime.datetime.now().date().weekday() + 1
if datetime.datetime.now().time() > datetime.time(hour=16): if datetime.datetime.now().time() > datetime.time(hour=16):
# Es ist zu spät am Tag, zeig das essen für morgen an # Es ist zu spät am Tag, zeig das essen für morgen an
@ -155,6 +160,8 @@ def mensa(bot, update, args):
filter_categories = MODES[arg] filter_categories = MODES[arg]
elif arg in WEEKDAYS: elif arg in WEEKDAYS:
today = WEEKDAYS[arg] today = WEEKDAYS[arg]
elif arg in DIETS:
diet = DIETS[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
@ -168,7 +175,7 @@ def mensa(bot, update, args):
if len(data["meals"]) > 1: if len(data["meals"]) > 1:
for meal in data["meals"]: for meal in data["meals"]:
if meal["category"] not in filter_categories:
if meal["category"] not in filter_categories and diet in meal["diet"]:
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