diff options
author | Kyomotoi <[email protected]> | 2022-12-28 15:43:51 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2022-12-28 15:43:51 +0800 |
commit | f197f55e4dadbb99b5ae60584af75e05c96725b2 (patch) | |
tree | 60525eb6da7f828e7947288966e2dffc034c1e17 /ATRI/plugins | |
parent | 1b5b6f91cb61367b86d5f145cc5a865faceaecfe (diff) | |
download | ATRI-f197f55e4dadbb99b5ae60584af75e05c96725b2.tar.gz ATRI-f197f55e4dadbb99b5ae60584af75e05c96725b2.tar.bz2 ATRI-f197f55e4dadbb99b5ae60584af75e05c96725b2.zip |
🚑️ 延长资源占用提示时间及限制提醒次数
Diffstat (limited to 'ATRI/plugins')
-rw-r--r-- | ATRI/plugins/status.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ATRI/plugins/status.py b/ATRI/plugins/status.py index e7ed842..d6a5682 100644 --- a/ATRI/plugins/status.py +++ b/ATRI/plugins/status.py @@ -11,6 +11,7 @@ from ATRI.log import log from ATRI.service import Service from ATRI.message import MessageBuilder from ATRI.exceptions import GetStatusError +from ATRI.utils import Limiter from ATRI.utils.apscheduler import scheduler @@ -35,7 +36,10 @@ async def _(): await status.finish(msg) [email protected]_job("interval", name="状态检查", minutes=15, misfire_grace_time=15) +limiter = Limiter(5, 21600) + + [email protected]_job("interval", name="状态检查", minutes=30, misfire_grace_time=15) async def _(): log.info("检查资源消耗中...") msg, stat = get_status() @@ -46,8 +50,12 @@ async def _(): bot = get_bot() except Exception: bot = None - - if bot: await plugin.send_to_master(msg) + if not limiter.check("114514"): + try: + if bot: await plugin.send_to_master(msg) + limiter.increase("114514") + except Exception: + return else: log.info("资源消耗正常") |