@@ -571,11 +571,6 @@ class ValueRankPlugin(MessagePluginInterface):
|
||||
self.mention_batch_size = 200
|
||||
self.mention_window_start_minutes = 20
|
||||
self.mention_window_end_minutes = 10
|
||||
# 身价排行里只有少数命令是真正的长任务:
|
||||
# 1. `社交关系图` 需要拼 HTML 再截图渲染;
|
||||
# 2. `重算身价` 会扫描整群候选成员并重写快照;
|
||||
# 3. 其他榜单/说明类命令基本是读库拼文本,不值得全部切到后台。
|
||||
self._background_commands = {"社交关系图", "重算身价"}
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件与配置。"""
|
||||
@@ -644,26 +639,6 @@ class ValueRankPlugin(MessagePluginInterface):
|
||||
command = content.split(" ")[0]
|
||||
return command in self._commands
|
||||
|
||||
def get_message_dispatch_mode(self, message: Dict[str, Any]) -> str:
|
||||
"""按命令决定是否切入后台任务池。"""
|
||||
content = str(message.get("content", "") or "").strip()
|
||||
command = content.split()[0] if content else ""
|
||||
if command in self._background_commands:
|
||||
# 这两个命令明显比普通查询重很多:
|
||||
# 1. `社交关系图` 的瓶颈主要在模板渲染与截图;
|
||||
# 2. `重算身价` 会遍历群成员并批量回写快照;
|
||||
# 3. 改成后台后,轻量榜单查询就不会再被这类维护型命令拖住。
|
||||
return self.normalize_message_dispatch_mode("background")
|
||||
return super().get_message_dispatch_mode(message)
|
||||
|
||||
def get_message_process_timeout_seconds(self, message: Dict[str, Any]) -> Optional[int]:
|
||||
"""为重渲染/重算命令单独放宽总超时。"""
|
||||
content = str(message.get("content", "") or "").strip()
|
||||
command = content.split()[0] if content else ""
|
||||
if command in self._background_commands:
|
||||
return 240
|
||||
return None
|
||||
|
||||
@plugin_stats_decorator(plugin_name="身价排行")
|
||||
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||
"""处理用户命令入口。"""
|
||||
|
||||
Reference in New Issue
Block a user