Skip to content

Instantly share code, notes, and snippets.

@M4GNV5
Last active March 21, 2022 10:24
Show Gist options
  • Save M4GNV5/c6ce4a8d7191fd0db5b4a3013f90b85b to your computer and use it in GitHub Desktop.
Save M4GNV5/c6ce4a8d7191fd0db5b4a3013f90b85b to your computer and use it in GitHub Desktop.
Generates a Message to ask where we take lunch today at THI. Uses Neuland App APIs
import requests
from datetime import datetime
def generate_meals_list(url):
data = requests.get(url).json()
today = datetime.now().strftime('%Y-%m-%d')
entries = [x for x in data if x["timestamp"] == today]
if len(entries) == 0:
return "keine Einträge :("
else:
meals = ["- {} ({}€)".format(x["name"], x["prices"]["employee"]) for x in entries[0]["meals"]]
return '\n'.join(meals)
mensa = generate_meals_list("https://dev.neuland.app/api/mensa")
reimanns = generate_meals_list("https://dev.neuland.app/api/reimanns")
print("""Abstimmung bzgl. Mittagsessen heute:
Mensa = :one::
{}
Reimanns = :two::
{}
Home Office = :three::
send pics!
beep boop""".format(mensa, reimanns))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment