revert command change

This commit is contained in:
yanyongyu 2021-02-07 20:57:08 +08:00
parent ef98a6f23c
commit 217b1a5fac
2 changed files with 8 additions and 12 deletions

View File

@ -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)

View File

@ -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():