18 lines
734 B
Python
18 lines
734 B
Python
from modules.app import app
|
|
from datetime import datetime
|
|
from modules.utils import configGet
|
|
from modules.database import col_users
|
|
from pyrogram.types.user_and_chats import User
|
|
|
|
def subLimit(user: User) -> None:
|
|
if col_users.find_one_and_update({"user": user.id}, {"$set": {"cooldown": datetime.now()}}) is None:
|
|
col_users.insert_one({"user": user.id, "cooldown": datetime.now()})
|
|
|
|
def subLimited(user: User) -> bool:
|
|
if user.id in app.admins:
|
|
return False
|
|
else:
|
|
db_record = col_users.find_one({"user": user.id})
|
|
if db_record is None:
|
|
return False
|
|
return True if (datetime.now() - db_record["cooldown"]).total_seconds() < configGet("timeout", "submission") else False |