Skip to content

Commit

Permalink
🐛 fix version 0.31.4
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Nov 4, 2023
1 parent 8e84559 commit 3534434
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/nonebot_plugin_alconna/uniseg/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ async def send(
if reply_to:
if isinstance(reply_to, bool):
if isinstance(target, Event):
reply_to = target.get_user_id()
reply_to = self.get_message_id(target, bot)
else:
raise TypeError("reply_to must be str when target is not Event")
self.insert(0, Reply(reply_to)) # type: ignore
Expand All @@ -577,7 +577,7 @@ async def send(
_target = fn.get_target(target)
try:
res = await fn.send_to(_target, bot, msg)
except NotImplementedError:
except (AssertionError, NotImplementedError):
res = await bot.send(target, msg)
else:
res = await fn.send_to(target, bot, msg)
Expand Down
11 changes: 8 additions & 3 deletions tests/test_uniseg.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@ async def handle(_bot: Bot, _event: Event, msg: MsgId):
async with app.test_matcher(matcher) as ctx:
adapter = get_adapter(Adapter)
bot = ctx.create_bot(base=Bot, adapter=adapter)
event = fake_group_message_event_v11(message=Message("test_unimsg_send"), user_id=123)
event = fake_group_message_event_v11(message=Message("test_unimsg_send"), user_id=123, group_id=456)
ctx.receive_event(bot, event)
ctx.should_call_send(
event, MessageSegment.reply(1) + MessageSegment.at(123) + MessageSegment.text("hello!")
ctx.should_call_api(
"send_msg",
{
"message_type": "group",
"group_id": 456,
"message": MessageSegment.reply(1) + MessageSegment.at(123) + MessageSegment.text("hello!"),
},
)
ctx.should_call_api("delete_msg", {"message_id": 2})

0 comments on commit 3534434

Please sign in to comment.