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 USERBOT_LOAD or USERBOT_NOLOAD: to_load = USERBOT_LOAD if to_load: if not all(any(mod == module_name for module_name in all_modules) for mod in to_load): log.error("Invalid Module name for userbot!") quit(1) else: to_load = all_modules if USERBOT_NOLOAD: log.info("Userbot No load: {}".format(USERBOT_NOLOAD)) return [item for item in to_load if item not in USERBOT_NOLOAD] return to_load return all_modules
async def update_checker(): try: repo = Repo() except NoSuchPathError as error: log.warning(f"Check update failed!\nDirectory {error} is not found!") return except InvalidGitRepositoryError as error: log.warning( "Check update failed!\nDirectory {} Not a git repository".format( error)) return except GitCommandError as error: log.warning(f"Check update failed!\n{error}") return brname = "main" if brname not in OFFICIAL_BRANCH: return try: repo.create_remote("upstream", REPOSITORY) except BaseException: pass upstream = repo.remote("upstream") upstream.fetch("main") changelog = await gen_chlog(repo, f"HEAD..upstream/{brname}") if not changelog: log.info(f"Titan is up-to-date with branch {brname}") return log.warning(f"New UPDATE available for [{brname}]!") text = tld("updater_available_text").format(brname) text += f"**CHANGELOG:**\n`{changelog}`" button = InlineKeyboardMarkup([[ InlineKeyboardButton(("update_now_btn"), callback_data="update_now") ]]) await setbot.send_message(Owner, text, reply_markup=button, parse_mode="markdown")
and not f.endswith('__init__.py')] if USERBOT_LOAD or USERBOT_NOLOAD: to_load = USERBOT_LOAD if to_load: if not all(any(mod == module_name for module_name in all_modules) for mod in to_load): log.error("Invalid Module name for userbot!") quit(1) else: to_load = all_modules if USERBOT_NOLOAD: log.info("Userbot No load: {}".format(USERBOT_NOLOAD)) return [item for item in to_load if item not in USERBOT_NOLOAD] return to_load return all_modules def get_all_plugins() -> List[str]: """ list all plugins """ plugins = get_import_path(ROOT, "/" if len(sys.argv) == 2 and sys.argv[1] == 'dev' else "/**/") _LOG.debug("All Available Plugins: %s", plugins) return list(plugins) __all__ = ['ROOT', 'get_all_plugins'] ALL_MODULES = sorted(__list_all_modules()) log.info("Userbot module loaded: %s", str(ALL_MODULES)) __all__ = ALL_MODULES + ["ALL_MODULES"]
from naruto import ASSISTANT_LOAD, ASSISTANT_NOLOAD, log 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') ] to_load = all_modules return all_modules ALL_SETTINGS = sorted(__list_all_modules()) log.info("Assistant bot module loaded: %s", str(ALL_SETTINGS)) __all__ = ALL_SETTINGS + ["ALL_SETTINGS"]