MCPcopy
hub / github.com/nonebot/nonebot2 / append

Method append

nonebot/internal/adapter/message.py:358–372  ·  view source on GitHub ↗

添加一个消息段到消息数组末尾。 参数: obj: 要添加的消息段

(  # pyright: ignore[reportIncompatibleMethodOverride]
        self, obj: str | TMS
    )

Source from the content-addressed store, hash-verified

356 return all(seg == value for seg in self)
357
358 def append( # pyright: ignore[reportIncompatibleMethodOverride]
359 self, obj: str | TMS
360 ) -> Self:
361 """添加一个消息段到消息数组末尾。
362
363 参数:
364 obj: 要添加的消息段
365 """
366 if isinstance(obj, MessageSegment):
367 super().append(obj)
368 elif isinstance(obj, str):
369 self.extend(self._construct(obj))
370 else:
371 raise ValueError(f"Unexpected type: {type(obj)} {obj}") # pragma: no cover
372 return self
373
374 def extend( # pyright: ignore[reportIncompatibleMethodOverride]
375 self, obj: Self | Iterable[TMS]

Callers 15

__init__Method · 0.95
__iadd__Method · 0.95
extendMethod · 0.95
commandFunction · 0.80
shell_commandFunction · 0.80
commandMethod · 0.80
shell_commandMethod · 0.80
onMethod · 0.80
on_metaeventMethod · 0.80
on_messageMethod · 0.80
on_noticeMethod · 0.80
on_requestMethod · 0.80

Calls 2

extendMethod · 0.95
_constructMethod · 0.95

Tested by 14

_startup1Function · 0.64
_startup2Function · 0.64
_ready1Function · 0.64
_ready2Function · 0.64
_shutdown1Function · 0.64
_shutdown2Function · 0.64
test_http_clientFunction · 0.64
test_http_client_sessionFunction · 0.64
_validate_1Method · 0.64
_validate_2Method · 0.64
test_require_not_loadedFunction · 0.64