feat: 适配aiocqhttp

This commit is contained in:
RockChinQ
2024-02-07 20:03:46 +08:00
parent 84b2867148
commit aeb1912db6
9 changed files with 291 additions and 13 deletions

View File

@@ -63,19 +63,24 @@ class Application:
async def initialize(self):
pass
# async def wait_loop(self):
async def run(self):
await self.plugin_mgr.load_plugins()
await self.plugin_mgr.initialize_plugins()
tasks = []
try:
tasks = [
asyncio.create_task(self.im_mgr.run()),
asyncio.create_task(self.ctrl.run())
]
await asyncio.wait(tasks)
await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
except asyncio.CancelledError:
self.logger.info("程序退出.")
pass
except Exception as e:
self.logger.error(f"应用运行致命异常: {e}")
self.logger.debug(f"Traceback: {traceback.format_exc()}")
self.logger.info("程序退出.")

View File

@@ -44,6 +44,7 @@ async def init_logging() -> logging.Logger:
handler.setFormatter(color_formatter)
qcg_logger.addHandler(handler)
qcg_logger.debug("日志初始化完成,日志级别:%s" % level)
logging.basicConfig(
level=logging.INFO, # 设置日志输出格式
format="[DEPR][%(asctime)s.%(msecs)03d] %(pathname)s (%(lineno)d) - [%(levelname)s] :\n%(message)s",