Ограничил длину аудиосообщений
This commit is contained in:
@@ -9,7 +9,7 @@ from telegram import (
|
||||
from telegram.error import TelegramError
|
||||
from telegram.ext import ContextTypes
|
||||
|
||||
from src.config import ADMIN_LOGIN
|
||||
from src.config import ADMIN_LOGIN, MAX_VOICE_DURATION
|
||||
from src.database import (
|
||||
User,
|
||||
UserSession,
|
||||
@@ -49,6 +49,7 @@ from src.messages import (
|
||||
TRACK_SAVED_TEXT,
|
||||
VOICE_EXPECTED_TEXT,
|
||||
VOICE_SAVE_ERROR_TEXT,
|
||||
VOICE_TOO_LONG_TEXT,
|
||||
)
|
||||
from src.scenarios import find_available_track
|
||||
|
||||
@@ -871,6 +872,20 @@ async def handle_voice_message(
|
||||
real_replica_index = replicas[session.replica_index].replica_index
|
||||
|
||||
voice = update.message.voice
|
||||
|
||||
# Проверяем длительность
|
||||
if voice.duration > MAX_VOICE_DURATION:
|
||||
await update.message.reply_text(
|
||||
VOICE_TOO_LONG_TEXT.format(
|
||||
max_duration=MAX_VOICE_DURATION, duration=voice.duration
|
||||
)
|
||||
)
|
||||
logger.info(
|
||||
f"User {user.id} sent voice too long: {voice.duration}s "
|
||||
f"(max {MAX_VOICE_DURATION}s)"
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
await save_voice_message(
|
||||
context.bot,
|
||||
|
||||
Reference in New Issue
Block a user