Gemini添加更多注释
This commit is contained in:
18
main.py
18
main.py
@@ -1,5 +1,7 @@
|
||||
"""
|
||||
NEO Bot 主程序入口
|
||||
|
||||
负责启动 WebSocket 连接,初始化插件系统,并提供热重载功能。
|
||||
"""
|
||||
import asyncio
|
||||
import os
|
||||
@@ -15,14 +17,24 @@ from core import WS
|
||||
class PluginReloadHandler(FileSystemEventHandler):
|
||||
"""
|
||||
文件变更处理器,用于热重载插件
|
||||
|
||||
继承自 watchdog.events.FileSystemEventHandler,
|
||||
监听 base_plugins 目录下的文件变化,并触发插件重载。
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
初始化处理器
|
||||
|
||||
设置冷却时间,防止短时间内多次触发重载。
|
||||
"""
|
||||
self.last_reload_time = 0
|
||||
self.cooldown = 1.0 # 冷却时间,防止短时间内多次重载
|
||||
|
||||
def on_any_event(self, event):
|
||||
"""
|
||||
处理所有文件事件
|
||||
|
||||
:param event: watchdog 事件对象
|
||||
"""
|
||||
if event.is_directory:
|
||||
return
|
||||
@@ -55,7 +67,11 @@ class PluginReloadHandler(FileSystemEventHandler):
|
||||
|
||||
async def main():
|
||||
"""
|
||||
主函数,启动 WebSocket 连接
|
||||
主函数
|
||||
|
||||
1. 启动文件监控(热重载)
|
||||
2. 初始化 WebSocket 客户端
|
||||
3. 建立连接并保持运行
|
||||
"""
|
||||
# 启动文件监控
|
||||
# 监控 base_plugins 目录
|
||||
|
||||
Reference in New Issue
Block a user