feat: remove /idea_voice, revert to text-only ideas

This commit is contained in:
admin committed 2026-10-05 15:25:22 +02:00
1 parent 7b76bef889
commit 2941cb2a24
13 files changed
+152 -124

No files matched your search

+2 -26
View File
@@ -12,9 +12,9 @@ from aiogram import Bot, Dispatcher, F, Router
from aiogram.client.session.aiohttp import AiohttpSession
from aiogram.client.telegram import TEST
from aiogram.filters import CommandStart
from aiogram.types import BufferedInputFile, Message
from aiogram.types import Message
from apinex_client import APINEX_STT_URL, POST_HISTORY_CHAR_LIMIT, POST_HISTORY_LIMIT, classify_intent, create_tone_profile, extract_posts_from_images, extract_transcript, generate_ideas, generate_posts, synthesize_idea_voice, transcribe_audio
from apinex_client import APINEX_STT_URL, POST_HISTORY_CHAR_LIMIT, POST_HISTORY_LIMIT, classify_intent, create_tone_profile, extract_posts_from_images, extract_transcript, generate_ideas, generate_posts, transcribe_audio
from help_message import HELP_RICH_HTML, rich_to_plain
from user_store import (
add_post_samples,
@@ -164,13 +164,6 @@ async def help_command(message: Message) -> None:
await message.answer(rich_to_plain(HELP_RICH_HTML))
async def _send_idea_voice(message: Message, idea: dict[str, str], user_id: int) -> None:
text = f"{idea['title']}. {idea['angle']}. Зачем: {idea['why']}"
audio = await synthesize_idea_voice(text, user_id=user_id)
await message.answer_voice(BufferedInputFile(audio, filename="idea.mp3"))
await asyncio.to_thread(save_idea, user_id, idea)
async def _send_idea(message: Message, idea: dict[str, str], user_id: int) -> None:
await message.answer(f"{idea['title']}\n\n{idea['angle']}\n\nЗачем: {idea['why']}")
await asyncio.to_thread(save_idea, user_id, idea)
@@ -404,21 +397,6 @@ async def transcribe_voice(message: Message, bot: Bot) -> None:
await report_error(message, "обработка голосового и генерация", exc)
async def idea_voice_command(message: Message) -> None:
if message.from_user is None:
await message.answer("Не удалось определить пользователя.")
return
try:
async with typing_status(message.bot, message.chat.id):
tone = await asyncio.to_thread(get_tone_of_voice, message.from_user.id)
history = await asyncio.to_thread(get_recent_post_history_text, message.from_user.id, POST_HISTORY_LIMIT, POST_HISTORY_CHAR_LIMIT)
idea_history = await asyncio.to_thread(get_idea_history, message.from_user.id, 30)
idea = await generate_ideas("предложи идею для поста", tone, history, idea_history, user_id=message.from_user.id)
await _send_idea_voice(message, idea, message.from_user.id)
except Exception as exc:
await report_error(message, "озвучка идеи", exc)
@router.message(F.text & F.text.startswith("/"))
async def handle_command_text(message: Message) -> None:
command = (message.text or "").strip().split(maxsplit=1)[0].split("@", 1)[0].casefold()
@@ -430,8 +408,6 @@ async def handle_command_text(message: Message) -> None:
await clear_command(message)
elif command == "/idea":
await _classify_and_respond(message, "предложи идею для нового поста")
elif command == "/idea_voice":
await idea_voice_command(message)
else:
await message.answer("Неизвестная команда. Используй /help.")