mirror of
https://github.com/cdryzun/tg_bot_collections.git
synced 2025-04-29 00:27:09 +08:00
fix: reuse function
Signed-off-by: Frost Ming <me@frostming.com>
This commit is contained in:
parent
ea236d47a8
commit
3f2a768ede
@ -57,15 +57,12 @@ def wrap_handler(handler: T, bot: TeleBot) -> T:
|
||||
|
||||
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("_"):
|
||||
for name in list_available_commands():
|
||||
if name in disable_commands:
|
||||
continue
|
||||
if child.stem in disable_commands:
|
||||
continue
|
||||
module = importlib.import_module(f".{child.stem}", __package__)
|
||||
module = importlib.import_module(f".{name}", __package__)
|
||||
if hasattr(module, "register"):
|
||||
print(f"Loading {child.stem} handlers.")
|
||||
print(f"Loading {name} handlers.")
|
||||
module.register(bot)
|
||||
print("Loading handlers done.")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user