34 lines
No EOL
967 B
Python
34 lines
No EOL
967 B
Python
try:
|
|
from .classUwuCounter import UwuCounter
|
|
from .databaseMethods import create_user, get_users, get_count
|
|
except:
|
|
from classUwuCounter import UwuCounter
|
|
from databaseMethods import create_user, get_users, get_count
|
|
from flask import Flask, Response
|
|
from flask_login import LoginManager, UserMixin, login_required
|
|
|
|
|
|
class User(UserMixin):
|
|
# proxy for a database of users
|
|
loaded_users={}
|
|
|
|
def __init__(self, username, password='', initialCount=0):
|
|
self.id = username
|
|
self.count = UwuCounter(initialCount)
|
|
if(password):
|
|
create_user(0, username, password, 0)
|
|
|
|
@classmethod
|
|
def load_user(cls, user):
|
|
cls.loaded_users[user.id] = user
|
|
|
|
@classmethod
|
|
def restore_users(cls):
|
|
user_list = get_users()
|
|
for user in user_list:
|
|
cls.load_user(User(user, initialCount=get_count(user)))
|
|
|
|
|
|
@classmethod
|
|
def get(cls, id):
|
|
return cls.loaded_users.get(id) |