Update bot_telegram.py
Browse files- bot_telegram.py +5 -4
bot_telegram.py
CHANGED
|
@@ -76,12 +76,12 @@ class TelegramBot:
|
|
| 76 |
user_id = update.message.from_user.id
|
| 77 |
user_message = update.message.text.strip()
|
| 78 |
|
| 79 |
-
#
|
| 80 |
if user_id in AWAITING_PASSWORD:
|
| 81 |
await self.check_password(update, context)
|
| 82 |
return
|
| 83 |
|
| 84 |
-
# If
|
| 85 |
if user_id in AUTHENTICATED_USERS:
|
| 86 |
await self.chat_with_ai(update, context)
|
| 87 |
else:
|
|
@@ -97,8 +97,9 @@ class TelegramBot:
|
|
| 97 |
return
|
| 98 |
|
| 99 |
if user_message == SECRET_PASSWORD:
|
| 100 |
-
AUTHENTICATED_USERS.add(user_id)
|
| 101 |
-
AWAITING_PASSWORD.
|
|
|
|
| 102 |
await update.message.reply_text("✅ Authentication successful! You can now use the bot.")
|
| 103 |
else:
|
| 104 |
await update.message.reply_text("❌ Wrong password. Try again.")
|
|
|
|
| 76 |
user_id = update.message.from_user.id
|
| 77 |
user_message = update.message.text.strip()
|
| 78 |
|
| 79 |
+
# If user is waiting to enter a password, validate it
|
| 80 |
if user_id in AWAITING_PASSWORD:
|
| 81 |
await self.check_password(update, context)
|
| 82 |
return
|
| 83 |
|
| 84 |
+
# If user is authenticated, process AI request
|
| 85 |
if user_id in AUTHENTICATED_USERS:
|
| 86 |
await self.chat_with_ai(update, context)
|
| 87 |
else:
|
|
|
|
| 97 |
return
|
| 98 |
|
| 99 |
if user_message == SECRET_PASSWORD:
|
| 100 |
+
AUTHENTICATED_USERS.add(user_id) # ✅ Save authentication status
|
| 101 |
+
AWAITING_PASSWORD.discard(user_id) # ✅ Remove user from the waiting list
|
| 102 |
+
logging.info(f"User {user_id} authenticated successfully.")
|
| 103 |
await update.message.reply_text("✅ Authentication successful! You can now use the bot.")
|
| 104 |
else:
|
| 105 |
await update.message.reply_text("❌ Wrong password. Try again.")
|