mirror of
https://github.com/marcogll/vanessa_bot_vanity.git
synced 2026-01-13 21:35:16 +00:00
feat: Disable user registration persistence
This change modifies the mock database module to make the bot completely stateless regarding user registration. - The `chat_id_exists` function now always returns `False`. - The `register_user` function is now a no-op, returning `True` without storing any data. This allows the registration flow to be run repeatedly for testing purposes, as requested by the user.
This commit is contained in:
@@ -11,21 +11,10 @@ _REGISTERED_USERS = set()
|
|||||||
|
|
||||||
def chat_id_exists(chat_id: int) -> bool:
|
def chat_id_exists(chat_id: int) -> bool:
|
||||||
"""Mock check: returns True if user is in in-memory set."""
|
"""Mock check: returns True if user is in in-memory set."""
|
||||||
return int(chat_id) in _REGISTERED_USERS
|
return False
|
||||||
|
|
||||||
def register_user(user_data: dict) -> bool:
|
def register_user(user_data: dict) -> bool:
|
||||||
"""Mock register: adds user to in-memory set."""
|
"""Mock register: adds user to in-memory set."""
|
||||||
try:
|
# This function is now a no-op to ensure statelessness.
|
||||||
meta = user_data.get("meta", {})
|
# It always returns True to not break the conversation flow.
|
||||||
metadata = user_data.get("metadata", {})
|
|
||||||
tid = meta.get("telegram_id") or metadata.get("telegram_id") or metadata.get("chat_id")
|
|
||||||
|
|
||||||
if tid:
|
|
||||||
_REGISTERED_USERS.add(int(tid))
|
|
||||||
logging.info(f"[MockDB] User {tid} registered in memory.")
|
|
||||||
return True
|
return True
|
||||||
logging.warning("[MockDB] Could not find telegram_id in user_data.")
|
|
||||||
return False
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"[MockDB] Register error: {e}")
|
|
||||||
return False
|
|
||||||
|
|||||||
Reference in New Issue
Block a user