-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76e5c70
commit 7ea573f
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from shizuchat import db | ||
|
||
usersdb = db.users | ||
|
||
|
||
async def is_served_user(user_id: int) -> bool: | ||
user = await usersdb.find_one({"user_id": user_id}) | ||
if not user: | ||
return False | ||
return True | ||
|
||
|
||
async def get_served_users() -> list: | ||
users_list = [] | ||
async for user in usersdb.find({"user_id": {"$gt": 0}}): | ||
users_list.append(user) | ||
return users_list | ||
|
||
|
||
async def add_served_user(user_id: int): | ||
is_served = await is_served_user(user_id) | ||
if is_served: | ||
return | ||
return await usersdb.insert_one({"user_id": user_id}) | ||
|