Skip to content

Commit

Permalink
Create users.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Badhacker98 authored Oct 10, 2024
1 parent 76e5c70 commit 7ea573f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions shizuchat/database/users.py
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})

0 comments on commit 7ea573f

Please sign in to comment.