refactor: streamline captcha and thread access
Build and Push (dev) / build (push) Successful in 1m29s

This commit is contained in:
2026-08-08 04:03:32 +05:00
parent 0cc2440736
commit 7e85a1af4c
3 changed files with 15 additions and 9 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ class Lolz:
logger.debug(f"Редактирую данные темы {thread_id}...")
try:
if post_body:
thread = await self.client.threads.get(thread_id=thread_id)
thread = await self.get_thread(thread_id=thread_id)
# Чтобы отредактировать соддержимое темы - надо отредактировать первый пост
post = thread.get("first_post", {})
+9 -5
View File
@@ -162,23 +162,27 @@ class TelegramStarsBot:
return False
try:
thread = await self.lolz_api.get_thread(thread_id=self.config.thread_id)
thread_text = thread.get("post_body", "")
thread = await self.lolz_api.get_thread(
thread_id=self.config.lolz_thread_id
)
thread_text = thread["first_post"].get("post_body", "")
# Check if captcha already exists in thread
if "[spoiler=Капча" in thread_text:
logger.info(f"Капча уже существует в теме {self.config.thread_id}, пропускаю добавление.")
logger.info(
f"Капча уже существует в теме {self.config.lolz_thread_id}, пропускаю добавление."
)
return True
captcha_wrapper = f"\n\n[spoiler=Капча (обязательно);align=center][CENTER]{captcha_text}[/CENTER][/spoiler]"
thread_text += captcha_wrapper
await self.lolz_api.edit_thread(
thread_id=self.config.thread_id, post_body=thread_text
thread_id=self.config.lolz_thread_id, post_body=thread_text
)
logger.info(
f"Тема {self.config.thread_id} отредактирована. Текст с капчей добавлен"
f"Тема {self.config.lolz_thread_id} отредактирована. Текст с капчей добавлен"
)
return True