Compare commits
No commits in common. "c9c95350a814b4a4521f3f71f8f12aaf64b63d7a" and "71af05c3ba12c0219914c90d002d4ff0694456e6" have entirely different histories.
c9c95350a8
...
71af05c3ba
@ -4,7 +4,7 @@ LABEL maintainer="Lord Baryhobal <lordbaryhobal@gmail.com>"
|
||||
|
||||
RUN echo "Installing Typst" \
|
||||
&& wget -q -O /tmp/typst.tar.xz https://github.com/typst/typst/releases/download/v0.11.1/typst-x86_64-unknown-linux-musl.tar.xz \
|
||||
&& tar -xf /tmp/typst.tar.xz -C /tmp/ \
|
||||
&& tar -x /tmp/typst.tar.xz -C /tmp/ \
|
||||
&& mv /tmp/typst-x86_64-unknown-linux-musl/typst /usr/bin/typst \
|
||||
&& chmod +x /usr/bin/typst \
|
||||
&& rm -r /tmp/typst-x86_64-unknown-linux-musl \
|
||||
|
@ -215,14 +215,9 @@ class BeeBot:
|
||||
async with self.fetch_lock:
|
||||
if not os.path.exists(menu_path) or self.is_outdated(menu_id, today_only):
|
||||
if today_only:
|
||||
available = await self.fetch_today_menu()
|
||||
await self.fetch_today_menu()
|
||||
else:
|
||||
available = await self.fetch_week_menu()
|
||||
|
||||
if not available:
|
||||
await msg.edit_text(self.i18n(prefs["lang"], "notif.unavailable"))
|
||||
return
|
||||
|
||||
await self.fetch_week_menu()
|
||||
await msg.delete()
|
||||
|
||||
# If image needs to be (re)generated
|
||||
@ -343,41 +338,33 @@ class BeeBot:
|
||||
self.cache[menu_id] = datetime.datetime.today().strftime("%Y-%m-%d")
|
||||
self.save_cache()
|
||||
|
||||
async def fetch_week_menu(self) -> bool:
|
||||
async def fetch_week_menu(self) -> None:
|
||||
logger.info("Fetching week menu")
|
||||
today = datetime.datetime.today()
|
||||
delta = datetime.timedelta(days=today.weekday())
|
||||
monday = today - delta
|
||||
days = []
|
||||
menus_count = 0
|
||||
for i in range(5):
|
||||
dt = datetime.timedelta(days=i)
|
||||
date = monday + dt
|
||||
menus = await self.fetch_menu(date)
|
||||
menus_count += len(menus)
|
||||
days.append({
|
||||
"date": date.strftime("%Y-%m-%d"),
|
||||
"menus": menus
|
||||
})
|
||||
if menus_count == 0:
|
||||
return False
|
||||
|
||||
self.save_menu(days, "week_menu", "menus_week.json")
|
||||
return True
|
||||
|
||||
async def fetch_today_menu(self) -> bool:
|
||||
async def fetch_today_menu(self) -> None:
|
||||
logger.info("Fetching today menu")
|
||||
today = datetime.datetime.today()
|
||||
menus = await self.fetch_menu(today)
|
||||
if len(menus) == 0:
|
||||
return False
|
||||
days = [{
|
||||
"date": today.strftime("%Y-%m-%d"),
|
||||
"menus": menus
|
||||
}]
|
||||
|
||||
self.save_menu(days, "today_menu", "menus_today.json")
|
||||
return True
|
||||
|
||||
async def fetch_menu(self, date: datetime.date) -> list:
|
||||
url = self.MENU_URL.format(date=date.strftime("%Y-%m-%d"))
|
||||
|
@ -10,8 +10,7 @@
|
||||
"menu.back_to_settings": "Retour aux paramètres",
|
||||
"setting.language": "Langue: {}",
|
||||
"setting.categories": "Catégories: {}",
|
||||
"notif.wait_updating": "Le menu est en train d'être mis à jour, veuillez patienter...",
|
||||
"notif.unavailable": "Il semblerait que le menu ne soit actuellement pas disponible"
|
||||
"notif.wait_updating": "Le menu est en train d'être mis à jour, veuillez patienter..."
|
||||
},
|
||||
"en": {
|
||||
"category.student": "Student",
|
||||
@ -24,8 +23,7 @@
|
||||
"menu.back_to_settings": "Back to settings",
|
||||
"setting.language": "Language: {}",
|
||||
"setting.categories": "Categories: {}",
|
||||
"notif.wait_updating": "The menu is being updated, please wait...",
|
||||
"notif.unavailable": "It seems that the menu is currently unavailable"
|
||||
"notif.wait_updating": "The menu is being updated, please wait..."
|
||||
},
|
||||
"de": {
|
||||
"category.student": "Student",
|
||||
@ -38,7 +36,6 @@
|
||||
"menu.back_to_settings": "Zurück zu Einstellungen",
|
||||
"setting.language": "Sprache: {}",
|
||||
"setting.categories": "Kategorien: {}",
|
||||
"notif.wait_updating": "Das Menü wird gerade aktualisiert, bitte warten Sie...",
|
||||
"notif.unavailable": "Es scheint, dass das Menü derzeit nicht verfügbar ist"
|
||||
"notif.wait_updating": "Das Menü wird gerade aktualisiert, bitte warten Sie..."
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user