2024-01-27 00:06:38 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2024-01-30 21:56:25 +08:00
|
|
|
import random
|
|
|
|
import asyncio
|
|
|
|
|
2024-01-27 00:06:38 +08:00
|
|
|
import mirai
|
|
|
|
|
|
|
|
from ...core import app
|
|
|
|
|
|
|
|
from .. import stage, entities, stagemgr
|
|
|
|
from ...core import entities as core_entities
|
|
|
|
from ...config import manager as cfg_mgr
|
|
|
|
|
|
|
|
|
|
|
|
@stage.stage_class("SendResponseBackStage")
|
|
|
|
class SendResponseBackStage(stage.PipelineStage):
|
|
|
|
"""发送响应消息
|
|
|
|
"""
|
|
|
|
|
|
|
|
async def process(self, query: core_entities.Query, stage_inst_name: str) -> entities.StageProcessResult:
|
|
|
|
"""处理
|
|
|
|
"""
|
2024-01-30 21:56:25 +08:00
|
|
|
random_delay = random.uniform(*self.ap.cfg_mgr.data['force_delay_range'])
|
|
|
|
|
|
|
|
self.ap.logger.debug(
|
|
|
|
"根据规则强制延迟回复: %s s",
|
|
|
|
random_delay
|
|
|
|
)
|
|
|
|
|
|
|
|
await asyncio.sleep(random_delay)
|
2024-01-27 00:06:38 +08:00
|
|
|
|
|
|
|
await self.ap.im_mgr.send(
|
|
|
|
query.message_event,
|
|
|
|
query.resp_message_chain
|
|
|
|
)
|
|
|
|
|
|
|
|
return entities.StageProcessResult(
|
|
|
|
result_type=entities.ResultType.CONTINUE,
|
|
|
|
new_query=query
|
|
|
|
)
|