Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/core/prefix.py

33 lines
1.4 KiB
Python
Raw Normal View History

2023-02-06 13:21:53 +00:00
from core.builtins import Bot
2022-08-27 16:17:01 +00:00
from core.component import on_command
p = on_command('prefix', required_admin=True, base=True)
@p.handle('add <prefix> {设置自定义机器人命令前缀}', 'remove <prefix> {移除自定义机器人命令前缀}',
'reset {重置自定义机器人命令前缀}')
2023-02-06 13:21:53 +00:00
async def set_prefix(msg: Bot.MessageSession):
2022-08-27 16:17:01 +00:00
prefixes = msg.options.get('command_prefix')
arg1 = msg.parsed_msg.get('<prefix>', False)
if prefixes is None:
prefixes = []
if 'add' in msg.parsed_msg:
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:
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('已重置自定义命令前缀列表。')