mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-07 04:26:45 +00:00
🧪 Add a fail test to reproduce #781
This commit is contained in:
@ -6,7 +6,14 @@ if TYPE_CHECKING:
|
||||
from nonebot.adapters import Event, Message
|
||||
|
||||
|
||||
def make_fake_message() -> Type["Message"]:
|
||||
def escape_text(s: str, *, escape_comma: bool = True) -> str:
|
||||
s = s.replace("&", "&").replace("[", "[").replace("]", "]")
|
||||
if escape_comma:
|
||||
s = s.replace(",", ",")
|
||||
return s
|
||||
|
||||
|
||||
def make_fake_message():
|
||||
from nonebot.adapters import Message, MessageSegment
|
||||
|
||||
class FakeMessageSegment(MessageSegment):
|
||||
@ -42,6 +49,10 @@ def make_fake_message() -> Type["Message"]:
|
||||
yield FakeMessageSegment(**seg)
|
||||
return
|
||||
|
||||
def __add__(self, other):
|
||||
other = escape_text(other) if isinstance(other, str) else other
|
||||
return super().__add__(other)
|
||||
|
||||
return FakeMessage
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user