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

Class FakeMessage

tests/utils.py:54–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53
54class FakeMessage(Message[FakeMessageSegment]):
55 @classmethod
56 @override
57 def get_segment_class(cls):
58 return FakeMessageSegment
59
60 @staticmethod
61 @override
62 def _construct(msg: str | Iterable[Mapping]):
63 if isinstance(msg, str):
64 yield FakeMessageSegment.text(msg)
65 else:
66 for seg in msg:
67 yield FakeMessageSegment(**seg)
68 return
69
70 @override
71 def __add__(self, other: str | FakeMessageSegment | Iterable[FakeMessageSegment]):
72 other = escape_text(other) if isinstance(other, str) else other
73 return super().__add__(other)
74
75
76def make_fake_event(

Callers 15

test_echoFunction · 0.90
test_eventFunction · 0.90
test_aliased_eventFunction · 0.90
test_stateFunction · 0.90
test_aliased_stateFunction · 0.90
test_argFunction · 0.90
test_aliased_argFunction · 0.90
test_dataclass_encoderFunction · 0.90
test_trieFunction · 0.90
test_startswithFunction · 0.90
test_endswithFunction · 0.90
test_fullmatchFunction · 0.90

Calls

no outgoing calls

Tested by 15

test_echoFunction · 0.72
test_eventFunction · 0.72
test_aliased_eventFunction · 0.72
test_stateFunction · 0.72
test_aliased_stateFunction · 0.72
test_argFunction · 0.72
test_aliased_argFunction · 0.72
test_dataclass_encoderFunction · 0.72
test_trieFunction · 0.72
test_startswithFunction · 0.72
test_endswithFunction · 0.72
test_fullmatchFunction · 0.72