Foydalanuvchi commited on
Commit
a5f0793
·
1 Parent(s): 5d01f97

Fix: 6ta tugmadagi xatolik (fayl yo'li adashishi) va timeoutlar tuzatildi

Browse files
Files changed (1) hide show
  1. main.py +13 -6
main.py CHANGED
@@ -483,8 +483,9 @@ async def button_handler(update: Update, context: ContextTypes.DEFAULT_TYPE):
483
 
484
  logger.info(f"Processing finished. Success path: {success_path}")
485
 
486
- if success_path and os.path.exists(output_path):
487
- # Save to history
 
488
  f_name = {
489
  "r": "retro", "u": "4k", "f": "face fix", "a": "auto enhance",
490
  "s": "slow motion", "bw": "oq-qora", "cc": "rang fix",
@@ -501,12 +502,18 @@ async def button_handler(update: Update, context: ContextTypes.DEFAULT_TYPE):
501
  }.get(action, f"filter_{action}")
502
  db.log_history(query.from_user.id, "photo" if m_type == "p" else "video", f_name, file_id)
503
 
504
- with open(output_path, 'rb') as f:
505
- caption = f"✅ <b>{f_name.upper()}</b> muvaffaqiyatli qo'llanildi!"
 
 
 
506
  if m_type == "p":
507
- await context.bot.send_photo(query.message.chat_id, f, caption=caption, parse_mode=constants.ParseMode.HTML, read_timeout=60, write_timeout=60)
 
 
 
508
  else:
509
- await context.bot.send_video(query.message.chat_id, f, caption=caption, parse_mode=constants.ParseMode.HTML, read_timeout=120, write_timeout=120)
510
  else:
511
  logger.error(f"Processing failed for {short_id}. Action: {action}")
512
  await context.bot.send_message(query.message.chat_id, "❌ Afsuski, ishlov berishda xatolik yuz berdi yoki natija topilmadi.")
 
483
 
484
  logger.info(f"Processing finished. Success path: {success_path}")
485
 
486
+ if success_path and os.path.exists(success_path):
487
+ # Extentsionni tiklash (rembg kabi png yaratuvchilar uchun)
488
+ final_ext = str(success_path).split('.')[-1]
489
  f_name = {
490
  "r": "retro", "u": "4k", "f": "face fix", "a": "auto enhance",
491
  "s": "slow motion", "bw": "oq-qora", "cc": "rang fix",
 
502
  }.get(action, f"filter_{action}")
503
  db.log_history(query.from_user.id, "photo" if m_type == "p" else "video", f_name, file_id)
504
 
505
+ with open(success_path, 'rb') as f:
506
+ caption = f"✅ <b>{f_name.upper()}</b> muvaffaqiyatli qo'llanildi!\n✨ @editfiltrbot orqali maxsus tayyorlandi!"
507
+ try: await query.edit_message_text("✅ Tayyor! Yuklanmoqda...")
508
+ except: pass
509
+
510
  if m_type == "p":
511
+ if final_ext in ["png", "webp"]:
512
+ await context.bot.send_document(query.message.chat_id, f, caption=caption, parse_mode=constants.ParseMode.HTML, read_timeout=300, write_timeout=300)
513
+ else:
514
+ await context.bot.send_photo(query.message.chat_id, f, caption=caption, parse_mode=constants.ParseMode.HTML, read_timeout=300, write_timeout=300)
515
  else:
516
+ await context.bot.send_video(query.message.chat_id, f, caption=caption, parse_mode=constants.ParseMode.HTML, read_timeout=300, write_timeout=300)
517
  else:
518
  logger.error(f"Processing failed for {short_id}. Action: {action}")
519
  await context.bot.send_message(query.message.chat_id, "❌ Afsuski, ishlov berishda xatolik yuz berdi yoki natija topilmadi.")