rename main command (#40)

* update poetry.lock

* rename main command

* Remove Ylokh && Vitalentum && GptChatly
This commit is contained in:
Dmitry Afanasyev
2023-10-16 18:38:04 +03:00
committed by GitHub
parent a273a89ba0
commit f987453b5d
8 changed files with 433 additions and 305 deletions

View File

@@ -12,7 +12,7 @@ from core.bot.services import ChatGptService, SpeechToTextService
from settings.config import settings
async def main_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> str:
async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> str:
"""Send message on `/start`."""
if not update.message:
return BotEntryPoints.end
@@ -90,19 +90,17 @@ async def ask_question(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
async def voice_recognize(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
if not update.message:
return
await update.message.reply_text("Пожалуйста, ожидайте :)\nТрехминутная запись обрабатывается примерно 30 секунд")
if not update.message.voice:
await update.message.reply_text("Голосовое сообщение не найдено")
return
await update.message.reply_text("Пожалуйста, ожидайте :)\nТрехминутная запись обрабатывается примерно 30 секунд")
sound_file = await update.message.voice.get_file()
sound_bytes = await sound_file.download_as_bytearray()
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
tmpfile.write(sound_bytes)
logger.info("file has been saved", filename=tmpfile.name)
speech_to_text_service = SpeechToTextService(filename=tmpfile.name)
speech_to_text_service.get_text_from_audio()
part = 0

View File

@@ -16,7 +16,7 @@ from core.bot.commands import (
ask_question,
github,
help_command,
main_command,
start_command,
voice_recognize,
website,
)
@@ -37,7 +37,7 @@ bot_event_handlers.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, a
bot_event_handlers.add_handler(MessageHandler(filters.VOICE | filters.AUDIO, voice_recognize))
bot_event_handlers.add_handler(
ConversationHandler(
entry_points=[CommandHandler("start", main_command)],
entry_points=[CommandHandler("start", start_command)],
states={
BotEntryPoints.start_routes: [
CallbackQueryHandler(about_me, pattern="^" + BotStagesEnum.about_me + "$"),
@@ -46,7 +46,7 @@ bot_event_handlers.add_handler(
CallbackQueryHandler(about_bot, pattern="^" + BotStagesEnum.about_bot + "$"),
],
},
fallbacks=[CommandHandler("start", main_command)],
fallbacks=[CommandHandler("start", start_command)],
)
)
bot_event_handlers.add_handler(CallbackQueryHandler(about_me, pattern="^" + BotStagesEnum.about_me + "$"))