Murtaza ΨΉΩ„ΫŒ commited on
Commit
7f76fc5
Β·
1 Parent(s): ab7723a

feat(01-02): force snipe pre-flight mtproto verification and overwrite ui integration

Browse files
Files changed (2) hide show
  1. bot/checker.py +1 -0
  2. bot/handlers.py +53 -4
bot/checker.py CHANGED
@@ -1163,6 +1163,7 @@ async def try_claim_account(username: str, acc, force: bool = False, quiet: bool
1163
  if prev_uname and prev_uname != uname:
1164
  state.get("claimed_meta", {}).pop(prev_uname, None)
1165
  state.get("claimed_by_us", {}).pop(prev_uname, None)
 
1166
  record_history(prev_uname, "OVERWRITTEN", f"Overwritten by @{uname} on Account #{acc.index} Profile via Force Snipe", source=f"Account #{acc.index}")
1167
  log(f"πŸ”„ Account #{acc.index} previous handle @{prev_uname} retired and replaced by @{uname}.")
1168
 
 
1163
  if prev_uname and prev_uname != uname:
1164
  state.get("claimed_meta", {}).pop(prev_uname, None)
1165
  state.get("claimed_by_us", {}).pop(prev_uname, None)
1166
+ state.setdefault("claimed_meta", {}).setdefault(uname, {})["overwrote"] = prev_uname
1167
  record_history(prev_uname, "OVERWRITTEN", f"Overwritten by @{uname} on Account #{acc.index} Profile via Force Snipe", source=f"Account #{acc.index}")
1168
  log(f"πŸ”„ Account #{acc.index} previous handle @{prev_uname} retired and replaced by @{uname}.")
1169
 
bot/handlers.py CHANGED
@@ -80,13 +80,37 @@ async def execute_force_snipe(message_obj, target: str, is_edit: bool = False):
80
  status_msg = await message_obj.reply_text(header_txt, reply_markup=abort_markup, parse_mode=enums.ParseMode.HTML)
81
 
82
  import time as _time
83
- from bot.checker import trigger_burst, build_rich_claim_card, verify_truly_occupied
84
  from bot.scheduler import stop_all_for_target, camper_loop, ACTIVE_CAMPER_TASKS
85
  from bot.scraper import scraper
86
  scraper.cache.pop(target, None)
87
  state.setdefault("target_start_ts", {})[target] = _time.time()
88
  state.setdefault("target_req_counts", {})[target] = 0
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  try:
91
  burst_result = await asyncio.wait_for(trigger_burst(target, force=True, quiet=True), timeout=15.0)
92
  except asyncio.TimeoutError:
@@ -96,7 +120,6 @@ async def execute_force_snipe(message_obj, target: str, is_edit: bool = False):
96
 
97
  # If UpdateUsername returned OCCUPIED during delayed release, verify if anyone actually owns @target on Telegram!
98
  if burst_result == "OCCUPIED":
99
- first_acc = available_accounts[0] if available_accounts else None
100
  if not await verify_truly_occupied(first_acc, target):
101
  log(f"⏳ Force Snipe detected @{target} is in Telegram Delayed Release (unowned despite OCCUPIED). Switching to LIMBO Camper!")
102
  burst_result = "LIMBO"
@@ -104,8 +127,34 @@ async def execute_force_snipe(message_obj, target: str, is_edit: bool = False):
104
  claimed_via = state.get("claimed_by_us", {}).get(target)
105
  if burst_result == "CLAIMED" or claimed_via:
106
  via_str = claimed_via or "Fleet Account"
107
- await stop_all_for_target(target, f"SECURED via {via_str}", mark_unavailable=True, is_success=True, source="Force Snipe")
108
- out_txt, card_markup = build_rich_claim_card(target, status_label=f"SECURED via {via_str}", is_success=True, source="Force Snipe")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  await status_msg.edit_text(out_txt, reply_markup=card_markup, parse_mode=enums.ParseMode.HTML)
110
  elif burst_result == "LIMBO":
111
  state["watchdog_queue"].add(target)
 
80
  status_msg = await message_obj.reply_text(header_txt, reply_markup=abort_markup, parse_mode=enums.ParseMode.HTML)
81
 
82
  import time as _time
83
+ from bot.checker import trigger_burst, build_rich_claim_card, verify_truly_occupied, check_username_raw_account
84
  from bot.scheduler import stop_all_for_target, camper_loop, ACTIVE_CAMPER_TASKS
85
  from bot.scraper import scraper
86
  scraper.cache.pop(target, None)
87
  state.setdefault("target_start_ts", {})[target] = _time.time()
88
  state.setdefault("target_req_counts", {})[target] = 0
89
 
90
+ first_acc = available_accounts[0] if available_accounts else None
91
+
92
+ # 1. MTProto Account-Level Pre-Flight Check (D-04)
93
+ if first_acc:
94
+ try:
95
+ is_available = await check_username_raw_account(first_acc, target)
96
+ if not is_available:
97
+ log(f"πŸ›‘ Force Snipe MTProto pre-flight check: @{target} is occupied on Telegram.")
98
+ out_txt = (
99
+ f"{header_txt}\n\n"
100
+ f"<blockquote>πŸ›‘ <b>Status:</b> TARGET OCCUPIED (MTProto Pre-Flight: Already owned on Telegram)\n"
101
+ f"πŸ’‘ <b>Tip:</b> You can Force Camp it one-by-one or add it to Watchdog/Fragment.</blockquote>"
102
+ )
103
+ markup = InlineKeyboardMarkup([
104
+ [InlineKeyboardButton("πŸ•οΈ Force Gatling Camp (One-by-One)", callback_data=f"force_camp|{target}", style=enums.ButtonStyle.DANGER)],
105
+ [InlineKeyboardButton("πŸ• Add to Watchdog", callback_data=f"smart|w|{target}", style=enums.ButtonStyle.SUCCESS),
106
+ InlineKeyboardButton("🌐 Add to Fragment", callback_data=f"smart|f|{target}", style=enums.ButtonStyle.PRIMARY)],
107
+ [InlineKeyboardButton("⚑ Force Snipe Another", callback_data="force_snipe_prompt", style=enums.ButtonStyle.SUCCESS),
108
+ InlineKeyboardButton("⬅️ Back to Panel", callback_data="main_panel", style=enums.ButtonStyle.PRIMARY)]
109
+ ])
110
+ return await status_msg.edit_text(out_txt, reply_markup=markup, parse_mode=enums.ParseMode.HTML)
111
+ except Exception as precheck_err:
112
+ log(f"⚠️ Pre-flight MTProto check error on @{target}: {precheck_err}")
113
+
114
  try:
115
  burst_result = await asyncio.wait_for(trigger_burst(target, force=True, quiet=True), timeout=15.0)
116
  except asyncio.TimeoutError:
 
120
 
121
  # If UpdateUsername returned OCCUPIED during delayed release, verify if anyone actually owns @target on Telegram!
122
  if burst_result == "OCCUPIED":
 
123
  if not await verify_truly_occupied(first_acc, target):
124
  log(f"⏳ Force Snipe detected @{target} is in Telegram Delayed Release (unowned despite OCCUPIED). Switching to LIMBO Camper!")
125
  burst_result = "LIMBO"
 
127
  claimed_via = state.get("claimed_by_us", {}).get(target)
128
  if burst_result == "CLAIMED" or claimed_via:
129
  via_str = claimed_via or "Fleet Account"
130
+ meta = state.get("claimed_meta", {}).get(target, {})
131
+ acc_idx = meta.get("acc_index")
132
+
133
+ # Overwrite feedback integration per D-05
134
+ overwrote_handle = meta.get("overwrote")
135
+ if not overwrote_handle:
136
+ for ev in reversed(list(state.get("event_history", []))):
137
+ if ev.get("type") == "OVERWRITTEN" and f"Overwritten by @{target}" in ev.get("details", ""):
138
+ overwrote_handle = ev.get("username")
139
+ break
140
+
141
+ acc_label = f"Account #{acc_idx}" if acc_idx is not None else via_str
142
+ if overwrote_handle:
143
+ status_label = f"SECURED via {acc_label} (Overwrote previous handle)"
144
+ else:
145
+ status_label = f"SECURED via {via_str}"
146
+
147
+ await stop_all_for_target(target, status_label, mark_unavailable=True, is_success=True, source="Force Snipe")
148
+ out_txt, card_markup = build_rich_claim_card(target, status_label=status_label, is_success=True, source="Force Snipe")
149
+
150
+ if overwrote_handle:
151
+ overwrite_notice = (
152
+ f"\n\n⚑ <b>SECURED VIA FORCE SNIPE!</b>\n"
153
+ f"Target: <code>@{target}</code>\n"
154
+ f"Account: <b>{acc_label} (Overwrote previous handle @{overwrote_handle})</b>"
155
+ )
156
+ out_txt += overwrite_notice
157
+
158
  await status_msg.edit_text(out_txt, reply_markup=card_markup, parse_mode=enums.ParseMode.HTML)
159
  elif burst_result == "LIMBO":
160
  state["watchdog_queue"].add(target)