refactor(bot): add logging and flow tweaks
This commit is contained in:
+10
-3
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user