Hfzune commited on
Commit
1e3455a
·
verified ·
1 Parent(s): 9238b68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -50,7 +50,8 @@ USER_DB = {}
50
  seen_users = set()
51
  MAINTENANCE_MODE = False
52
 
53
- ASK_NUMBER, ASK_MESSAGE, ASK_COUNT = range(3)
 
54
  WAITING_FOR_ADMIN_PASS = 99
55
 
56
  def default_user():
@@ -152,7 +153,6 @@ async def process_update(update: Update):
152
  msg = update.message
153
  cb_query = update.callback_query
154
 
155
- # Log incoming event to HF console
156
  if msg:
157
  print(f"👤 User {user_id} | Text: {msg.text}")
158
  elif cb_query:
@@ -196,7 +196,6 @@ async def process_update(update: Update):
196
  await bot.send_message(chat_id=user_id, text=f"👋 Welcome back, <b>{user.first_name}</b>!", parse_mode="HTML", reply_markup=get_main_menu_keyboard())
197
  return
198
 
199
- # FIX: Add /send command handler
200
  if text == "/send":
201
  if not db_user["accepted"] or not db_user["verified"]:
202
  await bot.send_message(chat_id=user_id, text="❌ You must /start and verify first.")
@@ -279,7 +278,8 @@ async def process_update(update: Update):
279
  return
280
 
281
  # --- STATE MACHINE ---
282
- if db_user.get("state"):
 
283
  state = db_user["state"]
284
  print(f"⚙️ [STATE MACHINE] User {user_id} state={state}, text={text}")
285
 
@@ -386,7 +386,6 @@ async def process_update(update: Update):
386
  return
387
  db_user["state"] = ASK_NUMBER
388
  save_db()
389
- # FIX: Send a brand new message instead of editing!
390
  await bot.send_message(chat_id=user_id, text="📱 Enter target number:")
391
 
392
  elif data == "menu_profile":
 
50
  seen_users = set()
51
  MAINTENANCE_MODE = False
52
 
53
+ # 🛠️ FIX 1: Changed from range(3) to range(1, 4) so ASK_NUMBER is 1, not 0.
54
+ ASK_NUMBER, ASK_MESSAGE, ASK_COUNT = range(1, 4)
55
  WAITING_FOR_ADMIN_PASS = 99
56
 
57
  def default_user():
 
153
  msg = update.message
154
  cb_query = update.callback_query
155
 
 
156
  if msg:
157
  print(f"👤 User {user_id} | Text: {msg.text}")
158
  elif cb_query:
 
196
  await bot.send_message(chat_id=user_id, text=f"👋 Welcome back, <b>{user.first_name}</b>!", parse_mode="HTML", reply_markup=get_main_menu_keyboard())
197
  return
198
 
 
199
  if text == "/send":
200
  if not db_user["accepted"] or not db_user["verified"]:
201
  await bot.send_message(chat_id=user_id, text="❌ You must /start and verify first.")
 
278
  return
279
 
280
  # --- STATE MACHINE ---
281
+ # 🛠️ FIX 2: Use "is not None" instead of just truthy check
282
+ if db_user.get("state") is not None:
283
  state = db_user["state"]
284
  print(f"⚙️ [STATE MACHINE] User {user_id} state={state}, text={text}")
285
 
 
386
  return
387
  db_user["state"] = ASK_NUMBER
388
  save_db()
 
389
  await bot.send_message(chat_id=user_id, text="📱 Enter target number:")
390
 
391
  elif data == "menu_profile":