mirror of
https://github.com/marcogll/vanessa_bot_vanity.git
synced 2026-01-13 13:25:16 +00:00
This reverts the changes that introduced file-based persistence for user registration. The user has requested that the bot should not persist user registrations to allow for repeated testing of the registration flow. This commit restores the original in-memory registration behavior, where the list of registered users is cleared on every restart. This change facilitates testing by allowing the same user to go through the registration process multiple times without being remembered by the bot.
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import logging
|
|
|
|
# MOCK DATABASE MODULE
|
|
# Since the actual DB is removed temporarily, this module provides mock implementations.
|
|
|
|
SessionUsersAlma = None
|
|
SessionVanityHr = None
|
|
SessionVanityAttendance = None
|
|
|
|
_REGISTERED_USERS = set()
|
|
|
|
def chat_id_exists(chat_id: int) -> bool:
|
|
"""Mock check: returns True if user is in in-memory set."""
|
|
return int(chat_id) in _REGISTERED_USERS
|
|
|
|
def register_user(user_data: dict) -> bool:
|
|
"""Mock register: adds user to in-memory set."""
|
|
try:
|
|
meta = user_data.get("meta", {})
|
|
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
|
|
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
|