Team Ai
Apppublic

azils3/bash

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
__init__.py75 linesDownload Raw Back to _misc
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://github.com/TeamUltroid/pyUltroid/blob/main/LICENSE>.7 8 9from .. import *10 11CMD_HELP = {}12# ----------------------------------------------#13 14 15class _SudoManager:16    def __init__(self):17        self.db = None18        self.owner = None19        self._owner_sudos = []20 21    def _init_db(self):22        if not self.db:23            from .. import udB24 25            self.db = udB26        return self.db27 28    def get_sudos(self):29        db = self._init_db()30        SUDOS = db.get_key("SUDOS")31        return SUDOS or []32 33    @property34    def should_allow_sudo(self):35        db = self._init_db()36        return db.get_key("SUDO")37 38    def owner_and_sudos(self):39        if not self.owner:40            db = self._init_db()41            self.owner = db.get_key("OWNER_ID")42        return [self.owner, *self.get_sudos()]43 44    @property45    def fullsudos(self):46        db = self._init_db()47        fsudos = db.get("FULLSUDO")48        if not self.owner:49            self.owner = db.get_key("OWNER_ID")50        if not fsudos:51            return [self.owner]52        fsudos = fsudos.split()53        fsudos.append(self.owner)54        return [int(_) for _ in fsudos]55 56    def is_sudo(self, id_):57        return bool(id_ in self.get_sudos())58 59 60SUDO_M = _SudoManager()61owner_and_sudos = SUDO_M.owner_and_sudos62sudoers = SUDO_M.get_sudos63is_sudo = SUDO_M.is_sudo64 65# ------------------------------------------------ #66 67 68def append_or_update(load, func, name, arggs):69    if isinstance(load, list):70        return load.append(func)71    if isinstance(load, dict):72        if load.get(name):73            return load[name].append((func, arggs))74        return load.update({name: [(func, arggs)]})75