From 1e331efedbfa6f1226f955f2edfbd2aefb4deccf Mon Sep 17 00:00:00 2001 From: angerstoner Date: Sat, 7 Apr 2018 00:46:45 +0200 Subject: [PATCH] added diet to bot, waiting for schneider to push --- schneiderbot.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/schneiderbot.py b/schneiderbot.py index 10fc885..7ec59ea 100644 --- a/schneiderbot.py +++ b/schneiderbot.py @@ -11,6 +11,12 @@ import datetime import cat import pydog +DIETS = { + "veggy" : "fleischlos", + "fleisch" : "mit Fleisch", + "fisch" : "mit Fisch/ Meeresfrüchten" +} + WEEKDAYS = { "montag" : 1, "dienstag" : 2, @@ -136,11 +142,10 @@ def shrug(bot, update): """SHRUG""" update.message.reply_text("¯\_(ツ)_/¯") - def mensa(bot, update, args): which = "zentral" filter_categories = MODES["light"] - + diet = "" today = datetime.datetime.now().date().weekday() + 1 if datetime.datetime.now().time() > datetime.time(hour=16): # 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] elif arg in WEEKDAYS: today = WEEKDAYS[arg] + elif arg in DIETS: + diet = DIETS[arg] else: update.message.reply_text("Falscher Aufruf! RTFM und versuchs nochmal.") return @@ -168,7 +175,7 @@ def mensa(bot, update, args): if len(data["meals"]) > 1: 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 += meal["title"].strip() + "\n"