async def send_post(title: str, text: str, link: str = "", source: str = None) -> bool:
"""
Отправляет пост в формате:
- Заголовок
- Текст (без точки в конце)
- "Подробнее..." на новой строке
- Хэштеги и @CCYPAS
"""
try:
# Убираем точку в конце текста, если она есть
text = text.strip()
if text.endswith(''):
text = text[:-1].strip()
# Собираем основную часть: заголовок + текст + "Подробнее" на новой строке
post_content = f"<b>{title}</b>\n\n{text}"
if link:
post_content += f"<a href='{link}'> Подробнее...</a>"
# Добавляем хэштеги и @CCYPAS через декоратор
try:
final_text = format_company_names(decorate_text(post_content))
except Exception as e:
logger.error(f"Text formatting error: {e}")
final_text = f"{post_content}\n\n♻️ @CCYPAS" # Fallback
# Отправка (осталось без изменений)
try:
image_data = await fetch_and_process_image(title)
if image_data:
await bot.send_photo(
chat_id=TG_CHANNEL_ID,
photo=BytesIO(image_data),
caption=final_text[:1024],
parse_mode="HTML"
)
return True
except Exception as e:
logger.error(f"Image send error: {e}")
await bot.send_message(
chat_id=TG_CHANNEL_ID,
text=final_text[:4096],
parse_mode="HTML",
disable_web_page_preview=True
)
return True
except Exception as e:
logger.error(f"Failed to send post: {e}", exc_info=True)
return False скажи как будеть выглядеть пост без второго абзаца и обычный