Archived
1
0
Fork 0

Update __init__.py

This commit is contained in:
yzhh 2022-08-27 15:49:10 +08:00
parent 8f339767ba
commit dae1afca42

View file

@ -376,23 +376,25 @@ p = on_command('prefix', required_admin=True, base=True)
'reset {重置自定义机器人命令前缀}')
async def set_prefix(msg: MessageSession):
prefixes = msg.options.get('command_prefix')
arg1 = msg.parsed_msg['<prefix>']
arg1 = msg.parsed_msg.get('<prefix>', False)
if prefixes is None:
prefixes = []
if 'add' in msg.parsed_msg:
if arg1 not in prefixes:
prefixes.append(arg1)
msg.data.edit_option('command_prefix', prefixes)
await msg.sendMessage(f'已添加自定义命令前缀:{arg1}\n帮助文档将默认使用该前缀进行展示。')
else:
await msg.sendMessage(f'此命令前缀已存在于自定义前缀列表。')
if arg1:
if arg1 not in prefixes:
prefixes.append(arg1)
msg.data.edit_option('command_prefix', prefixes)
await msg.sendMessage(f'已添加自定义命令前缀:{arg1}\n帮助文档将默认使用该前缀进行展示。')
else:
await msg.sendMessage(f'此命令前缀已存在于自定义前缀列表。')
elif 'remove' in msg.parsed_msg:
if arg1 in prefixes:
prefixes.remove(arg1)
msg.data.edit_option('command_prefix', prefixes)
await msg.sendMessage(f'已移除自定义命令前缀:{arg1}')
else:
await msg.sendMessage(f'此命令前缀不存在于自定义前缀列表。')
if arg1:
if arg1 in prefixes:
prefixes.remove(arg1)
msg.data.edit_option('command_prefix', prefixes)
await msg.sendMessage(f'已移除自定义命令前缀:{arg1}')
else:
await msg.sendMessage(f'此命令前缀不存在于自定义前缀列表。')
elif 'reset' in msg.parsed_msg:
msg.data.edit_option('command_prefix', [])
await msg.sendMessage('已重置自定义命令前缀列表。')
@ -405,8 +407,8 @@ ali = on_command('alias', required_admin=True, base=True)
'reset {重置自定义命令别名}')
async def set_alias(msg: MessageSession):
alias = msg.options.get('command_alias')
arg1 = msg.parsed_msg['<alias>']
arg2 = msg.parsed_msg['<command>']
arg1 = msg.parsed_msg.get('<alias>', False)
arg2 = msg.parsed_msg.get('<command>', False)
if alias is None:
alias = {}
if 'add' in msg.parsed_msg:
@ -431,7 +433,7 @@ async def set_alias(msg: MessageSession):
await msg.sendMessage(f'已移除自定义命令别名:{arg1}')
else:
await msg.sendMessage(f'[{arg1}]别名不存在于自定义别名列表。')
elif msg.parsed_msg['reset']:
elif 'reset' in msg.parsed_msg:
msg.data.edit_option('command_alias', {})
await msg.sendMessage('已重置自定义命令别名列表。')