fix: support forwarded media with captions (text from caption, ignore media-only)

This commit is contained in:
vrubel 2026-06-03 18:43:02 +00:00
parent ed3c1cf0ce
commit 3333b38e6b

View file

@ -109,10 +109,14 @@ async def user_start(update: Update, context):
async def handle_user_message(update: Update, context):
"""Receive text → TTS → reply voice → forward to admin."""
"""Receive text/caption → TTS → reply voice → forward to admin."""
global admin_chat_id
user = update.effective_user
text = update.message.text
text = update.message.text or update.message.caption
if not text:
# Media without caption — silently ignore
return
logger.info(f"User {user.full_name} (id={user.id}): {text[:80]}")
@ -183,7 +187,7 @@ def build_admin_app() -> Application:
def build_user_app() -> Application:
app = Application.builder().token(USER_TOKEN).build()
app.add_handler(CommandHandler('start', user_start))
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_user_message))
app.add_handler(MessageHandler((filters.TEXT | filters.CAPTION) & ~filters.COMMAND, handle_user_message))
return app