2023-02-06 13:21:53 +00:00
|
|
|
from core.builtins import Bot
|
2023-03-04 08:51:56 +00:00
|
|
|
from core.component import module
|
2022-08-27 16:17:01 +00:00
|
|
|
|
2023-03-04 08:51:56 +00:00
|
|
|
p = module('prefix', required_admin=True, base=True)
|
2022-08-27 16:17:01 +00:00
|
|
|
|
|
|
|
|
2023-03-08 11:40:16 +00:00
|
|
|
@p.command('add <prefix> {{core.prefix.help.add}}',
|
|
|
|
'remove <prefix> {{core.prefix.help.remove}}',
|
|
|
|
'reset {{{core.prefix.help.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)
|
2023-03-08 11:40:16 +00:00
|
|
|
await msg.sendMessage(msg.locale.t("core.prefix.message.add.success", prefix=arg1))
|
2022-08-27 16:17:01 +00:00
|
|
|
else:
|
2023-03-08 11:40:16 +00:00
|
|
|
await msg.sendMessage(msg.locale.t("core.prefix.message.add.already"))
|
2022-08-27 16:17:01 +00:00
|
|
|
elif 'remove' in msg.parsed_msg:
|
|
|
|
if arg1:
|
|
|
|
if arg1 in prefixes:
|
|
|
|
prefixes.remove(arg1)
|
|
|
|
msg.data.edit_option('command_prefix', prefixes)
|
2023-03-08 11:40:16 +00:00
|
|
|
await msg.sendMessage(msg.locale.t("core.prefix.message.remove.success") + arg1)
|
2022-08-27 16:17:01 +00:00
|
|
|
else:
|
2023-03-08 11:40:16 +00:00
|
|
|
await msg.sendMessage(msg.locale.t("core.prefix.message.remove.not_found"))
|
2022-08-27 16:17:01 +00:00
|
|
|
elif 'reset' in msg.parsed_msg:
|
|
|
|
msg.data.edit_option('command_prefix', [])
|
2023-03-08 11:40:16 +00:00
|
|
|
await msg.sendMessage(msg.locale.t("core.prefix.message.reset"))
|