Spaces:
Paused
Paused
Update bot.py
Browse files
bot.py
CHANGED
|
@@ -64,7 +64,6 @@ def generate_fragment_card(username, status):
|
|
| 64 |
except:
|
| 65 |
font_main = font_pill = font_card_head = font_card_body = ImageFont.load_default()
|
| 66 |
|
| 67 |
-
# Header
|
| 68 |
header_text = f"{username}.t.me"
|
| 69 |
draw.text((40, 40), header_text, fill=text_white, font=font_main)
|
| 70 |
tw = draw.textlength(header_text, font=font_main)
|
|
@@ -72,13 +71,11 @@ def generate_fragment_card(username, status):
|
|
| 72 |
draw.rounded_rectangle([pill_x, 52, pill_x + 135, 92], radius=8, fill=cfg["bg"])
|
| 73 |
draw.text((pill_x + 22, 59), status.replace("_", " ").capitalize(), fill=cfg["text"], font=font_pill)
|
| 74 |
|
| 75 |
-
# Left Card
|
| 76 |
draw.rounded_rectangle([40, 150, 480, 400], radius=10, fill=card_bg)
|
| 77 |
draw.text((105, 190), "Can I buy this username?", fill=text_white, font=font_card_head)
|
| 78 |
draw.line([40, 235, 480, 235], fill=divider_color, width=1)
|
| 79 |
draw.multiline_text((260, 315), cfg["desc"], fill=text_gray, font=font_card_body, align="center", anchor="mm", spacing=8)
|
| 80 |
|
| 81 |
-
# Right Card
|
| 82 |
draw.rounded_rectangle([510, 150, 960, 400], radius=10, fill=card_bg)
|
| 83 |
rows = [("Telegram Username", f"@{username}"), ("Web Address", f"t.me/{username}"), ("TON Web 3.0", f"{username}.t.me")]
|
| 84 |
y_pos = 185
|
|
@@ -171,7 +168,6 @@ def setup_handlers(client):
|
|
| 171 |
await msg.delete()
|
| 172 |
await client.send_file(event.chat_id, file=img, caption=f"**Report:** `@{target}`")
|
| 173 |
|
| 174 |
-
# --- NEW HTML DEBUG COMMAND ---
|
| 175 |
@client.on(events.NewMessage(pattern=r'/html\s+([a-zA-Z0-9_]+)'))
|
| 176 |
async def html_cmd(event):
|
| 177 |
if not is_admin(event): return
|
|
@@ -188,17 +184,15 @@ def setup_handlers(client):
|
|
| 188 |
async with session.get(url, headers=headers, allow_redirects=True, timeout=15) as resp:
|
| 189 |
html_text = await resp.text()
|
| 190 |
status_code = resp.status
|
|
|
|
| 191 |
|
| 192 |
-
# Package the long HTML text into a clean file object
|
| 193 |
f = io.BytesIO(html_text.encode('utf-8'))
|
| 194 |
f.name = f"{target}_fragment.html"
|
| 195 |
|
|
|
|
|
|
|
| 196 |
await msg.delete()
|
| 197 |
-
await client.send_file(
|
| 198 |
-
event.chat_id,
|
| 199 |
-
file=f,
|
| 200 |
-
caption=f"π **Raw HTML Captured for** `@{target}`\n**Status Code:** `{status_code}`"
|
| 201 |
-
)
|
| 202 |
except Exception as e:
|
| 203 |
await msg.edit(f"β **Error fetching HTML:** `{str(e)}`")
|
| 204 |
|
|
@@ -243,11 +237,7 @@ def setup_handlers(client):
|
|
| 243 |
|
| 244 |
sent_code = await app.send_code(phone)
|
| 245 |
|
| 246 |
-
await conv.send_message(
|
| 247 |
-
"π₯ **Code Sent!**\n\n"
|
| 248 |
-
"β οΈ **CRITICAL:** You MUST enter the code with spaces between numbers.\n"
|
| 249 |
-
"Example: `1 2 3 4 5`"
|
| 250 |
-
)
|
| 251 |
code_msg = await conv.get_response()
|
| 252 |
otp_code = code_msg.text.replace(" ", "").strip()
|
| 253 |
|
|
@@ -260,12 +250,7 @@ def setup_handlers(client):
|
|
| 260 |
|
| 261 |
string_session = await app.export_session_string()
|
| 262 |
|
| 263 |
-
await conv.send_message(
|
| 264 |
-
f"β
**String Session Generated!**\n\n"
|
| 265 |
-
f"`{string_session}`\n\n"
|
| 266 |
-
f"β οΈ Keep this secret. Anyone with this can access your account."
|
| 267 |
-
)
|
| 268 |
-
|
| 269 |
except asyncio.TimeoutError:
|
| 270 |
await conv.send_message("β **Timeout.** You took too long. Run `/getstring` again.")
|
| 271 |
except Exception as e:
|
|
@@ -354,10 +339,8 @@ def setup_handlers(client):
|
|
| 354 |
msg = await generate_status_msg()
|
| 355 |
await event.edit(msg, buttons=[[Button.inline("π Refresh", b"refresh_status")], [Button.inline("Β« Back", b"back_main")]])
|
| 356 |
except Exception as e:
|
| 357 |
-
if "not modified" in str(e).lower() or "MessageNotModifiedError" in str(type(e)):
|
| 358 |
-
|
| 359 |
-
else:
|
| 360 |
-
print(f"Status Error: {e}")
|
| 361 |
|
| 362 |
elif data == "set_speed":
|
| 363 |
await event.edit("β‘ **Select Concurrent Workers:**", buttons=[
|
|
@@ -396,5 +379,4 @@ def setup_handlers(client):
|
|
| 396 |
|
| 397 |
elif data == "reset_do":
|
| 398 |
await db.flush_all()
|
| 399 |
-
await event.edit("π£ Memory purged successfully.", buttons=get_settings_menu())
|
| 400 |
-
|
|
|
|
| 64 |
except:
|
| 65 |
font_main = font_pill = font_card_head = font_card_body = ImageFont.load_default()
|
| 66 |
|
|
|
|
| 67 |
header_text = f"{username}.t.me"
|
| 68 |
draw.text((40, 40), header_text, fill=text_white, font=font_main)
|
| 69 |
tw = draw.textlength(header_text, font=font_main)
|
|
|
|
| 71 |
draw.rounded_rectangle([pill_x, 52, pill_x + 135, 92], radius=8, fill=cfg["bg"])
|
| 72 |
draw.text((pill_x + 22, 59), status.replace("_", " ").capitalize(), fill=cfg["text"], font=font_pill)
|
| 73 |
|
|
|
|
| 74 |
draw.rounded_rectangle([40, 150, 480, 400], radius=10, fill=card_bg)
|
| 75 |
draw.text((105, 190), "Can I buy this username?", fill=text_white, font=font_card_head)
|
| 76 |
draw.line([40, 235, 480, 235], fill=divider_color, width=1)
|
| 77 |
draw.multiline_text((260, 315), cfg["desc"], fill=text_gray, font=font_card_body, align="center", anchor="mm", spacing=8)
|
| 78 |
|
|
|
|
| 79 |
draw.rounded_rectangle([510, 150, 960, 400], radius=10, fill=card_bg)
|
| 80 |
rows = [("Telegram Username", f"@{username}"), ("Web Address", f"t.me/{username}"), ("TON Web 3.0", f"{username}.t.me")]
|
| 81 |
y_pos = 185
|
|
|
|
| 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
|
|
|
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
except Exception as e:
|
| 197 |
await msg.edit(f"β **Error fetching HTML:** `{str(e)}`")
|
| 198 |
|
|
|
|
| 237 |
|
| 238 |
sent_code = await app.send_code(phone)
|
| 239 |
|
| 240 |
+
await conv.send_message("π₯ **Code Sent!**\n\nβ οΈ **CRITICAL:** You MUST enter the code with spaces between numbers.\nExample: `1 2 3 4 5`")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
code_msg = await conv.get_response()
|
| 242 |
otp_code = code_msg.text.replace(" ", "").strip()
|
| 243 |
|
|
|
|
| 250 |
|
| 251 |
string_session = await app.export_session_string()
|
| 252 |
|
| 253 |
+
await conv.send_message(f"β
**String Session Generated!**\n\n`{string_session}`\n\nβ οΈ Keep this secret.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
except asyncio.TimeoutError:
|
| 255 |
await conv.send_message("β **Timeout.** You took too long. Run `/getstring` again.")
|
| 256 |
except Exception as e:
|
|
|
|
| 339 |
msg = await generate_status_msg()
|
| 340 |
await event.edit(msg, buttons=[[Button.inline("π Refresh", b"refresh_status")], [Button.inline("Β« Back", b"back_main")]])
|
| 341 |
except Exception as e:
|
| 342 |
+
if "not modified" in str(e).lower() or "MessageNotModifiedError" in str(type(e)): pass
|
| 343 |
+
else: print(f"Status Error: {e}")
|
|
|
|
|
|
|
| 344 |
|
| 345 |
elif data == "set_speed":
|
| 346 |
await event.edit("β‘ **Select Concurrent Workers:**", buttons=[
|
|
|
|
| 379 |
|
| 380 |
elif data == "reset_do":
|
| 381 |
await db.flush_all()
|
| 382 |
+
await event.edit("π£ Memory purged successfully.", buttons=get_settings_menu())
|
|
|