Skip to content

Commit

Permalink
✨ 分离magicocacroterline
Browse files Browse the repository at this point in the history
  • Loading branch information
snowykami committed Oct 12, 2024
1 parent 3d218a0 commit 9c52514
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/liteyuki_plugins/nonebot/dev_reloader.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 9c52514

Please sign in to comment.