feat: add --disable-command option to specify a command to disable

This commit is contained in:
Pagliacii
2023-12-15 21:39:21 +08:00
parent 384cc4656f
commit 93fb98f7b5
3 changed files with 19 additions and 2 deletions

View File

@ -55,12 +55,14 @@ def wrap_handler(handler: T, bot: TeleBot) -> T:
return update_wrapper(wrapper, handler)
def load_handlers(bot: TeleBot) -> None:
def load_handlers(bot: TeleBot, disable_commands: list[str]) -> None:
# import all submodules
this_path = Path(__file__).parent
for child in this_path.iterdir():
if child.name.startswith("_"):
continue
if child.stem in disable_commands:
continue
module = importlib.import_module(f".{child.stem}", __package__)
if hasattr(module, "register"):
print(f"Loading {child.stem} handlers.")