Skip to content

Commit 62069bf

Browse files
committed
fix: restore upstream fixes lost during pipeline refactoring
- Integrate active_event_registry register/unregister into new PipelineExecutor to restore #5225 (terminate active events on reset/new/del) - Add missing component validators (Json, Share, Music, Forward, Location, Contact, Shake, Dice, RPS, Unknown) to SendService to restore #5208 (JSON-only message empty reply error) - Invoke OnPluginErrorEvent hook in CommandDispatcher error path to restore #5192 (plugin error hook for custom error routing) - Pass text=comp.text when creating TTS Record to restore #5204 (voice_messages_forbidden fallback caption on Telegram)
1 parent e09f1eb commit 62069bf

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

astrbot/builtin_stars/tts/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ async def process(self, event: AstrMessageEvent) -> NodeResult:
9191
Record(
9292
file=url or audio_path,
9393
url=url or audio_path,
94+
text=comp.text,
9495
)
9596
)
9697

astrbot/core/pipeline/engine/executor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from astrbot.core import logger
88
from astrbot.core.message.components import At, AtAll, Reply
99
from astrbot.core.pipeline.agent import AgentExecutor
10+
from astrbot.core.utils.active_event_registry import active_event_registry
1011
from astrbot.core.pipeline.engine.chain_executor import ChainExecutor
1112
from astrbot.core.pipeline.system.access_control import AccessController
1213
from astrbot.core.pipeline.system.command_dispatcher import CommandDispatcher
@@ -78,6 +79,7 @@ async def initialize(self) -> None:
7879

7980
async def execute(self, event: AstrMessageEvent) -> None:
8081
"""执行 Pipeline"""
82+
active_event_registry.register(event)
8183
try:
8284
# 预处理
8385
should_continue = await self.preprocessor.preprocess(event)
@@ -185,6 +187,7 @@ async def execute(self, event: AstrMessageEvent) -> None:
185187
logger.error(f"Pipeline execution error: {e}")
186188
logger.error(traceback.format_exc())
187189
finally:
190+
active_event_registry.unregister(event)
188191
await self._handle_special_platforms(event)
189192
logger.debug("Pipeline 执行完毕。")
190193

astrbot/core/pipeline/engine/send_service.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ class SendService:
5252
Comp.Nodes: lambda comp: bool(comp.nodes),
5353
Comp.File: lambda comp: bool(comp.file_ or comp.url),
5454
Comp.WechatEmoji: lambda comp: comp.md5 is not None,
55+
Comp.Json: lambda comp: bool(comp.data),
56+
Comp.Share: lambda comp: bool(comp.url),
57+
Comp.Music: lambda comp: bool(comp.url or comp.audio or comp.id),
58+
Comp.Forward: lambda comp: bool(comp.id),
59+
Comp.Location: lambda comp: comp.lat is not None and comp.lon is not None,
60+
Comp.Contact: lambda comp: comp.id is not None and comp.id != 0,
61+
Comp.Shake: lambda _: True,
62+
Comp.Dice: lambda _: True,
63+
Comp.RPS: lambda _: True,
64+
Comp.Unknown: lambda comp: bool(comp.text),
5565
}
5666

5767
def __init__(self, ctx: PipelineContext):

astrbot/core/pipeline/system/command_dispatcher.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from astrbot.core import logger
77
from astrbot.core.message.message_event_result import MessageChain, MessageEventResult
8+
from astrbot.core.pipeline.context_utils import call_event_hook
89
from astrbot.core.pipeline.system.star_yield import StarHandlerAdapter, StarYieldDriver
910
from astrbot.core.star.star import star_map
1011
from astrbot.core.star.star_handler import (
@@ -118,7 +119,18 @@ async def execute(
118119
)
119120

120121
if result.error:
121-
# handler 执行出错
122+
# handler 执行出错,触发插件错误钩子
123+
traceback_text = result.error
124+
await call_event_hook(
125+
event,
126+
EventType.OnPluginErrorEvent,
127+
plugin_meta.name,
128+
handler.handler_name,
129+
result.error,
130+
traceback_text,
131+
)
132+
if event.is_stopped():
133+
return True
122134
if event.is_at_or_wake_command:
123135
error_msg = (
124136
f":(\n\n调用插件 {plugin_meta.name} 的 "

0 commit comments

Comments
 (0)