caching meals for 15 minutes

This commit is contained in:
Konrad 2019-09-27 19:57:32 +02:00
parent 99de5d26c0
commit 4bf7266951

View file

@ -10,6 +10,7 @@ import traceback
import urllib.request
import xml.etree.ElementTree as ET
from enum import Enum
from time import time
from typing import Any
from urllib.error import HTTPError
@ -54,6 +55,7 @@ essen = []
essen_eng = []
var = True
datum = None
last_updated = 0.0
botID = -1
@ -244,7 +246,11 @@ async def get_essen(only_today: bool) -> None:
:param only_today: only current day; no download if the mensa is closed
:return:
"""
global datum, essen, essen_eng, var # , ctx
global datum, essen, essen_eng, var, last_updated # , ctx
if time() < last_updated + 900:
return
last_updated = time()
essen = []
essen_eng = []
try: