Add ad support to stars_bot.py with probability-based insertion
Build and Push (dev) / build (push) Successful in 33s

This commit is contained in:
2026-09-03 16:11:25 +00:00
parent 6d6a2e5534
commit 9c2cc5794e
+9
View File
@@ -288,6 +288,15 @@ class TelegramStarsBot:
replies = self.config._load_replies() replies = self.config._load_replies()
for reply_options in replies: for reply_options in replies:
reply_message = random.choice(reply_options) reply_message = random.choice(reply_options)
# Add ad with probability if ads are enabled
if self.config.enable_ads and random.random() < self.config.ads_probability:
ad_content = self.config._load_ads()
if ad_content:
# Add ad as a separate line/paragraph
reply_message = f"{reply_message}\n\n{ad_content}"
logger.info(f"Добавлена реклама к комментарию поста {post_id}")
await self.lolz_api.create_comment(post_id, reply_message) await self.lolz_api.create_comment(post_id, reply_message)
await asyncio.sleep(self.config.api_delay) await asyncio.sleep(self.config.api_delay)