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