feat: 添加启动信息阶段

This commit is contained in:
RockChinQ
2024-07-03 17:34:23 +08:00
parent 79804b6ecd
commit 61e2af4a14
9 changed files with 105 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import json
import typing
import os
import base64
import logging
import pydantic
import requests
@@ -107,17 +108,20 @@ class AnnouncementManager:
async def show_announcements(
self
):
) -> typing.Tuple[str, int]:
"""显示公告"""
try:
announcements = await self.fetch_new()
ann_text = ""
for ann in announcements:
self.ap.logger.info(f'[公告] {ann.time}: {ann.content}')
ann_text += f"[公告] {ann.time}: {ann.content}\n"
if announcements:
await self.ap.ctr_mgr.main.post_announcement_showed(
ids=[item.id for item in announcements]
)
return ann_text, logging.INFO
except Exception as e:
self.ap.logger.warning(f'获取公告时出错: {e}')
return f'获取公告时出错: {e}', logging.WARNING

View File

@@ -1,6 +1,8 @@
from __future__ import annotations
import os
import typing
import logging
import time
import requests
@@ -213,11 +215,11 @@ class VersionManager:
async def show_version_update(
self
):
) -> typing.Tuple[str, int]:
try:
if await self.ap.ver_mgr.is_new_version_available():
self.ap.logger.info("有新版本可用,请使用 !update 命令更新")
return "有新版本可用,请使用管理员账号发送 !update 命令更新", logging.INFO
except Exception as e:
self.ap.logger.warning(f"检查版本更新时出错: {e}")
return f"检查版本更新时出错: {e}", logging.WARNING