refactor: 恢复插件事件调用

This commit is contained in:
RockChinQ
2024-01-30 21:45:17 +08:00
parent e2de3d0102
commit 33d600fb6b
10 changed files with 298 additions and 86 deletions

View File

@@ -19,7 +19,7 @@ from ..utils import version as version_mgr, proxy as proxy_mgr
class Application:
im_mgr: im_mgr.QQBotManager = None
im_mgr: im_mgr.PlatformManager = None
cmd_mgr: cmdmgr.CommandManager = None

View File

@@ -88,10 +88,13 @@ async def make_app() -> app.Application:
# 发送公告
ann_mgr = announce.AnnouncementManager(ap)
announcements = await ann_mgr.fetch_new()
try:
announcements = await ann_mgr.fetch_new()
for ann in announcements:
ap.logger.info(f'[公告] {ann.time}: {ann.content}')
for ann in announcements:
ap.logger.info(f'[公告] {ann.time}: {ann.content}')
except Exception as e:
ap.logger.warning(f'获取公告时出错: {e}')
ap.query_pool = pool.QueryPool()
@@ -99,8 +102,13 @@ async def make_app() -> app.Application:
await ver_mgr.initialize()
ap.ver_mgr = ver_mgr
if await ap.ver_mgr.is_new_version_available():
ap.logger.info("有新版本可用,请使用 !update 命令更新")
try:
if await ap.ver_mgr.is_new_version_available():
ap.logger.info("有新版本可用,请使用 !update 命令更新")
except Exception as e:
ap.logger.warning(f"检查版本更新时出错: {e}")
plugin_mgr_inst = plugin_mgr.PluginManager(ap)
await plugin_mgr_inst.initialize()
@@ -141,7 +149,7 @@ async def make_app() -> app.Application:
await llm_tool_mgr_inst.initialize()
ap.tool_mgr = llm_tool_mgr_inst
im_mgr_inst = im_mgr.QQBotManager(ap=ap)
im_mgr_inst = im_mgr.PlatformManager(ap=ap)
await im_mgr_inst.initialize()
ap.im_mgr = im_mgr_inst

View File

@@ -6,6 +6,7 @@ import traceback
from . import app, entities
from ..pipeline import entities as pipeline_entities
from ..plugin import events
DEFAULT_QUERY_CONCURRENCY = 10