fix: support forwarded media with captions (text from caption, ignore media-only)
This commit is contained in:
parent
ed3c1cf0ce
commit
3333b38e6b
1 changed files with 7 additions and 3 deletions
10
app/bot.py
10
app/bot.py
|
|
@ -109,10 +109,14 @@ async def user_start(update: Update, context):
|
||||||
|
|
||||||
|
|
||||||
async def handle_user_message(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
|
global admin_chat_id
|
||||||
user = update.effective_user
|
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]}")
|
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:
|
def build_user_app() -> Application:
|
||||||
app = Application.builder().token(USER_TOKEN).build()
|
app = Application.builder().token(USER_TOKEN).build()
|
||||||
app.add_handler(CommandHandler('start', user_start))
|
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
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue