✨ feat(limit, message): 引入声明式限流系统并增强消息格式化功能 (#1978)

- 新增 Cooldown、RateLimit、ConcurrencyLimit 三种限流依赖
- MessageUtils 支持动态格式化字符串 (format_args 参数)
- 插件CD限制消息显示精确剩余时间

- 重构限流逻辑至 utils/limiters.py,新增时间工具模块
- 整合时间工具函数并优化时区处理
- 新增 limiter_hook 自动释放资源,CooldownError 优化异常处理

- 冷却提示从固定文本改为动态显示剩余时间
- 示例:总结功能冷却中,请等待 1分30秒 后再试~

Co-authored-by: webjoin111 <455457521@qq.com>
Co-authored-by: HibiKier <45528451+HibiKier@users.noreply.github.com>
This commit is contained in:
Rumio
2025-07-15 17:13:33 +08:00
committed by GitHub
co-authored by webjoin111 HibiKier
parent d218c569d4
commit b993450a23
9 changed files with 463 additions and 107 deletions
+14
View File
@@ -1,3 +1,17 @@
from nonebot.exception import IgnoredException
class CooldownError(IgnoredException):
"""
冷却异常,用于在冷却时中断事件处理。
继承自 IgnoredException,不会在控制台留下错误堆栈。
"""
def __init__(self, message: str):
self.message = message
super().__init__(message)
class HookPriorityException(BaseException):
"""
钩子优先级异常