Muttered3 commited on
Commit
4ebb3a3
·
verified ·
1 Parent(s): 82305f2

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +12 -3
bot.py CHANGED
@@ -168,6 +168,7 @@ def setup_handlers(client):
168
  await msg.delete()
169
  await client.send_file(event.chat_id, file=img, caption=f"**Report:** `@{target}`")
170
 
 
171
  @client.on(events.NewMessage(pattern=r'/html\s+([a-zA-Z0-9_]+)'))
172
  async def html_cmd(event):
173
  if not is_admin(event): return
@@ -181,15 +182,23 @@ def setup_handlers(client):
181
 
182
  try:
183
  async with aiohttp.ClientSession() as session:
184
- async with session.get(url, headers=headers, allow_redirects=True, timeout=15) as resp:
 
185
  html_text = await resp.text()
186
  status_code = resp.status
187
- final_url = str(resp.url)
188
 
189
  f = io.BytesIO(html_text.encode('utf-8'))
190
  f.name = f"{target}_fragment.html"
191
 
192
- caption = f"📄 **Raw Response for** `@{target}`\n**Status Code:** `{status_code}`\n**Final URL:** `{final_url}`\n\n*(If the final URL doesn't contain /username/, Fragment dropped you on the homepage!)*"
 
 
 
 
 
 
 
193
 
194
  await msg.delete()
195
  await client.send_file(event.chat_id, file=f, caption=caption)
 
168
  await msg.delete()
169
  await client.send_file(event.chat_id, file=img, caption=f"**Report:** `@{target}`")
170
 
171
+ # --- HTML DEBUG COMMAND (With Redirect Tracking) ---
172
  @client.on(events.NewMessage(pattern=r'/html\s+([a-zA-Z0-9_]+)'))
173
  async def html_cmd(event):
174
  if not is_admin(event): return
 
182
 
183
  try:
184
  async with aiohttp.ClientSession() as session:
185
+ # CRITICAL FIX: allow_redirects=False captures the bounce
186
+ async with session.get(url, headers=headers, allow_redirects=False, timeout=15) as resp:
187
  html_text = await resp.text()
188
  status_code = resp.status
189
+ location = resp.headers.get("Location", "None")
190
 
191
  f = io.BytesIO(html_text.encode('utf-8'))
192
  f.name = f"{target}_fragment.html"
193
 
194
+ caption = (
195
+ f"📄 **Raw Response for** `@{target}`\n"
196
+ f"**Requested URL:** `{url}`\n"
197
+ f"**Status Code:** `{status_code}`\n"
198
+ )
199
+
200
+ if status_code in [301, 302, 303, 307]:
201
+ caption += f"\n**🚨 FRAGMENT REDIRECTED TO:** `{location}`\n\n*(This proves Fragment kicked the bot off the username page!)*"
202
 
203
  await msg.delete()
204
  await client.send_file(event.chat_id, file=f, caption=caption)