Compare commits

..

No commits in common. "c9c95350a814b4a4521f3f71f8f12aaf64b63d7a" and "71af05c3ba12c0219914c90d002d4ff0694456e6" have entirely different histories.

3 changed files with 8 additions and 24 deletions

View File

@ -4,7 +4,7 @@ LABEL maintainer="Lord Baryhobal <lordbaryhobal@gmail.com>"
RUN echo "Installing Typst" \ 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 \ && 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 \ && mv /tmp/typst-x86_64-unknown-linux-musl/typst /usr/bin/typst \
&& chmod +x /usr/bin/typst \ && chmod +x /usr/bin/typst \
&& rm -r /tmp/typst-x86_64-unknown-linux-musl \ && rm -r /tmp/typst-x86_64-unknown-linux-musl \

View File

@ -215,14 +215,9 @@ class BeeBot:
async with self.fetch_lock: async with self.fetch_lock:
if not os.path.exists(menu_path) or self.is_outdated(menu_id, today_only): if not os.path.exists(menu_path) or self.is_outdated(menu_id, today_only):
if today_only: if today_only:
available = await self.fetch_today_menu() await self.fetch_today_menu()
else: else:
available = await self.fetch_week_menu() await self.fetch_week_menu()
if not available:
await msg.edit_text(self.i18n(prefs["lang"], "notif.unavailable"))
return
await msg.delete() await msg.delete()
# If image needs to be (re)generated # 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.cache[menu_id] = datetime.datetime.today().strftime("%Y-%m-%d")
self.save_cache() self.save_cache()
async def fetch_week_menu(self) -> bool: async def fetch_week_menu(self) -> None:
logger.info("Fetching week menu") logger.info("Fetching week menu")
today = datetime.datetime.today() today = datetime.datetime.today()
delta = datetime.timedelta(days=today.weekday()) delta = datetime.timedelta(days=today.weekday())
monday = today - delta monday = today - delta
days = [] days = []
menus_count = 0
for i in range(5): for i in range(5):
dt = datetime.timedelta(days=i) dt = datetime.timedelta(days=i)
date = monday + dt date = monday + dt
menus = await self.fetch_menu(date) menus = await self.fetch_menu(date)
menus_count += len(menus)
days.append({ days.append({
"date": date.strftime("%Y-%m-%d"), "date": date.strftime("%Y-%m-%d"),
"menus": menus "menus": menus
}) })
if menus_count == 0:
return False
self.save_menu(days, "week_menu", "menus_week.json") 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") logger.info("Fetching today menu")
today = datetime.datetime.today() today = datetime.datetime.today()
menus = await self.fetch_menu(today) menus = await self.fetch_menu(today)
if len(menus) == 0:
return False
days = [{ days = [{
"date": today.strftime("%Y-%m-%d"), "date": today.strftime("%Y-%m-%d"),
"menus": menus "menus": menus
}] }]
self.save_menu(days, "today_menu", "menus_today.json") self.save_menu(days, "today_menu", "menus_today.json")
return True
async def fetch_menu(self, date: datetime.date) -> list: async def fetch_menu(self, date: datetime.date) -> list:
url = self.MENU_URL.format(date=date.strftime("%Y-%m-%d")) url = self.MENU_URL.format(date=date.strftime("%Y-%m-%d"))

View File

@ -10,8 +10,7 @@
"menu.back_to_settings": "Retour aux paramètres", "menu.back_to_settings": "Retour aux paramètres",
"setting.language": "Langue: {}", "setting.language": "Langue: {}",
"setting.categories": "Catégories: {}", "setting.categories": "Catégories: {}",
"notif.wait_updating": "Le menu est en train d'être mis à jour, veuillez patienter...", "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"
}, },
"en": { "en": {
"category.student": "Student", "category.student": "Student",
@ -24,8 +23,7 @@
"menu.back_to_settings": "Back to settings", "menu.back_to_settings": "Back to settings",
"setting.language": "Language: {}", "setting.language": "Language: {}",
"setting.categories": "Categories: {}", "setting.categories": "Categories: {}",
"notif.wait_updating": "The menu is being updated, please wait...", "notif.wait_updating": "The menu is being updated, please wait..."
"notif.unavailable": "It seems that the menu is currently unavailable"
}, },
"de": { "de": {
"category.student": "Student", "category.student": "Student",
@ -38,7 +36,6 @@
"menu.back_to_settings": "Zurück zu Einstellungen", "menu.back_to_settings": "Zurück zu Einstellungen",
"setting.language": "Sprache: {}", "setting.language": "Sprache: {}",
"setting.categories": "Kategorien: {}", "setting.categories": "Kategorien: {}",
"notif.wait_updating": "Das Menü wird gerade aktualisiert, bitte warten Sie...", "notif.wait_updating": "Das Menü wird gerade aktualisiert, bitte warten Sie..."
"notif.unavailable": "Es scheint, dass das Menü derzeit nicht verfügbar ist"
} }
} }