Browse Source

added day specific mensa commands

quotes
angerstoner 7 years ago
parent
commit
cff984b341
  1. 28
      schneiderbot.py

28
schneiderbot.py

@ -11,6 +11,15 @@ import datetime
import cat
import pydog
WEEKDAYS = {
"montag" : 1,
"dienstag" : 2,
"mittwoch" : 3,
"donnerstag" : 4,
"freitag" : 5,
"samstag" : 6
}
MENSA_URL = {
"zentral": "zentralmensa",
"nord": "nordmensa",
@ -131,22 +140,25 @@ def shrug(bot, update):
def mensa(bot, update, args):
which = "zentral"
filter_categories = MODES["light"]
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
today += 1
today = today % 7
for arg in args:
if arg in MENSA_NAME:
which = args[0]
elif arg in MODES:
filter_categories = MODES[arg]
elif arg in WEEKDAYS:
today = WEEKDAYS[arg]
else:
update.message.reply_text("Falscher Aufruf! RTFM und versuchs nochmal.")
return
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
today += 1
today = today % 7
url = "https://mensa.schneider-hosting.de/static/%s.%d.json" % (MENSA_URL[which], today)
request = requests.get(url)
request.encoding = 'utf-8'

Loading…
Cancel
Save