mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-27 18:45:05 +08:00
⏪ revert command change
This commit is contained in:
parent
ef98a6f23c
commit
217b1a5fac
@ -422,15 +422,12 @@ def on_command(cmd: Union[str, Tuple[str, ...]],
|
||||
|
||||
async def _strip_cmd(bot: "Bot", event: "Event", state: T_State):
|
||||
message = event.get_message()
|
||||
text_processed = False
|
||||
for index, segment in enumerate(message):
|
||||
segment: "MessageSegment" = message.pop(index)
|
||||
if segment.is_text() and not text_processed:
|
||||
segment, *_ = message.__class__(
|
||||
str(segment)[len(state["_prefix"]["raw_command"]):].lstrip(
|
||||
)) # type: ignore
|
||||
text_processed = True
|
||||
message.insert(index, segment)
|
||||
segment = message.pop(0)
|
||||
new_message = message.__class__(
|
||||
str(segment)
|
||||
[len(state["_prefix"]["raw_command"]):].lstrip()) # type: ignore
|
||||
for new_segment in reversed(new_message):
|
||||
message.insert(0, new_segment)
|
||||
|
||||
handlers = kwargs.pop("handlers", [])
|
||||
handlers.insert(0, _strip_cmd)
|
||||
|
@ -137,9 +137,8 @@ class TrieRule:
|
||||
prefix = None
|
||||
suffix = None
|
||||
message = event.get_message()
|
||||
message_seg: Optional["MessageSegment"] = next(
|
||||
filter(lambda x: x.is_text(), message), None)
|
||||
if message_seg is not None:
|
||||
message_seg = message[0]
|
||||
if message_seg.is_text():
|
||||
prefix = cls.prefix.longest_prefix(str(message_seg).lstrip())
|
||||
message_seg_r = message[-1]
|
||||
if message_seg_r.is_text():
|
||||
|
Loading…
Reference in New Issue
Block a user