It's version 0.8.3 bug fix ТЕПЕРЬ УЖ точно восстановлена система слежения расписания
This commit is contained in:
@@ -35,14 +35,17 @@ class ScheduleService:
|
||||
else:
|
||||
target = target.replace(day=int(day_offset))
|
||||
return target.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
|
||||
def _get_next_day(self, day_offeset: int = 0) -> datetime:
|
||||
return datetime.now() + timedelta(days=day_offeset)
|
||||
|
||||
|
||||
def _next_target_date(self, day_offset: int = 0) -> datetime:
|
||||
return (datetime.now() + timedelta(days=day_offset)).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
|
||||
|
||||
|
||||
async def _load_pdf_for_date(
|
||||
self, day_offset: int = 1
|
||||
self, day_offset: int = 0
|
||||
) -> Tuple[Optional[bytes], Optional[str], int, int]:
|
||||
target = self._get_next_day(day_offset)
|
||||
target = self._resolve_target_date(day_offset)
|
||||
day, month = target.day, target.month
|
||||
|
||||
drive_file = await self.drive.find_for_date(target)
|
||||
@@ -57,6 +60,25 @@ class ScheduleService:
|
||||
url = f"https://drive.google.com/file/d/{drive_file.file_id}/view"
|
||||
return self._pdf_cache[drive_file.file_id], url, day, month
|
||||
|
||||
async def _load_pdf_for_watcher(
|
||||
self, day_offset: int = 1
|
||||
) -> Tuple[Optional[bytes], Optional[str], int, int]:
|
||||
target = self._next_target_date(day_offset)
|
||||
day, month = target.day, target.month
|
||||
|
||||
drive_file = await self.drive.find_for_date(target)
|
||||
if not drive_file:
|
||||
return None, None, day, month
|
||||
|
||||
if drive_file.file_id not in self._pdf_cache:
|
||||
self._pdf_cache[drive_file.file_id] = await self.drive.download_pdf(
|
||||
drive_file.file_id
|
||||
)
|
||||
|
||||
url = f"https://drive.google.com/file/d/{drive_file.file_id}/view"
|
||||
return self._pdf_cache[drive_file.file_id], url, day, month
|
||||
|
||||
|
||||
@staticmethod
|
||||
def exact_group_regex(group: str) -> re.Pattern:
|
||||
pattern = rf"(^|{BOUNDARY}){re.escape(group)}({BOUNDARY}|$)"
|
||||
@@ -108,7 +130,7 @@ class ScheduleService:
|
||||
return f"📅 Расписание для {day} числа:\n<pre>{body}</pre>"
|
||||
|
||||
async def is_published_for(self, day_offset: int = 0) -> bool:
|
||||
target = self._resolve_target_date(day_offset)
|
||||
target = self._next_target_date(day_offset)
|
||||
return await self.drive.find_for_date(target) is not None
|
||||
|
||||
async def get_schedule(
|
||||
|
||||
Reference in New Issue
Block a user