diff --git a/app/bot.py b/app/bot.py index 0a5dfc0..e143f47 100644 --- a/app/bot.py +++ b/app/bot.py @@ -69,7 +69,13 @@ def clean_text(text: str) -> str: text = re.sub(r'@\S+\s*', '', text) text = re.sub(r'[ \t]+', ' ', text) text = re.sub(r'\n{2,}', '\n', text) + text = re.sub(r'\n', ' ', text) text = text.strip() + + parts = re.split(r'(?<=[.!?])\s+', text) + if parts and re.search(r'макс', parts[-1], re.IGNORECASE): + text = ' '.join(p.strip() for p in parts[:-1] if p.strip()) + if text: text += '\nПип.' return text