This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
TelegramPoster/modules/submissions.py

18 lines
734 B
Python
Raw Normal View History

2023-02-17 22:54:52 +02:00
from modules.app import app
from datetime import datetime
2023-02-15 15:06:06 +02:00
from modules.utils import configGet
2023-02-17 22:54:52 +02:00
from modules.database import col_users
2023-02-15 15:06:06 +02:00
from pyrogram.types.user_and_chats import User
2023-01-10 13:52:44 +02:00
2023-02-15 15:06:06 +02:00
def subLimit(user: User) -> None:
2023-02-17 22:54:52 +02:00
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()})
2023-01-10 13:52:44 +02:00
2023-02-15 15:06:06 +02:00
def subLimited(user: User) -> bool:
2023-02-17 22:54:52 +02:00
if user.id in app.admins:
2023-01-10 13:52:44 +02:00
return False
else:
2023-02-15 15:06:06 +02:00
db_record = col_users.find_one({"user": user.id})
if db_record is None:
2023-01-10 13:52:44 +02:00
return False
2023-02-17 22:54:52 +02:00
return True if (datetime.now() - db_record["cooldown"]).total_seconds() < configGet("timeout", "submission") else False