Angerstoner
6 years ago
3 changed files with 115 additions and 116 deletions
-
2db.py
-
111mensa.py
-
118schneiderbot.py
@ -0,0 +1,111 @@ |
|||||
|
import datetime |
||||
|
from telegram import ParseMode |
||||
|
import requests |
||||
|
|
||||
|
DIETS = { |
||||
|
"veggy": "fleischlos", |
||||
|
"fleisch": "mit Fleisch", |
||||
|
"fisch": "mit Fisch/Meeresfrüchten" |
||||
|
} |
||||
|
|
||||
|
WEEKDAYS = { |
||||
|
"montag": 1, |
||||
|
"dienstag": 2, |
||||
|
"mittwoch": 3, |
||||
|
"donnerstag": 4, |
||||
|
"freitag": 5, |
||||
|
"samstag": 6, |
||||
|
} |
||||
|
|
||||
|
MENSA_URL = { |
||||
|
"zentral": "goe1", |
||||
|
"turm": "goe2", |
||||
|
"nord": "goe3", |
||||
|
"italia": "goe4", |
||||
|
"fasthochschule": "goe5" |
||||
|
} |
||||
|
|
||||
|
MENSA_NAME = { |
||||
|
"zentral": "Zentralmensa", |
||||
|
"nord": "Nordmensa", |
||||
|
"turm": "Turmmensa", |
||||
|
"italia": "Mensa Italia", |
||||
|
"fasthochschule": "Bistro Fasthochschule" |
||||
|
} |
||||
|
|
||||
|
HIDE_CATEGORIES_LIGHT = { |
||||
|
"CampusCurry", |
||||
|
"natürlich fit", |
||||
|
"Fitnesscenter", |
||||
|
"Salatbuffet", |
||||
|
"Studentenfutter", |
||||
|
"Süße Versuchung", |
||||
|
"Süße Spezial Tagesangebot", |
||||
|
"Vollwert & Co. Stärke", |
||||
|
"Vollwert & Co. Gemüse", |
||||
|
"Bio-Beilagen", |
||||
|
"Dessertbuffet", |
||||
|
"Last Minute ab 14:30 Uhr", |
||||
|
## Nordmensa: |
||||
|
"Salatbuffet/Pastapoint", |
||||
|
"Last Minute ab 13:30 Uhr", |
||||
|
## Turmmensa: |
||||
|
"Beilagen", |
||||
|
"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 = { |
||||
|
"light": HIDE_CATEGORIES_LIGHT, |
||||
|
"full": HIDE_CATEGORIES_FULL |
||||
|
} |
||||
|
|
||||
|
|
||||
|
def mensa(bot, update, args): |
||||
|
which = "zentral" |
||||
|
filter_categories = MODES["light"] |
||||
|
offset = 0 |
||||
|
# today = datetime.datetime.now().date().weekday() + 1 |
||||
|
if datetime.datetime.now().time() > datetime.time(hour=16): |
||||
|
offset += 1 |
||||
|
# |
||||
|
# today = today % 7 |
||||
|
|
||||
|
for arg in args: |
||||
|
arg = arg.lower() |
||||
|
if arg in MENSA_NAME: |
||||
|
which = arg |
||||
|
elif arg in MODES: |
||||
|
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 |
||||
|
# if today == 0: |
||||
|
# update.message.reply_text("Sonntags hat die Mensa zu") |
||||
|
# return |
||||
|
|
||||
|
url = "https://app.mensaplan.de/api/11102/de.mensaplan.app.android.goettingen/%s.json" % MENSA_URL[which] |
||||
|
request = requests.get(url) |
||||
|
request.encoding = 'utf-8' |
||||
|
data = request.json() |
||||
|
|
||||
|
today_data = data['days'][offset] |
||||
|
|
||||
|
message = "Das Essen für %s in der %s \n\n" % (today_data["date"], MENSA_NAME[which]) |
||||
|
for cat in today_data['categories']: |
||||
|
if cat['name'] not in filter_categories: |
||||
|
meal_line = "*%s*\n" % cat['name'] |
||||
|
for meal in cat['meals']: |
||||
|
meal_line += meal['name'].strip() + "\n" |
||||
|
message += meal_line + '\n' |
||||
|
|
||||
|
update.message.reply_text(message, ParseMode.MARKDOWN) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue