2023-09-02 08:58:11 +00:00
|
|
|
from core.component import module
|
|
|
|
from core.builtins import Bot
|
2023-09-02 09:28:57 +00:00
|
|
|
from .generator import get_mkey
|
2023-09-02 08:58:11 +00:00
|
|
|
|
2023-09-27 14:36:26 +00:00
|
|
|
mk = module('mkey', desc='{mkey.help.desc}', developers=['OasisAkari', 'Kurisu'])
|
2023-09-02 08:58:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
@mk.handle('<device> <month> <day> <inquiry_num> [<device_id>]')
|
2023-09-02 08:58:48 +00:00
|
|
|
async def mkey(msg: Bot.MessageSession, device: str, month: int, day: int, inquiry_num: str, device_id: str = None):
|
2023-09-02 08:58:11 +00:00
|
|
|
|
|
|
|
device_codes = {
|
|
|
|
"3ds": "CTR",
|
|
|
|
"dsi": "TWL",
|
|
|
|
"wii": "RVL",
|
|
|
|
"wiiu": "WUP",
|
|
|
|
"switch": "HAC"
|
|
|
|
}
|
|
|
|
|
|
|
|
if month < 1 or month > 12:
|
2023-09-27 08:30:27 +00:00
|
|
|
await msg.finish(msg.locale.t('mkey.message.error.date.month'))
|
2023-09-02 08:58:11 +00:00
|
|
|
if day < 1 or day > 31:
|
2023-09-27 08:30:27 +00:00
|
|
|
await msg.finish(msg.locale.t('mkey.message.error.date.day'))
|
2023-09-02 11:00:02 +00:00
|
|
|
if device.lower() not in device_codes:
|
2023-09-27 08:30:27 +00:00
|
|
|
await msg.finish(msg.locale.t('mkey.message.error.device'))
|
2023-09-02 11:00:02 +00:00
|
|
|
if len(inquiry_num) not in [6, 8, 10]:
|
2023-09-27 08:30:27 +00:00
|
|
|
await msg.finish(msg.locale.t('mkey.message.error.inquiry_num'))
|
2023-09-02 08:58:11 +00:00
|
|
|
device_code = device_codes[device.lower()]
|
2023-09-02 11:00:02 +00:00
|
|
|
if device_id is None and device_code == "HAC":
|
2023-09-27 08:30:27 +00:00
|
|
|
await msg.finish(msg.locale.t('mkey.message.error.hal'))
|
2023-09-02 08:58:11 +00:00
|
|
|
|
2023-09-02 09:28:57 +00:00
|
|
|
result = get_mkey(inquiry_num, month, day, device_id, device_code)
|
2023-09-27 08:30:27 +00:00
|
|
|
await msg.finish(msg.locale.t('mkey.message.result', result=result))
|