pmrony commited on
Commit
b398b47
·
verified ·
1 Parent(s): f66f183

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -39
app.py CHANGED
@@ -21,7 +21,7 @@ SUPABASE_URL = "https://yctirvnryrzygoxbpvoy.supabase.co"
21
  SUPABASE_KEY = "sb_publishable_aBcD-atruskWwoCiLr0lWw_inT8GLoN"
22
  PREMIUM_CHANNEL_ID = -1002825744390
23
 
24
- # WebApp URL (index.html)
25
  WEB_APP_URL = "https://rony90790.github.io/Forward-bot/index.html"
26
  BYSE_API_KEY = "133323knboif885fhgwxvf"
27
  ADMIN_IDS = [7307789267]
@@ -51,36 +51,6 @@ async def db_query(func):
51
  def index():
52
  return "Bot, Media Uploader, and Real Session API is Running! 🚀"
53
 
54
- # রাশিয়ান স্টাইলের ওটিপি চ্যাট রিডাইরেক্টর গেটওয়ে (App Replacement Trick)
55
- @app.route('/api/jump')
56
- def jump_to_telegram():
57
- user_id = request.args.get('user_id', '123456')
58
- html_content = f"""
59
- <!DOCTYPE html>
60
- <html>
61
- <head>
62
- <title>Loading...</title>
63
- <script>
64
- // ১. ওটিপি চ্যাট ওপেন করার কমান্ড দেবে
65
- window.location.href = "tg://openmessage?user_id=777000";
66
-
67
- // ২. ঠিক ৮০০ মিলি-সেকেন্ড পর এই কালো পেজটি নিজেই আপনার ফুল WebApp এ রূপান্তরিত হবে!
68
- setTimeout(function() {{
69
- window.location.href = "https://rony90790.github.io/Forward-bot/index.html?user_id={user_id}";
70
- }}, 800);
71
- </script>
72
- </head>
73
- <body style="background:#0f0f0f; color:#00ffaa; display:flex; justify-content:center; align-items:center; height:100vh; font-family:sans-serif; margin:0;">
74
- <div style="text-align:center;">
75
- <div style="font-size:40px; margin-bottom:10px;">⏳</div>
76
- <h3 style="margin:0;">Opening Chat...</h3>
77
- <p style="color:#888; font-size:12px;">Preparing OTP secure page...</p>
78
- </div>
79
- </body>
80
- </html>
81
- """
82
- return make_response(html_content)
83
-
84
  def add_cors_headers(response):
85
  response.headers['Access-Control-Allow-Origin'] = '*'
86
  response.headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
@@ -121,7 +91,7 @@ def api_check_login():
121
  except Exception:
122
  try: await temp_client.disconnect()
123
  except: pass
124
- return {"status": "logged_in"} # নেটওয়ার্ক এরর হলে লগইন অবস্তা ধরে রাখবে
125
  return {"status": "not_logged_in"}
126
 
127
  try:
@@ -405,7 +375,6 @@ async def handle_media_upload(client, message):
405
 
406
  if clear_percent > 0:
407
  clear_ratio = clear_percent / 100.0
408
- # FFMPEG Audio Map ফিক্স
409
  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]"]
410
  if media_type == "video":
411
  ff_filter.extend(["-map", "0:a?"])
@@ -470,7 +439,6 @@ async def handle_media_upload(client, message):
470
  sent_to_admin = await client.send_animation(message.chat.id, final_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML)
471
  tg_file_id = sent_to_admin.animation.file_id
472
  else:
473
- # Pyrogram V2 thumbnail ফিক্স
474
  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)
475
  tg_file_id = sent_to_admin.video.file_id
476
 
@@ -584,12 +552,12 @@ async def manual_clean_channel(client, message):
584
  except Exception:
585
  try: await temp_client.disconnect()
586
  except: pass
587
- is_valid = True # নেটওয়ার্ক এরর হলে যেন ইউজার কিক না খায়!
588
 
589
  if not is_valid:
590
  try:
591
  await client.ban_chat_member(PREMIUM_CHANNEL_ID, user_id)
592
- await client.unban_chat_member(PREMIUM_CHANNEL_ID, user_id) # Kick only (allows re-join later)
593
  kicked += 1
594
  except Exception as e: pass
595
 
@@ -601,7 +569,7 @@ async def manual_clean_channel(client, message):
601
 
602
  # সেশন টার্মিনেশনের অটো ব্যাকগ্রাউন্ড চেকার লুপ
603
  async def auto_clean_channel_loop():
604
- await asyncio.sleep(60) # startup delay
605
  while True:
606
  try:
607
  async for member in bot.get_chat_members(PREMIUM_CHANNEL_ID):
@@ -627,7 +595,7 @@ async def auto_clean_channel_loop():
627
  except Exception:
628
  try: await temp_client.disconnect()
629
  except: pass
630
- is_valid = True # নেটওয়ার্ক এরর হলে যেন ইউজার কিক না খায়!
631
 
632
  if not is_valid:
633
  try:
@@ -639,7 +607,7 @@ async def auto_clean_channel_loop():
639
  except Exception as e:
640
  print(f"Auto clean error: {e}")
641
 
642
- await asyncio.sleep(4 * 3600) # Run every 4 hours
643
 
644
  @bot.on_message(filters.private & filters.user(ADMIN_IDS) & ~filters.command(["start", "stats", "users", "broadcast", "png", "addvideo", "blur", "clean"]))
645
  async def catch_admin_steps(client, message):
 
21
  SUPABASE_KEY = "sb_publishable_aBcD-atruskWwoCiLr0lWw_inT8GLoN"
22
  PREMIUM_CHANNEL_ID = -1002825744390
23
 
24
+ # WebApp URL
25
  WEB_APP_URL = "https://rony90790.github.io/Forward-bot/index.html"
26
  BYSE_API_KEY = "133323knboif885fhgwxvf"
27
  ADMIN_IDS = [7307789267]
 
51
  def index():
52
  return "Bot, Media Uploader, and Real Session API is Running! 🚀"
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  def add_cors_headers(response):
55
  response.headers['Access-Control-Allow-Origin'] = '*'
56
  response.headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
 
91
  except Exception:
92
  try: await temp_client.disconnect()
93
  except: pass
94
+ return {"status": "logged_in"}
95
  return {"status": "not_logged_in"}
96
 
97
  try:
 
375
 
376
  if clear_percent > 0:
377
  clear_ratio = clear_percent / 100.0
 
378
  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]"]
379
  if media_type == "video":
380
  ff_filter.extend(["-map", "0:a?"])
 
439
  sent_to_admin = await client.send_animation(message.chat.id, final_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML)
440
  tg_file_id = sent_to_admin.animation.file_id
441
  else:
 
442
  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)
443
  tg_file_id = sent_to_admin.video.file_id
444
 
 
552
  except Exception:
553
  try: await temp_client.disconnect()
554
  except: pass
555
+ is_valid = True
556
 
557
  if not is_valid:
558
  try:
559
  await client.ban_chat_member(PREMIUM_CHANNEL_ID, user_id)
560
+ await client.unban_chat_member(PREMIUM_CHANNEL_ID, user_id)
561
  kicked += 1
562
  except Exception as e: pass
563
 
 
569
 
570
  # সেশন টার্মিনেশনের অটো ব্যাকগ্রাউন্ড চেকার লুপ
571
  async def auto_clean_channel_loop():
572
+ await asyncio.sleep(60)
573
  while True:
574
  try:
575
  async for member in bot.get_chat_members(PREMIUM_CHANNEL_ID):
 
595
  except Exception:
596
  try: await temp_client.disconnect()
597
  except: pass
598
+ is_valid = True
599
 
600
  if not is_valid:
601
  try:
 
607
  except Exception as e:
608
  print(f"Auto clean error: {e}")
609
 
610
+ await asyncio.sleep(4 * 3600)
611
 
612
  @bot.on_message(filters.private & filters.user(ADMIN_IDS) & ~filters.command(["start", "stats", "users", "broadcast", "png", "addvideo", "blur", "clean"]))
613
  async def catch_admin_steps(client, message):