From 3333b38e6b7c77961189a45b45810279979b4097 Mon Sep 17 00:00:00 2001 From: vrubel Date: Wed, 3 Jun 2026 18:43:02 +0000 Subject: [PATCH] fix: support forwarded media with captions (text from caption, ignore media-only) --- app/bot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/bot.py b/app/bot.py index 4ebbe9d..58f87b8 100644 --- a/app/bot.py +++ b/app/bot.py @@ -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