mirror of
https://github.com/cdryzun/tg_bot_collections.git
synced 2025-06-24 05:12:22 +08:00
@ -57,15 +57,12 @@ def wrap_handler(handler: T, bot: TeleBot) -> T:
|
|||||||
|
|
||||||
def load_handlers(bot: TeleBot, disable_commands: list[str]) -> None:
|
def load_handlers(bot: TeleBot, disable_commands: list[str]) -> None:
|
||||||
# import all submodules
|
# import all submodules
|
||||||
this_path = Path(__file__).parent
|
for name in list_available_commands():
|
||||||
for child in this_path.iterdir():
|
if name in disable_commands:
|
||||||
if child.name.startswith("_"):
|
|
||||||
continue
|
continue
|
||||||
if child.stem in disable_commands:
|
module = importlib.import_module(f".{name}", __package__)
|
||||||
continue
|
|
||||||
module = importlib.import_module(f".{child.stem}", __package__)
|
|
||||||
if hasattr(module, "register"):
|
if hasattr(module, "register"):
|
||||||
print(f"Loading {child.stem} handlers.")
|
print(f"Loading {name} handlers.")
|
||||||
module.register(bot)
|
module.register(bot)
|
||||||
print("Loading handlers done.")
|
print("Loading handlers done.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user