mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-09 15:26:03 +00:00
feat: adapt more events
This commit is contained in:
@@ -4,9 +4,11 @@ import typing
|
||||
|
||||
from .. import entities
|
||||
from .. import stage
|
||||
from ...plugin import events
|
||||
|
||||
import langbot_plugin.api.entities.builtin.platform.message as platform_message
|
||||
import langbot_plugin.api.entities.builtin.pipeline.query as pipeline_query
|
||||
import langbot_plugin.api.entities.context as event_context
|
||||
import langbot_plugin.api.entities.events as events
|
||||
|
||||
|
||||
@stage.stage_class('ResponseWrapper')
|
||||
@@ -57,7 +59,7 @@ class ResponseWrapper(stage.PipelineStage):
|
||||
reply_text = str(result.get_content_platform_message_chain())
|
||||
|
||||
# ============= 触发插件事件 ===============
|
||||
event_ctx = await self.ap.plugin_mgr.emit_event(
|
||||
event_ctx = event_context.EventContext(
|
||||
event=events.NormalMessageResponded(
|
||||
launcher_type=query.launcher_type.value,
|
||||
launcher_id=query.launcher_id,
|
||||
@@ -72,6 +74,13 @@ class ResponseWrapper(stage.PipelineStage):
|
||||
query=query,
|
||||
)
|
||||
)
|
||||
|
||||
serialized_event_ctx = event_ctx.model_dump(serialize_as_any=True)
|
||||
|
||||
event_ctx_result = await self.ap.plugin_connector.handler.emit_event(serialized_event_ctx)
|
||||
|
||||
event_ctx = event_context.EventContext.parse_from_dict(event_ctx_result['event_context'])
|
||||
|
||||
if event_ctx.is_prevented_default():
|
||||
yield entities.StageProcessResult(
|
||||
result_type=entities.ResultType.INTERRUPT,
|
||||
|
||||
Reference in New Issue
Block a user