ShopBot/utils/database/base.py
2022-06-16 00:32:17 +03:00

55 lines
1.1 KiB
Python

from .model import Admin, Operator
def get_admins():
users = []
for i in Admin.select():
users.append(i.user_id)
return users
def get_operator():
users = []
for i in Operator.select():
users.append(i.user_id)
return users
def get_full_admin():
usr = []
for i in Admin.select():
usr.append({
"user_id": i.user_id,
"first_name": i.first_name,
"last_name": i.last_name,
"username": i.username
})
return usr
def get_full_operator():
usr = []
for i in Operator.select():
usr.append({
"user_id": i.user_id,
"first_name": i.first_name,
"last_name": i.last_name,
"username": i.username
})
return usr
def del_admin(user_id: int):
Admin.delete().where(Admin.user_id == user_id).execute()
def del_operator(user_id: int):
Operator.delete().where(Operator.user_id == user_id).execute()
def get_active_operator():
usr = []
for i in Operator.select().where(Operator.active==True):
usr.append(i.user_id)
return usr