refactor(bot): add logging and flow tweaks

This commit is contained in:
2026-07-29 19:00:48 +05:00
parent 78ac1cb030
commit bdb096688b
3 changed files with 53 additions and 13 deletions
+10 -3
View File
@@ -17,8 +17,14 @@ class Lolz:
raise
async def get_post(self, post_id: Union[str, int]) -> Dict[str, Any]:
logger.debug(f"Запрашиваю данные поста {post_id}...")
response = await self.client.posts.get(post_id=post_id)
return (response.json()).get("post", {})
post = (response.json()).get("post", {})
if post == {}:
logger.warning(f"Пост {post_id} не найден или вернул пустой ответ.")
return post
async def get_thread_posts(
self, thread_id: Union[str, int], start_page: int = 1
@@ -41,7 +47,7 @@ class Lolz:
all_posts.extend(posts)
last_page = page
logger.info(
logger.debug(
f"Получено {len(posts)} постов из темы {thread_id} на странице {page}."
)
@@ -62,9 +68,10 @@ class Lolz:
return posts
async def get_post_comments(self, post_id: int) -> List[Dict[str, Any]]:
logger.debug(f"Запрашиваю комментарии к посту {post_id}...")
response = await self.client.posts.comments.list(post_id=post_id)
comments = (response.json()).get("comments", [])
logger.debug(f"Найдено {len(comments)} комментариев к посту {post_id}.")
return comments
async def has_comments(