Merge branch 'dev'
Build and Push (main) / build (push) Successful in 41s

This commit is contained in:
2026-08-08 05:11:16 +05:00
3 changed files with 15 additions and 9 deletions
+5 -3
View File
@@ -51,14 +51,14 @@ class Config:
default_captcha = (
f"[CENTER][B]Напишите ответ:[/B]\n"
f"сколько будет 20 + 20? [I][COLOR=rgb(80, 80, 78)](Капча меняется раз в месяц)[/COLOR][/I][/CENTER]"
)
).strip()
try:
captcha = ""
with open(file_path, "r", encoding="utf-8") as replies:
captcha = replies.read()
return captcha if captcha else default_captcha
return captcha.strip() if captcha else default_captcha
except FileNotFoundError:
return default_captcha
@@ -133,7 +133,9 @@ class Config:
# Validate captcha configuration
if enable_captcha and not captcha_answer:
raise ConfigError("ENABLE_CAPTCHA установлен, но CAPTCHA_ANSWER не задан")
raise ConfigError(
"ENABLE_CAPTCHA установлен, но CAPTCHA_ANSWER не задан"
)
return {
# Pyrogram
+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