mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-07 04:26:45 +00:00
添加了查询 B 站动漫的命令,修复一些细节的 bug
This commit is contained in:
25
command.py
25
command.py
@ -302,7 +302,30 @@ def split_arguments(maxsplit=0):
|
||||
elif isinstance(argument, (list, tuple)):
|
||||
argv = list(argument)
|
||||
else:
|
||||
argv = list(filter(lambda arg: arg, re.split('|'.join(_command_args_seps), argument, maxsplit)))
|
||||
regexp = re.compile('|'.join(_command_args_seps))
|
||||
if maxsplit == 0:
|
||||
argv = list(filter(lambda arg: arg, regexp.split(argument)))
|
||||
else:
|
||||
cur = 0
|
||||
tmp_argument = argument
|
||||
argv = []
|
||||
while cur <= maxsplit:
|
||||
sl = regexp.split(tmp_argument, 1)
|
||||
if len(sl) == 1:
|
||||
if sl[0]:
|
||||
argv.append(sl[0])
|
||||
break
|
||||
# Here len(sl) is > 1 (== 2)
|
||||
if not sl[0]:
|
||||
tmp_argument = sl[1]
|
||||
continue
|
||||
if cur < maxsplit:
|
||||
argv.append(sl[0])
|
||||
tmp_argument = sl[1]
|
||||
else:
|
||||
# Last time
|
||||
argv.append(tmp_argument)
|
||||
cur += 1
|
||||
return func(argument, argv=argv, *args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
Reference in New Issue
Block a user