分离magicocacroterline
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 6m48s

This commit is contained in:
远野千束 2024-10-13 02:56:29 +08:00
parent 3d218a0e8d
commit 9c525141f6

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
NoneBot 开发环境重载监视器
"""
import os.path
from liteyuki.dev import observer
from liteyuki import get_bot, logger
from liteyuki.utils import IS_MAIN_PROCESS
from watchdog.events import FileSystemEvent
bot = get_bot()
exclude_extensions = (".pyc", ".pyo")
@observer.on_file_system_event(
directories=("src/nonebot_plugins",),
event_filter=lambda event: not event.src_path.endswith(exclude_extensions)
and ("__pycache__" not in event.src_path)
and os.path.isfile(event.src_path),
)
def restart_nonebot_process(event: FileSystemEvent):
logger.debug(f"File {event.src_path} changed, reloading nonebot...")
bot.restart_process("nonebot")