hyperboria/nexus/hub/user_manager/user_manager.py
the-superpirate 43a4d0e17f - feat: Open Hub API
GitOrigin-RevId: dd347635b52b69451a50cca3163fbfbcefb8561e
2021-04-09 15:32:52 +03:00

23 lines
639 B
Python

class UserManager:
def __init__(self):
self.last_widget = {}
self.tasks = set()
self.limits = {}
def add_task(self, user_id, id):
self.tasks.add((user_id, id))
self.limits[user_id] = self.limits.get(user_id, 0) + 1
def remove_task(self, user_id, id):
try:
self.tasks.remove((user_id, id))
self.limits[user_id] = self.limits.get(user_id, 1) - 1
except ValueError:
pass
def has_task(self, user_id, id):
return (user_id, id) in self.tasks
def hit_limits(self, user_id):
return self.limits.get(user_id, 0) >= 3