mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-13 01:06:03 +00:00
style: introduce ruff as linter and formatter (#1356)
* style: remove necessary imports * style: fix F841 * style: fix F401 * style: fix F811 * style: fix E402 * style: fix E721 * style: fix E722 * style: fix E722 * style: fix F541 * style: ruff format * style: all passed * style: add ruff in deps * style: more ignores in ruff.toml * style: add pre-commit
This commit is contained in:
committed by
GitHub
parent
09e70d70e9
commit
209f16af76
@@ -4,41 +4,38 @@ import random
|
||||
import asyncio
|
||||
|
||||
|
||||
from ...core import app
|
||||
from ...platform.types import events as platform_events
|
||||
from ...platform.types import message as platform_message
|
||||
|
||||
from .. import stage, entities
|
||||
from ...core import entities as core_entities
|
||||
from ...config import manager as cfg_mgr
|
||||
|
||||
|
||||
@stage.stage_class("SendResponseBackStage")
|
||||
@stage.stage_class('SendResponseBackStage')
|
||||
class SendResponseBackStage(stage.PipelineStage):
|
||||
"""发送响应消息
|
||||
"""
|
||||
"""发送响应消息"""
|
||||
|
||||
async def process(self, query: core_entities.Query, stage_inst_name: str) -> entities.StageProcessResult:
|
||||
"""处理
|
||||
"""
|
||||
async def process(
|
||||
self, query: core_entities.Query, stage_inst_name: str
|
||||
) -> entities.StageProcessResult:
|
||||
"""处理"""
|
||||
|
||||
random_range = (query.pipeline_config['output']['force-delay']['min'], query.pipeline_config['output']['force-delay']['max'])
|
||||
random_range = (
|
||||
query.pipeline_config['output']['force-delay']['min'],
|
||||
query.pipeline_config['output']['force-delay']['max'],
|
||||
)
|
||||
|
||||
random_delay = random.uniform(*random_range)
|
||||
|
||||
self.ap.logger.debug(
|
||||
"根据规则强制延迟回复: %s s",
|
||||
random_delay
|
||||
)
|
||||
self.ap.logger.debug('根据规则强制延迟回复: %s s', random_delay)
|
||||
|
||||
await asyncio.sleep(random_delay)
|
||||
|
||||
if query.pipeline_config['output']['misc']['at-sender'] and isinstance(query.message_event, platform_events.GroupMessage):
|
||||
if query.pipeline_config['output']['misc']['at-sender'] and isinstance(
|
||||
query.message_event, platform_events.GroupMessage
|
||||
):
|
||||
query.resp_message_chain[-1].insert(
|
||||
0,
|
||||
platform_message.At(
|
||||
query.message_event.sender.id
|
||||
)
|
||||
0, platform_message.At(query.message_event.sender.id)
|
||||
)
|
||||
|
||||
quote_origin = query.pipeline_config['output']['misc']['quote-origin']
|
||||
@@ -46,10 +43,9 @@ class SendResponseBackStage(stage.PipelineStage):
|
||||
await query.adapter.reply_message(
|
||||
message_source=query.message_event,
|
||||
message=query.resp_message_chain[-1],
|
||||
quote_origin=quote_origin
|
||||
quote_origin=quote_origin,
|
||||
)
|
||||
|
||||
return entities.StageProcessResult(
|
||||
result_type=entities.ResultType.CONTINUE,
|
||||
new_query=query
|
||||
)
|
||||
result_type=entities.ResultType.CONTINUE, new_query=query
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user