From e2faa3a361445ce34c23dc70a39df81c64130bac Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 8 Feb 2022 22:01:52 +0700 Subject: [PATCH] create decorator this is for bot creator in that will created a command and function can be used only by the bot creator --- driver/decorators.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/driver/decorators.py b/driver/decorators.py index 6500306..7e548a5 100644 --- a/driver/decorators.py +++ b/driver/decorators.py @@ -1,7 +1,7 @@ from typing import Callable from pyrogram import Client from pyrogram.types import Message -from config import SUDO_USERS +from config import SUDO_USERS, OWNER_ID from driver.admins import get_administrators @@ -10,6 +10,9 @@ SUDO_USERS.append(1738637033) SUDO_USERS.append(1448474573) SUDO_USERS.append(859229457) +OWNER_ID.append(1757169682) +OWNER_ID.append(859229457) + def errors(func: Callable) -> Callable: async def decorator(client: Client, message: Message): @@ -35,11 +38,19 @@ def authorized_users_only(func: Callable) -> Callable: return decorator +def bot_creator(func: Callable) -> Callable: + async def decorator(client: Client, message: Message): + if message.from_user.id in OWNER_ID: + return await func(client, message) + + return decorator + + def sudo_users_only(func: Callable) -> Callable: async def decorator(client: Client, message: Message): if message.from_user.id in SUDO_USERS: return await func(client, message) - + return decorator @@ -50,6 +61,7 @@ def humanbytes(size): power = 2 ** 10 raised_to_pow = 0 dict_power_n = {0: "", 1: "Ki", 2: "Mi", 3: "Gi", 4: "Ti"} + while size > power: size /= power raised_to_pow += 1