예제 #1
0
def __list_all_modules():
    from os.path import dirname, basename, isfile
    import glob
    # This generates a list of modules in this folder for the * in __main__ to work.
    mod_paths = glob.glob(dirname(__file__) + "/*.py")
    all_modules = [
        basename(f)[:-3] for f in mod_paths
        if isfile(f) and f.endswith(".py") and not f.endswith('__init__.py')
    ]

    if LOAD or NO_LOAD:
        to_load = LOAD
        if to_load:
            if not all(
                    any(mod == module_name for module_name in all_modules)
                    for mod in to_load):
                LOGGER.error("Invalid load order names. Quitting.")
                quit(1)

        else:
            to_load = all_modules

        if NO_LOAD:
            LOGGER.info("Not loading: {}".format(NO_LOAD))
            return [item for item in to_load if item not in NO_LOAD]

        return to_load

    return all_modules
예제 #2
0
async def getAllBannedUsers():
    users = []
    try:
        async for user in bannedUserDb.find({}):
            LOGGER.info(f"Adding {user.userId} in banned.")
            users.append(user.userId)
    except Exception as e:
        LOGGER.error(e)
    return users
예제 #3
0
async def isUserMember(userId):
    LOGGER.info(f"Checking if {userId} is in our kholi!")
    try:
        member = await bot.get_chat_member(config.get("base_chat"),userId)
        if member.status == "left" or member.status == "kicked":
            return False
    except Exception as e:
        LOGGER.error(e)
        return False
    return True
예제 #4
0
async def removeBanUser(userId):
    LOGGER.info(f"UnBanning User: {userId}")
    try:
        result = await bannedUserDb.delete_one({"userId": userId})
        LOGGER.info(result)
    except Exception as e:
        LOGGER.error(e)
        return False
    BANNED_USERS.remove(userId)
    return True
예제 #5
0
async def addBanUser(userId):
    LOGGER.info(f"Banning User: {userId}")
    try:
        result = await bannedUserDb.insert_one({"userId": userId})
        LOGGER.info(result)
    except Exception as e:
        LOGGER.error(e)
        return False
    BANNED_USERS.append(userId)
    return True
예제 #6
0
async def isUserInDb(userId):
    LOGGER.info(f"Checking {userId} in db")
    try:
        result = await accessUserDb.find_one({"userId": userId})
        LOGGER.info(result)
        if result is None:
            return False
    except Exception as e:
        LOGGER.error(e)
        return False
    return True
예제 #7
0
async def addAccessUser(userId, email):
    LOGGER.info(f"Adding {userId} : {email}")
    try:
        result = await accessUserDb.insert_one({
            "userId": userId,
            "email": email
        })
        LOGGER.info(result)
    except Exception as e:
        LOGGER.error(e)
        return False
    return True