feat: 公告和更新检查

This commit is contained in:
RockChinQ
2024-01-30 16:13:33 +08:00
parent 437971ded8
commit e9e458c877
6 changed files with 130 additions and 81 deletions

View File

@@ -10,7 +10,7 @@ from ..provider.requester import modelmgr as llm_model_mgr
from ..provider.sysprompt import sysprompt as llm_prompt_mgr
from ..provider.tools import toolmgr as llm_tool_mgr
from ..config import manager as config_mgr
# from ..utils.center import v2 as center_mgr
from ..audit.center import v2 as center_mgr
from ..command import cmdmgr
from ..plugin import manager as plugin_mgr
from . import pool, controller
@@ -35,7 +35,7 @@ class Application:
tips_mgr: config_mgr.ConfigManager = None
# ctr_mgr: center_mgr.V2CenterAPI = None
ctr_mgr: center_mgr.V2CenterAPI = None
plugin_mgr: plugin_mgr.PluginManager = None
@@ -61,13 +61,11 @@ class Application:
await self.plugin_mgr.load_plugins()
await self.plugin_mgr.initialize_plugins()
tasks = [
asyncio.create_task(self.im_mgr.run()),
asyncio.create_task(self.ctrl.run())
]
try:
tasks = [
asyncio.create_task(self.im_mgr.run()),
asyncio.create_task(self.ctrl.run())
]
await asyncio.wait(tasks)
except asyncio.CancelledError:

View File

@@ -21,7 +21,7 @@ from ..platform import manager as im_mgr
from ..command import cmdmgr
from ..plugin import manager as plugin_mgr
from ..audit.center import v2 as center_v2
from ..utils import version, proxy
from ..utils import version, proxy, announce
use_override = False
@@ -82,16 +82,26 @@ async def make_app() -> app.Application:
ap.cfg_mgr = cfg_mgr
ap.tips_mgr = tips_mgr
ap.query_pool = pool.QueryPool()
proxy_mgr = proxy.ProxyManager(ap)
await proxy_mgr.initialize()
ap.proxy_mgr = proxy_mgr
# 发送公告
ann_mgr = announce.AnnouncementManager(ap)
announcements = await ann_mgr.fetch_new()
for ann in announcements:
ap.logger.info(f'[公告] {ann.time}: {ann.content}')
ap.query_pool = pool.QueryPool()
ver_mgr = version.VersionManager(ap)
await ver_mgr.initialize()
ap.ver_mgr = ver_mgr
if await ap.ver_mgr.is_new_version_available():
ap.logger.info("有新版本可用,请使用 !update 命令更新")
plugin_mgr_inst = plugin_mgr.PluginManager(ap)
await plugin_mgr_inst.initialize()
ap.plugin_mgr = plugin_mgr_inst
@@ -109,7 +119,7 @@ async def make_app() -> app.Application:
"msg_source": cfg['msg_source_adapter'],
}
)
# ap.ctr_mgr = center_v2_api
ap.ctr_mgr = center_v2_api
cmd_mgr_inst = cmdmgr.CommandManager(ap)
await cmd_mgr_inst.initialize()