MCPcopy
hub / github.com/AstrBotDevs/AstrBot / MessageEventResult

Class MessageEventResult

astrbot/core/message/message_event_result.py:224–284  ·  view source on GitHub ↗

MessageEventResult 描述了一整条消息中带有的所有组件以及事件处理的结果。 现代消息平台的一条富文本消息中可能由多个组件构成,如文本、图片、At 等,并且保留了顺序。 Attributes: `chain` (list): 用于顺序存储各个组件。 `use_t2i_` (bool): 用于标记是否使用文本转图片服务。默认为 None,即跟随用户的设置。当设置为 True 时,将会使用文本转图片服务。 `result_type` (EventResultType): 事件处理的结果类型。

Source from the content-addressed store, hash-verified

222
223@dataclass
224class MessageEventResult(MessageChain):
225 """MessageEventResult 描述了一整条消息中带有的所有组件以及事件处理的结果。
226 现代消息平台的一条富文本消息中可能由多个组件构成,如文本、图片、At 等,并且保留了顺序。
227
228 Attributes:
229 `chain` (list): 用于顺序存储各个组件。
230 `use_t2i_` (bool): 用于标记是否使用文本转图片服务。默认为 None,即跟随用户的设置。当设置为 True 时,将会使用文本转图片服务。
231 `result_type` (EventResultType): 事件处理的结果类型。
232
233 """
234
235 result_type: EventResultType | None = field(
236 default_factory=lambda: EventResultType.CONTINUE,
237 )
238
239 result_content_type: ResultContentType | None = field(
240 default_factory=lambda: ResultContentType.GENERAL_RESULT,
241 )
242
243 async_stream: AsyncGenerator | None = None
244 """异步流"""
245
246 def stop_event(self) -> "MessageEventResult":
247 """终止事件传播。"""
248 self.result_type = EventResultType.STOP
249 return self
250
251 def continue_event(self) -> "MessageEventResult":
252 """继续事件传播。"""
253 self.result_type = EventResultType.CONTINUE
254 return self
255
256 def is_stopped(self) -> bool:
257 """是否终止事件传播。"""
258 return self.result_type == EventResultType.STOP
259
260 def set_async_stream(self, stream: AsyncGenerator) -> "MessageEventResult":
261 """设置异步流。"""
262 self.async_stream = stream
263 return self
264
265 def set_result_content_type(self, typ: ResultContentType) -> "MessageEventResult":
266 """设置事件处理的结果类型。
267
268 Args:
269 result_type (EventResultType): 事件处理的结果类型。
270
271 """
272 self.result_content_type = typ
273 return self
274
275 def is_llm_result(self) -> bool:
276 """是否为 LLM 结果。"""
277 return self.result_content_type == ResultContentType.LLM_RESULT
278
279 def is_model_result(self) -> bool:
280 """Whether result comes from model execution (including runner errors)."""
281 return self.result_content_type in (

Callers 15

run_agentFunction · 0.90
set_resultMethod · 0.90
stop_eventMethod · 0.90
continue_eventMethod · 0.90
make_resultMethod · 0.90
plain_resultMethod · 0.90
image_resultMethod · 0.90
chain_resultMethod · 0.90
processMethod · 0.90
processMethod · 0.90
processMethod · 0.90
processMethod · 0.90

Calls

no outgoing calls