fix 重启系统发送消息

This commit is contained in:
thsrite 2023-10-14 20:49:03 +08:00
parent 0539ddab85
commit 493b7c2d24
2 changed files with 11 additions and 2 deletions

View File

@ -2,12 +2,14 @@ from typing import Union
from app.chain import ChainBase from app.chain import ChainBase
from app.schemas import Notification, MessageChannel from app.schemas import Notification, MessageChannel
from app.utils.system import SystemUtils
class SystemChain(ChainBase): class SystemChain(ChainBase):
""" """
系统级处理链 系统级处理链
""" """
def remote_clear_cache(self, channel: MessageChannel, userid: Union[int, str]): def remote_clear_cache(self, channel: MessageChannel, userid: Union[int, str]):
""" """
清理系统缓存 清理系统缓存
@ -15,3 +17,11 @@ class SystemChain(ChainBase):
self.clear_cache() self.clear_cache()
self.post_message(Notification(channel=channel, self.post_message(Notification(channel=channel,
title=f"缓存清理完成!", userid=userid)) title=f"缓存清理完成!", userid=userid))
def restart(self, channel: MessageChannel, userid: Union[int, str]):
"""
重启系统
"""
self.post_message(Notification(channel=channel,
title=f"系统正在重启,请耐心等候!", userid=userid))
SystemUtils.restart()

View File

@ -19,7 +19,6 @@ from app.schemas import Notification
from app.schemas.types import EventType, MessageChannel from app.schemas.types import EventType, MessageChannel
from app.utils.object import ObjectUtils from app.utils.object import ObjectUtils
from app.utils.singleton import Singleton from app.utils.singleton import Singleton
from app.utils.system import SystemUtils
class CommandChian(ChainBase): class CommandChian(ChainBase):
@ -139,7 +138,7 @@ class Command(metaclass=Singleton):
"data": {} "data": {}
}, },
"/restart": { "/restart": {
"func": SystemUtils.restart, "func": SystemChain(self._db).restart,
"description": "重启系统", "description": "重启系统",
"category": "管理", "category": "管理",
"data": {} "data": {}