Added libs
This commit is contained in:
26
noSys/users.py
Normal file
26
noSys/users.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from .events import Events
|
||||
|
||||
class User:
|
||||
"""Represents a single user in the system."""
|
||||
|
||||
def __init__(self, public_key, networks=[]):
|
||||
self.id = public_key
|
||||
self.public_key = public_key
|
||||
self.networks = networks
|
||||
|
||||
|
||||
class UserManager:
|
||||
"""Handles user creation, storage, and retrieval."""
|
||||
|
||||
def __init__(self, nosys_core):
|
||||
from .noSysCore import NoSysCore
|
||||
self.nosys_core: NoSysCore = nosys_core
|
||||
self.users: dict[str, User] = {}
|
||||
|
||||
def add_user(self, user: User):
|
||||
if user.public_key not in self.users:
|
||||
self.users[user.public_key] = user
|
||||
self.nosys_core.fire_event(Events.USER_ADDED, user_id = user.id)
|
||||
|
||||
def get_user(self, user_id: str):
|
||||
return self.users.get(user_id)
|
||||
Reference in New Issue
Block a user