From d3a69268b5f3d60aa22461281b85e373dd4a0b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Thu, 28 Dec 2023 20:24:58 +0800 Subject: [PATCH 01/38] fix if b23.tv not video --- modules/bilibili/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/bilibili/__init__.py b/modules/bilibili/__init__.py index 212718e5..f1ae658b 100644 --- a/modules/bilibili/__init__.py +++ b/modules/bilibili/__init__.py @@ -65,6 +65,8 @@ async def _(msg: Bot.MessageSession): url = f"{api_url}?aid={video[2:]}" else: url = await parse_shorturl(f"https://b23.tv/{video}") + if not url: + await msg.finish(msg.locale.t("bilibili.message.error.invalid")) await get_info(msg, url, get_detail=False) @@ -75,5 +77,8 @@ async def parse_shorturl(shorturl): target_url = response.headers.get('Location') video = re.search(r'/video/([^/?]+)', target_url) - url = f"{api_url}?bvid={video.group(1)}" - return url + if video: + url = f"{api_url}?bvid={video.group(1)}" + return url + else: + return False From aa6459fff6f9d9cffec2e5540c4db4572165c035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Thu, 28 Dec 2023 20:26:11 +0800 Subject: [PATCH 02/38] Update __init__.py --- modules/bilibili/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bilibili/__init__.py b/modules/bilibili/__init__.py index f1ae658b..df8c94e5 100644 --- a/modules/bilibili/__init__.py +++ b/modules/bilibili/__init__.py @@ -66,7 +66,7 @@ async def _(msg: Bot.MessageSession): else: url = await parse_shorturl(f"https://b23.tv/{video}") if not url: - await msg.finish(msg.locale.t("bilibili.message.error.invalid")) + return await get_info(msg, url, get_detail=False) From ad9cd48edbe9d28dbcc67cf7c23f7a1654951de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 12:18:11 +0800 Subject: [PATCH 03/38] Add alias --- modules/chemical_code/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/chemical_code/__init__.py b/modules/chemical_code/__init__.py index 5d7f4a43..6c689d39 100644 --- a/modules/chemical_code/__init__.py +++ b/modules/chemical_code/__init__.py @@ -89,6 +89,7 @@ async def search_csr(id=None): ccode = module('chemical_code', alias={'cc': 'chemical_code', + 'cca': 'chemical_code captcha', 'chemicalcode': 'chemical_code', 'chemical_captcha': 'chemical_code captcha', 'chemicalcaptcha': 'chemical_code captcha', From a800d321cf74a1ca84c43201f1919768c934f265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 15:44:06 +0800 Subject: [PATCH 04/38] Update maimai --- modules/maimai/README | 1 - modules/maimai/__init__.py | 188 +----------------- .../{maimaidx_api_data.py => apidata.py} | 2 +- .../{maimai_best_50.py => best50.py} | 3 +- .../libraries/{maimaidx_music.py => music.py} | 0 .../{maimaidx_project.py => utils.py} | 4 +- modules/maimai/rating.py | 137 +++++++++++++ modules/maimai/regex.py | 52 +---- 8 files changed, 149 insertions(+), 238 deletions(-) delete mode 100644 modules/maimai/README rename modules/maimai/libraries/{maimaidx_api_data.py => apidata.py} (95%) rename modules/maimai/libraries/{maimai_best_50.py => best50.py} (99%) rename modules/maimai/libraries/{maimaidx_music.py => music.py} (100%) rename modules/maimai/libraries/{maimaidx_project.py => utils.py} (99%) create mode 100644 modules/maimai/rating.py diff --git a/modules/maimai/README b/modules/maimai/README deleted file mode 100644 index 11444d3d..00000000 --- a/modules/maimai/README +++ /dev/null @@ -1 +0,0 @@ -资源文件请解压到assets/maimai文件夹。 \ No newline at end of file diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index ac53379b..5afeefc4 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -5,17 +5,14 @@ from config import Config from core.builtins import Bot, Plain, Image as BImage from core.scheduler import CronTrigger from core.utils.image import msgchain2image -from modules.maimai.libraries.maimai_best_50 import generate -from modules.maimai.libraries.maimaidx_api_data import get_alias, get_info, search_by_alias, update_alias, update_covers -from modules.maimai.libraries.maimaidx_music import get_cover_len5_id, TotalList -from modules.maimai.libraries.maimaidx_project import get_level_process, \ - get_plate_process, get_player_score, get_rank, get_score_list +from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias, update_alias, update_covers +from modules.maimai.libraries.best50 import computeRa +from modules.maimai.libraries.music import TotalList +from .rating import * from .regex import * total_list = TotalList() -level_list = ['1', '2', '3', '4', '5', '6', '7', '7+', '8', '8+', '9', '9+', - '10', '10+', '11', '11+', '12', '12+', '13', '13+', '14', '14+', '15'] diff_label = ['Basic', 'Advanced', 'Expert', 'Master', 'Re:MASTER'] diff_label_abbr = ['bas', 'adv', 'exp', 'mas', 'rem'] @@ -160,18 +157,6 @@ async def _(msg: Bot.MessageSession, sid: str): await msg.finish([Plain(result.strip())]) -@mai.command('b50 [] {{maimai.help.b50}}') -async def _(msg: Bot.MessageSession, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender, 'b50': True} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username, 'b50': True} - img = await generate(msg, payload) - await msg.finish([BImage(img)]) - - @mai.command('id [] {{maimai.help.id}}') @mai.command('song [] {{maimai.help.song}}') async def _(msg: Bot.MessageSession, id_or_alias: str, diff: str = None): @@ -237,138 +222,6 @@ async def _(msg: Bot.MessageSession, id_or_alias: str, diff: str = None): await msg.finish(await get_info(msg, music, Plain(message))) -@mai.command('info [] {{maimai.help.info}}') -async def _(msg: Bot.MessageSession, id_or_alias: str, username: str = None): - if id_or_alias[:2].lower() == "id": - sid = id_or_alias[2:] - else: - sid_list = await search_by_alias(msg, id_or_alias) - - if len(sid_list) == 0: - await msg.finish(msg.locale.t("maimai.message.music_not_found")) - elif len(sid_list) > 1: - res = msg.locale.t("maimai.message.song.prompt") + "\n" - for sid in sorted(sid_list, key=int): - s = (await total_list.get()).by_id(sid) - res += f"{s['id']}\u200B. {s['title']}{' (DX)' if s['type'] == 'DX' else ''}\n" - await msg.finish(res.strip()) - else: - sid = str(sid_list[0]) - - music = (await total_list.get()).by_id(sid) - if not music: - await msg.finish(msg.locale.t("maimai.message.music_not_found")) - - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - output = await get_player_score(msg, payload, sid) - - await msg.finish(await get_info(msg, music, Plain(output))) - - -@mai.command('plate [] {{maimai.help.plate}}') -async def _(msg: Bot.MessageSession, plate: str, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - if plate == '真将' or (plate[1] == '者' and plate[0] != '霸'): - await msg.finish(msg.locale.t('maimai.message.plate.plate_not_found')) - - output, get_img = await get_plate_process(msg, payload, plate) - - if get_img: - img = await msgchain2image([Plain(output)]) - await msg.finish([BImage(img)]) - else: - await msg.finish(output.strip()) - - -@mai.command('process [] {{maimai.help.process}}') -async def _(msg: Bot.MessageSession, level: str, goal: str, username: str = None): - goal_list = [ - "A", - "AA", - "AAA", - "S", - "S+", - "SS", - "SS+", - "SSS", - "SSS+", - "FC", - "FC+", - "AP", - "AP+", - "FS", - "FS+", - "FDX", - "FDX+"] - - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - if level in level_list: - level_num = int(level.split('+')[0]) - if level_num < 8: - await msg.finish(msg.locale.t("maimai.message.process.less_than_8")) - else: - await msg.finish(msg.locale.t("maimai.message.level_invalid")) - - if goal.upper() not in goal_list: - await msg.finish(msg.locale.t("maimai.message.goal_invalid")) - - output, get_img = await get_level_process(msg, payload, level, goal) - - if get_img: - img = await msgchain2image([Plain(output)]) - await msg.finish([BImage(img)]) - else: - await msg.finish(output.strip()) - - -@mai.command('rank [] {{maimai.help.rank}}') -async def _(msg: Bot.MessageSession, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - await get_rank(msg, payload) - - -@mai.command('scorelist [] {{maimai.help.scorelist}}') -async def _(msg: Bot.MessageSession, level: str, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - res, get_img = await get_score_list(msg, payload, level) - - if get_img: - img = await msgchain2image([Plain(res)]) - await msg.finish([BImage(img)]) - else: - await msg.finish([Plain(res.strip())]) - - @mai.command('random [] {{maimai.help.random.filter}}') async def _(msg: Bot.MessageSession, dx_type: str = None): filter = msg.parsed_msg[''] @@ -463,39 +316,6 @@ async def _(msg: Bot.MessageSession, base: float, score: float): await msg.finish([Plain(max(0, computeRa(base, score)))]) -def computeRa(base: float, achievement: float) -> int: - if achievement < 50: - baseRa = 7.0 - elif achievement < 60: - baseRa = 8.0 - elif achievement < 70: - baseRa = 9.6 - elif achievement < 75: - baseRa = 11.2 - elif achievement < 80: - baseRa = 12.0 - elif achievement < 90: - baseRa = 13.6 - elif achievement < 94: - baseRa = 15.2 - elif achievement < 97: - baseRa = 16.8 - elif achievement < 98: - baseRa = 20.0 - elif achievement < 99: - baseRa = 20.3 - elif achievement < 99.5: - baseRa = 20.8 - elif achievement < 100: - baseRa = 21.1 - elif achievement < 100.5: - baseRa = 21.6 - else: - baseRa = 22.4 - - return math.floor(base * (min(100.5, achievement) / 100) * baseRa) - - @mai.command('update', required_superuser=True) async def _(msg: Bot.MessageSession): if await update_alias() and await update_covers(): diff --git a/modules/maimai/libraries/maimaidx_api_data.py b/modules/maimai/libraries/apidata.py similarity index 95% rename from modules/maimai/libraries/maimaidx_api_data.py rename to modules/maimai/libraries/apidata.py index 7f049013..28476a60 100644 --- a/modules/maimai/libraries/maimaidx_api_data.py +++ b/modules/maimai/libraries/apidata.py @@ -8,7 +8,7 @@ from core.builtins import Bot, Plain, Image from core.logger import Logger from core.utils.cache import random_cache_path from core.utils.http import get_url, post_url, download_to_cache -from .maimaidx_music import get_cover_len5_id, Music, TotalList +from .music import get_cover_len5_id, Music, TotalList total_list = TotalList() assets_path = os.path.abspath('./assets/maimai') diff --git a/modules/maimai/libraries/maimai_best_50.py b/modules/maimai/libraries/best50.py similarity index 99% rename from modules/maimai/libraries/maimai_best_50.py rename to modules/maimai/libraries/best50.py index 3d5c1270..e92bb349 100644 --- a/modules/maimai/libraries/maimai_best_50.py +++ b/modules/maimai/libraries/best50.py @@ -1,13 +1,12 @@ import math import os from typing import Optional, Dict, List, Tuple - import ujson as json from PIL import Image, ImageDraw, ImageFont, ImageFilter from core.builtins import ErrorMessage from core.utils.http import post_url -from .maimaidx_music import get_cover_len5_id, TotalList +from .music import get_cover_len5_id, TotalList total_list = TotalList() diff --git a/modules/maimai/libraries/maimaidx_music.py b/modules/maimai/libraries/music.py similarity index 100% rename from modules/maimai/libraries/maimaidx_music.py rename to modules/maimai/libraries/music.py diff --git a/modules/maimai/libraries/maimaidx_project.py b/modules/maimai/libraries/utils.py similarity index 99% rename from modules/maimai/libraries/maimaidx_project.py rename to modules/maimai/libraries/utils.py index 5b44f2b5..a13292bc 100644 --- a/modules/maimai/libraries/maimaidx_project.py +++ b/modules/maimai/libraries/utils.py @@ -5,8 +5,8 @@ import numpy as np from core.utils.http import get_url from core.utils.cache import random_cache_path -from .maimaidx_api_data import get_record, get_plate -from .maimaidx_music import TotalList +from .apidata import get_record, get_plate +from .music import TotalList JINGLEBELL_SONG_ID = 70 diff --git a/modules/maimai/rating.py b/modules/maimai/rating.py new file mode 100644 index 00000000..9476aed3 --- /dev/null +++ b/modules/maimai/rating.py @@ -0,0 +1,137 @@ +from core.builtins import Bot, Plain, Image as BImage +from core.utils.image import msgchain2image +from modules.maimai import total_list +from modules.maimai.libraries.apidata import get_info, search_by_alias +from modules.maimai.libraries.best50 import generate +from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score, get_rank, \ + get_score_list + +goal_list = ["A", "AA", "AAA", "S", "S+", "SS", "SS+", "SSS", "SSS+", + "FC", "FC+", "AP", "AP+", "FS", "FS+", "FDX", "FDX+"] +level_list = ['1', '2', '3', '4', '5', '6', '7', '7+', '8', '8+', '9', '9+', + '10', '10+', '11', '11+', '12', '12+', '13', '13+', '14', '14+', '15'] + + +@mai.command('b50 [] {{maimai.help.b50}}') +async def _(msg: Bot.MessageSession, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender, 'b50': True} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username, 'b50': True} + img = await generate(msg, payload) + await msg.finish([BImage(img)]) + + +@mai.command('info [] {{maimai.help.info}}') +async def _(msg: Bot.MessageSession, id_or_alias: str, username: str = None): + if id_or_alias[:2].lower() == "id": + sid = id_or_alias[2:] + else: + sid_list = await search_by_alias(msg, id_or_alias) + + if len(sid_list) == 0: + await msg.finish(msg.locale.t("maimai.message.music_not_found")) + elif len(sid_list) > 1: + res = msg.locale.t("maimai.message.song.prompt") + "\n" + for sid in sorted(sid_list, key=int): + s = (await total_list.get()).by_id(sid) + res += f"{s['id']}\u200B. {s['title']}{' (DX)' if s['type'] == 'DX' else ''}\n" + await msg.finish(res.strip()) + else: + sid = str(sid_list[0]) + + music = (await total_list.get()).by_id(sid) + if not music: + await msg.finish(msg.locale.t("maimai.message.music_not_found")) + + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + output = await get_player_score(msg, payload, sid) + + await msg.finish(await get_info(msg, music, Plain(output))) + + +@mai.command('plate [] {{maimai.help.plate}}') +async def _(msg: Bot.MessageSession, plate: str, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + if plate == '真将' or (plate[1] == '者' and plate[0] != '霸'): + await msg.finish(msg.locale.t('maimai.message.plate.plate_not_found')) + + output, get_img = await get_plate_process(msg, payload, plate) + + if get_img: + img = await msgchain2image([Plain(output)]) + await msg.finish([BImage(img)]) + else: + await msg.finish(output.strip()) + + +@mai.command('process [] {{maimai.help.process}}') +async def _(msg: Bot.MessageSession, level: str, goal: str, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + if level in level_list: + level_num = int(level.split('+')[0]) + if level_num < 8: + await msg.finish(msg.locale.t("maimai.message.process.less_than_8")) + else: + await msg.finish(msg.locale.t("maimai.message.level_invalid")) + + if goal.upper() not in goal_list: + await msg.finish(msg.locale.t("maimai.message.goal_invalid")) + + output, get_img = await get_level_process(msg, payload, level, goal) + + if get_img: + img = await msgchain2image([Plain(output)]) + await msg.finish([BImage(img)]) + else: + await msg.finish(output.strip()) + + +@mai.command('rank [] {{maimai.help.rank}}') +async def _(msg: Bot.MessageSession, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + await get_rank(msg, payload) + + +@mai.command('scorelist [] {{maimai.help.scorelist}}') +async def _(msg: Bot.MessageSession, level: str, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + res, get_img = await get_score_list(msg, payload, level) + + if get_img: + img = await msgchain2image([Plain(res)]) + await msg.finish([BImage(img)]) + else: + await msg.finish([Plain(res.strip())]) \ No newline at end of file diff --git a/modules/maimai/regex.py b/modules/maimai/regex.py index 18ecd4c2..2caa5930 100644 --- a/modules/maimai/regex.py +++ b/modules/maimai/regex.py @@ -5,36 +5,10 @@ from core.builtins import Bot, Plain, Image as BImage from core.component import module from core.logger import Logger from core.utils.image import msgchain2image -from modules.maimai.libraries.maimaidx_api_data import get_alias, get_info, search_by_alias -from modules.maimai.libraries.maimaidx_music import get_cover_len5_id, TotalList -from modules.maimai.libraries.maimaidx_project import get_level_process, get_plate_process, get_player_score - -total_list = TotalList() - -level_list = ['1', '2', '3', '4', '5', '6', '7', '7+', '8', '8+', '9', '9+', - '10', '10+', '11', '11+', '12', '12+', '13', '13+', '14', '14+', '15'] - -diff_label = ['Basic', 'Advanced', 'Expert', 'Master', 'Re:MASTER'] -diff_label_abbr = ['bas', 'adv', 'exp', 'mas', 'rem'] -diff_label_zhs = ['绿', '黄', '红', '紫', '白'] -diff_label_zht = ['綠', '黃', '紅'] - - -def get_diff(diff): - diff = diff.lower() - diff_label_lower = [label.lower() for label in diff_label] - - if diff in diff_label_zhs: - level = diff_label_zhs.index(diff) - elif diff in diff_label_zht: - level = diff_label_zht.index(diff) - elif diff in diff_label_abbr: - level = diff_label_abbr.index(diff) - elif diff in diff_label_lower: - level = diff_label_lower.index(diff) - else: - level = None - return level +from modules.maimai import get_diff, total_list +from modules.maimai.rating import goal_list, level_list +from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias +from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score mai_regex = module('maimai_regex', @@ -176,24 +150,6 @@ async def _(msg: Bot.MessageSession): @mai_regex.regex(re.compile(r"([0-9]+\+?)\s?(.+)\s?[进進]度\s?(.+)?"), desc='{maimai.help.maimai_regex.process}') async def _(msg: Bot.MessageSession): - goal_list = [ - "A", - "AA", - "AAA", - "S", - "S+", - "SS", - "SS+", - "SSS", - "SSS+", - "FC", - "FC+", - "AP", - "AP+", - "FS", - "FS+", - "FDX", - "FDX+"] level = msg.matched_msg.groups()[0] goal = msg.matched_msg.groups()[1] username = msg.matched_msg.groups()[2] From b4d9975afb98f26b59c6266a37e5c6f65cfdaae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 15:48:10 +0800 Subject: [PATCH 05/38] update --- modules/maimai/__init__.py | 1 - modules/maimai/rating.py | 3 ++- modules/maimai/regex.py | 25 ++++++++++++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index 5afeefc4..7fa32747 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -13,7 +13,6 @@ from .regex import * total_list = TotalList() - diff_label = ['Basic', 'Advanced', 'Expert', 'Master', 'Re:MASTER'] diff_label_abbr = ['bas', 'adv', 'exp', 'mas', 'rem'] diff_label_zhs = ['绿', '黄', '红', '紫', '白'] diff --git a/modules/maimai/rating.py b/modules/maimai/rating.py index 9476aed3..cca7cbdb 100644 --- a/modules/maimai/rating.py +++ b/modules/maimai/rating.py @@ -1,8 +1,8 @@ from core.builtins import Bot, Plain, Image as BImage from core.utils.image import msgchain2image -from modules.maimai import total_list from modules.maimai.libraries.apidata import get_info, search_by_alias from modules.maimai.libraries.best50 import generate +from modules.maimai.libraries.music import TotalList from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score, get_rank, \ get_score_list @@ -10,6 +10,7 @@ goal_list = ["A", "AA", "AAA", "S", "S+", "SS", "SS+", "SSS", "SSS+", "FC", "FC+", "AP", "AP+", "FS", "FS+", "FDX", "FDX+"] level_list = ['1', '2', '3', '4', '5', '6', '7', '7+', '8', '8+', '9', '9+', '10', '10+', '11', '11+', '12', '12+', '13', '13+', '14', '14+', '15'] +total_list = TotalList() @mai.command('b50 [] {{maimai.help.b50}}') diff --git a/modules/maimai/regex.py b/modules/maimai/regex.py index 2caa5930..7e28536e 100644 --- a/modules/maimai/regex.py +++ b/modules/maimai/regex.py @@ -5,11 +5,34 @@ from core.builtins import Bot, Plain, Image as BImage from core.component import module from core.logger import Logger from core.utils.image import msgchain2image -from modules.maimai import get_diff, total_list from modules.maimai.rating import goal_list, level_list from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias +from modules.maimai.libraries.music import TotalList from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score +total_list = TotalList() + +diff_label = ['Basic', 'Advanced', 'Expert', 'Master', 'Re:MASTER'] +diff_label_abbr = ['bas', 'adv', 'exp', 'mas', 'rem'] +diff_label_zhs = ['绿', '黄', '红', '紫', '白'] +diff_label_zht = ['綠', '黃', '紅'] + + +def get_diff(diff): + diff = diff.lower() + diff_label_lower = [label.lower() for label in diff_label] + + if diff in diff_label_zhs: + level = diff_label_zhs.index(diff) + elif diff in diff_label_zht: + level = diff_label_zht.index(diff) + elif diff in diff_label_abbr: + level = diff_label_abbr.index(diff) + elif diff in diff_label_lower: + level = diff_label_lower.index(diff) + else: + level = None + return level mai_regex = module('maimai_regex', desc='{maimai.help.maimai_regex.desc}', recommend_modules=['maimai'], From c6d03a87dfa7bbebd1c9dd821b970ed071ea376f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 15:52:53 +0800 Subject: [PATCH 06/38] update --- modules/ask/__init__.py | 2 +- modules/exchange_rate/__init__.py | 2 +- modules/maimai/__init__.py | 2 -- modules/maimai/rating.py | 3 +-- modules/maimai/regex.py | 23 +---------------------- modules/summary/__init__.py | 2 +- modules/wolframalpha/__init__.py | 3 +-- 7 files changed, 6 insertions(+), 31 deletions(-) diff --git a/modules/ask/__init__.py b/modules/ask/__init__.py index 719463ed..b162f175 100644 --- a/modules/ask/__init__.py +++ b/modules/ask/__init__.py @@ -8,9 +8,9 @@ from config import Config from core.builtins import Bot, Plain, Image from core.component import module from core.dirty_check import check_bool, rickroll +from core.exceptions import ConfigValueError from core.petal import count_petal from core.utils.cooldown import CoolDown -from core.exceptions import ConfigValueError os.environ['LANGCHAIN_TRACING_V2'] = str(Config('enable_langsmith')) if Config('enable_langsmith'): diff --git a/modules/exchange_rate/__init__.py b/modules/exchange_rate/__init__.py index bed613be..7c44bfb6 100644 --- a/modules/exchange_rate/__init__.py +++ b/modules/exchange_rate/__init__.py @@ -3,8 +3,8 @@ import datetime from config import Config from core.builtins import Bot from core.component import module -from core.utils.http import get_url from core.exceptions import ConfigValueError +from core.utils.http import get_url api_key = Config('exchange_rate_api_key') diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index 7fa32747..fa2ef9b3 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -8,8 +8,6 @@ from core.utils.image import msgchain2image from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias, update_alias, update_covers from modules.maimai.libraries.best50 import computeRa from modules.maimai.libraries.music import TotalList -from .rating import * -from .regex import * total_list = TotalList() diff --git a/modules/maimai/rating.py b/modules/maimai/rating.py index cca7cbdb..b3835ec7 100644 --- a/modules/maimai/rating.py +++ b/modules/maimai/rating.py @@ -1,8 +1,8 @@ from core.builtins import Bot, Plain, Image as BImage from core.utils.image import msgchain2image +from modules.maimai import total_list, mai from modules.maimai.libraries.apidata import get_info, search_by_alias from modules.maimai.libraries.best50 import generate -from modules.maimai.libraries.music import TotalList from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score, get_rank, \ get_score_list @@ -10,7 +10,6 @@ goal_list = ["A", "AA", "AAA", "S", "S+", "SS", "SS+", "SSS", "SSS+", "FC", "FC+", "AP", "AP+", "FS", "FS+", "FDX", "FDX+"] level_list = ['1', '2', '3', '4', '5', '6', '7', '7+', '8', '8+', '9', '9+', '10', '10+', '11', '11+', '12', '12+', '13', '13+', '14', '14+', '15'] -total_list = TotalList() @mai.command('b50 [] {{maimai.help.b50}}') diff --git a/modules/maimai/regex.py b/modules/maimai/regex.py index 7e28536e..22fd5370 100644 --- a/modules/maimai/regex.py +++ b/modules/maimai/regex.py @@ -5,34 +5,13 @@ from core.builtins import Bot, Plain, Image as BImage from core.component import module from core.logger import Logger from core.utils.image import msgchain2image +from modules.maimai import get_diff, total_list from modules.maimai.rating import goal_list, level_list from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias -from modules.maimai.libraries.music import TotalList from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score total_list = TotalList() -diff_label = ['Basic', 'Advanced', 'Expert', 'Master', 'Re:MASTER'] -diff_label_abbr = ['bas', 'adv', 'exp', 'mas', 'rem'] -diff_label_zhs = ['绿', '黄', '红', '紫', '白'] -diff_label_zht = ['綠', '黃', '紅'] - - -def get_diff(diff): - diff = diff.lower() - diff_label_lower = [label.lower() for label in diff_label] - - if diff in diff_label_zhs: - level = diff_label_zhs.index(diff) - elif diff in diff_label_zht: - level = diff_label_zht.index(diff) - elif diff in diff_label_abbr: - level = diff_label_abbr.index(diff) - elif diff in diff_label_lower: - level = diff_label_lower.index(diff) - else: - level = None - return level mai_regex = module('maimai_regex', desc='{maimai.help.maimai_regex.desc}', recommend_modules=['maimai'], diff --git a/modules/summary/__init__.py b/modules/summary/__init__.py index 18151c4a..b0905ab1 100644 --- a/modules/summary/__init__.py +++ b/modules/summary/__init__.py @@ -5,10 +5,10 @@ from config import Config from core.builtins import Bot from core.component import module from core.dirty_check import check_bool, rickroll +from core.exceptions import ConfigValueError from core.logger import Logger from core.petal import count_petal from core.utils.cooldown import CoolDown -from core.exceptions import ConfigValueError openai.api_key = Config('openai_api_key') diff --git a/modules/wolframalpha/__init__.py b/modules/wolframalpha/__init__.py index e8a4a9f1..f9107bc8 100644 --- a/modules/wolframalpha/__init__.py +++ b/modules/wolframalpha/__init__.py @@ -1,15 +1,14 @@ import os import urllib.parse - from PIL import Image from config import Config from core.builtins import Bot, Image as BImage from core.component import module from core.dirty_check import check_bool, rickroll +from core.exceptions import ConfigValueError from core.utils.http import download_to_cache, get_url -from core.exceptions import ConfigValueError appid = Config('wolfram_alpha_appid') From a2a39a303c4465a217ba000c60d36ef8a2e11ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 15:54:33 +0800 Subject: [PATCH 07/38] fix ? --- modules/maimai/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index fa2ef9b3..2f054e12 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -3,6 +3,7 @@ import traceback from config import Config from core.builtins import Bot, Plain, Image as BImage +from core.component import module from core.scheduler import CronTrigger from core.utils.image import msgchain2image from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias, update_alias, update_covers From 61fb76d93fb4ba9244d35b07ba3f0bd25dca8872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 16:28:36 +0800 Subject: [PATCH 08/38] fix --- modules/maimai/grade_info.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 modules/maimai/grade_info.json diff --git a/modules/maimai/grade_info.json b/modules/maimai/grade_info.json new file mode 100644 index 00000000..8159dbbd --- /dev/null +++ b/modules/maimai/grade_info.json @@ -0,0 +1,12 @@ +{ + "grade": { + "grade1": { + "life": ["-0", "-2", "-5", "+20"], + "charts": [ + {"song_id":} + ] + } + }, + "true_grade":, + "random_grade": +} \ No newline at end of file From 1aa1b4c0e8caa59db4547720f023605364fa6102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 16:29:17 +0800 Subject: [PATCH 09/38] . --- modules/maimai/__init__.py | 139 +++++++++++++++++++++++++++++- modules/maimai/grade_info.json | 12 --- modules/maimai/libraries/utils.py | 3 - modules/maimai/rating.py | 137 ----------------------------- modules/maimai/regex.py | 31 ++++++- 5 files changed, 163 insertions(+), 159 deletions(-) delete mode 100644 modules/maimai/rating.py diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index 2f054e12..5e7cc49f 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -3,13 +3,19 @@ import traceback from config import Config from core.builtins import Bot, Plain, Image as BImage -from core.component import module from core.scheduler import CronTrigger from core.utils.image import msgchain2image +from modules.maimai.libraries.best50 import computeRa, generate from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias, update_alias, update_covers -from modules.maimai.libraries.best50 import computeRa -from modules.maimai.libraries.music import TotalList +from modules.maimai.libraries.music import get_cover_len5_id, TotalList +from modules.maimai.libraries.utils import get_level_process, \ + get_plate_process, get_player_score, get_rank, get_score_list +from .regex import * +goal_list = ["A", "AA", "AAA", "S", "S+", "SS", "SS+", "SSS", "SSS+", + "FC", "FC+", "AP", "AP+", "FS", "FS+", "FDX", "FDX+"] +level_list = ['1', '2', '3', '4', '5', '6', '7', '7+', '8', '8+', '9', '9+', + '10', '10+', '11', '11+', '12', '12+', '13', '13+', '14', '14+', '15'] total_list = TotalList() diff_label = ['Basic', 'Advanced', 'Expert', 'Master', 'Re:MASTER'] @@ -155,6 +161,18 @@ async def _(msg: Bot.MessageSession, sid: str): await msg.finish([Plain(result.strip())]) +@mai.command('b50 [] {{maimai.help.b50}}') +async def _(msg: Bot.MessageSession, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender, 'b50': True} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username, 'b50': True} + img = await generate(msg, payload) + await msg.finish([BImage(img)]) + + @mai.command('id [] {{maimai.help.id}}') @mai.command('song [] {{maimai.help.song}}') async def _(msg: Bot.MessageSession, id_or_alias: str, diff: str = None): @@ -220,6 +238,119 @@ async def _(msg: Bot.MessageSession, id_or_alias: str, diff: str = None): await msg.finish(await get_info(msg, music, Plain(message))) +@mai.command('info [] {{maimai.help.info}}') +async def _(msg: Bot.MessageSession, id_or_alias: str, username: str = None): + if id_or_alias[:2].lower() == "id": + sid = id_or_alias[2:] + else: + sid_list = await search_by_alias(msg, id_or_alias) + + if len(sid_list) == 0: + await msg.finish(msg.locale.t("maimai.message.music_not_found")) + elif len(sid_list) > 1: + res = msg.locale.t("maimai.message.song.prompt") + "\n" + for sid in sorted(sid_list, key=int): + s = (await total_list.get()).by_id(sid) + res += f"{s['id']}\u200B. {s['title']}{' (DX)' if s['type'] == 'DX' else ''}\n" + await msg.finish(res.strip()) + else: + sid = str(sid_list[0]) + + music = (await total_list.get()).by_id(sid) + if not music: + await msg.finish(msg.locale.t("maimai.message.music_not_found")) + + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + output = await get_player_score(msg, payload, sid) + + await msg.finish(await get_info(msg, music, Plain(output))) + + +@mai.command('plate [] {{maimai.help.plate}}') +async def _(msg: Bot.MessageSession, plate: str, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + if plate == '真将' or (plate[1] == '者' and plate[0] != '霸'): + await msg.finish(msg.locale.t('maimai.message.plate.plate_not_found')) + + output, get_img = await get_plate_process(msg, payload, plate) + + if get_img: + img = await msgchain2image([Plain(output)]) + await msg.finish([BImage(img)]) + else: + await msg.finish(output.strip()) + + +@mai.command('process [] {{maimai.help.process}}') +async def _(msg: Bot.MessageSession, level: str, goal: str, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + if level in level_list: + level_num = int(level.split('+')[0]) + if level_num < 8: + await msg.finish(msg.locale.t("maimai.message.process.less_than_8")) + else: + await msg.finish(msg.locale.t("maimai.message.level_invalid")) + + if goal.upper() not in goal_list: + await msg.finish(msg.locale.t("maimai.message.goal_invalid")) + + output, get_img = await get_level_process(msg, payload, level, goal) + + if get_img: + img = await msgchain2image([Plain(output)]) + await msg.finish([BImage(img)]) + else: + await msg.finish(output.strip()) + + +@mai.command('rank [] {{maimai.help.rank}}') +async def _(msg: Bot.MessageSession, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + await get_rank(msg, payload) + + +@mai.command('scorelist [] {{maimai.help.scorelist}}') +async def _(msg: Bot.MessageSession, level: str, username: str = None): + if not username and msg.target.sender_from == "QQ": + payload = {'qq': msg.session.sender} + else: + if not username: + await msg.finish(msg.locale.t("maimai.message.no_username")) + payload = {'username': username} + + res, get_img = await get_score_list(msg, payload, level) + + if get_img: + img = await msgchain2image([Plain(res)]) + await msg.finish([BImage(img)]) + else: + await msg.finish([Plain(res.strip())]) + + @mai.command('random [] {{maimai.help.random.filter}}') async def _(msg: Bot.MessageSession, dx_type: str = None): filter = msg.parsed_msg[''] @@ -329,4 +460,4 @@ async def _(): await update_alias() except Exception: if Config('debug'): - Logger.error(traceback.format_exc()) + Logger.error(traceback.format_exc()) \ No newline at end of file diff --git a/modules/maimai/grade_info.json b/modules/maimai/grade_info.json index 8159dbbd..e69de29b 100644 --- a/modules/maimai/grade_info.json +++ b/modules/maimai/grade_info.json @@ -1,12 +0,0 @@ -{ - "grade": { - "grade1": { - "life": ["-0", "-2", "-5", "+20"], - "charts": [ - {"song_id":} - ] - } - }, - "true_grade":, - "random_grade": -} \ No newline at end of file diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index a13292bc..643bd7d6 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -1,8 +1,5 @@ from datetime import datetime -import matplotlib.pyplot as plt -import numpy as np - from core.utils.http import get_url from core.utils.cache import random_cache_path from .apidata import get_record, get_plate diff --git a/modules/maimai/rating.py b/modules/maimai/rating.py deleted file mode 100644 index b3835ec7..00000000 --- a/modules/maimai/rating.py +++ /dev/null @@ -1,137 +0,0 @@ -from core.builtins import Bot, Plain, Image as BImage -from core.utils.image import msgchain2image -from modules.maimai import total_list, mai -from modules.maimai.libraries.apidata import get_info, search_by_alias -from modules.maimai.libraries.best50 import generate -from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score, get_rank, \ - get_score_list - -goal_list = ["A", "AA", "AAA", "S", "S+", "SS", "SS+", "SSS", "SSS+", - "FC", "FC+", "AP", "AP+", "FS", "FS+", "FDX", "FDX+"] -level_list = ['1', '2', '3', '4', '5', '6', '7', '7+', '8', '8+', '9', '9+', - '10', '10+', '11', '11+', '12', '12+', '13', '13+', '14', '14+', '15'] - - -@mai.command('b50 [] {{maimai.help.b50}}') -async def _(msg: Bot.MessageSession, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender, 'b50': True} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username, 'b50': True} - img = await generate(msg, payload) - await msg.finish([BImage(img)]) - - -@mai.command('info [] {{maimai.help.info}}') -async def _(msg: Bot.MessageSession, id_or_alias: str, username: str = None): - if id_or_alias[:2].lower() == "id": - sid = id_or_alias[2:] - else: - sid_list = await search_by_alias(msg, id_or_alias) - - if len(sid_list) == 0: - await msg.finish(msg.locale.t("maimai.message.music_not_found")) - elif len(sid_list) > 1: - res = msg.locale.t("maimai.message.song.prompt") + "\n" - for sid in sorted(sid_list, key=int): - s = (await total_list.get()).by_id(sid) - res += f"{s['id']}\u200B. {s['title']}{' (DX)' if s['type'] == 'DX' else ''}\n" - await msg.finish(res.strip()) - else: - sid = str(sid_list[0]) - - music = (await total_list.get()).by_id(sid) - if not music: - await msg.finish(msg.locale.t("maimai.message.music_not_found")) - - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - output = await get_player_score(msg, payload, sid) - - await msg.finish(await get_info(msg, music, Plain(output))) - - -@mai.command('plate [] {{maimai.help.plate}}') -async def _(msg: Bot.MessageSession, plate: str, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - if plate == '真将' or (plate[1] == '者' and plate[0] != '霸'): - await msg.finish(msg.locale.t('maimai.message.plate.plate_not_found')) - - output, get_img = await get_plate_process(msg, payload, plate) - - if get_img: - img = await msgchain2image([Plain(output)]) - await msg.finish([BImage(img)]) - else: - await msg.finish(output.strip()) - - -@mai.command('process [] {{maimai.help.process}}') -async def _(msg: Bot.MessageSession, level: str, goal: str, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - if level in level_list: - level_num = int(level.split('+')[0]) - if level_num < 8: - await msg.finish(msg.locale.t("maimai.message.process.less_than_8")) - else: - await msg.finish(msg.locale.t("maimai.message.level_invalid")) - - if goal.upper() not in goal_list: - await msg.finish(msg.locale.t("maimai.message.goal_invalid")) - - output, get_img = await get_level_process(msg, payload, level, goal) - - if get_img: - img = await msgchain2image([Plain(output)]) - await msg.finish([BImage(img)]) - else: - await msg.finish(output.strip()) - - -@mai.command('rank [] {{maimai.help.rank}}') -async def _(msg: Bot.MessageSession, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - await get_rank(msg, payload) - - -@mai.command('scorelist [] {{maimai.help.scorelist}}') -async def _(msg: Bot.MessageSession, level: str, username: str = None): - if not username and msg.target.sender_from == "QQ": - payload = {'qq': msg.session.sender} - else: - if not username: - await msg.finish(msg.locale.t("maimai.message.no_username")) - payload = {'username': username} - - res, get_img = await get_score_list(msg, payload, level) - - if get_img: - img = await msgchain2image([Plain(res)]) - await msg.finish([BImage(img)]) - else: - await msg.finish([Plain(res.strip())]) \ No newline at end of file diff --git a/modules/maimai/regex.py b/modules/maimai/regex.py index 22fd5370..5a9c57e4 100644 --- a/modules/maimai/regex.py +++ b/modules/maimai/regex.py @@ -5,13 +5,38 @@ from core.builtins import Bot, Plain, Image as BImage from core.component import module from core.logger import Logger from core.utils.image import msgchain2image -from modules.maimai import get_diff, total_list -from modules.maimai.rating import goal_list, level_list from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias +from modules.maimai.libraries.music import get_cover_len5_id, TotalList from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score +goal_list = ["A", "AA", "AAA", "S", "S+", "SS", "SS+", "SSS", "SSS+", + "FC", "FC+", "AP", "AP+", "FS", "FS+", "FDX", "FDX+"] +level_list = ['1', '2', '3', '4', '5', '6', '7', '7+', '8', '8+', '9', '9+', + '10', '10+', '11', '11+', '12', '12+', '13', '13+', '14', '14+', '15'] total_list = TotalList() +diff_label = ['Basic', 'Advanced', 'Expert', 'Master', 'Re:MASTER'] +diff_label_abbr = ['bas', 'adv', 'exp', 'mas', 'rem'] +diff_label_zhs = ['绿', '黄', '红', '紫', '白'] +diff_label_zht = ['綠', '黃', '紅'] + + +def get_diff(diff): + diff = diff.lower() + diff_label_lower = [label.lower() for label in diff_label] + + if diff in diff_label_zhs: + level = diff_label_zhs.index(diff) + elif diff in diff_label_zht: + level = diff_label_zht.index(diff) + elif diff in diff_label_abbr: + level = diff_label_abbr.index(diff) + elif diff in diff_label_lower: + level = diff_label_lower.index(diff) + else: + level = None + return level + mai_regex = module('maimai_regex', desc='{maimai.help.maimai_regex.desc}', recommend_modules=['maimai'], @@ -180,4 +205,4 @@ async def _(msg: Bot.MessageSession): img = await msgchain2image([Plain(output)], msg) await msg.finish([BImage(img)]) else: - await msg.finish(output.strip()) + await msg.finish(output.strip()) \ No newline at end of file From 79a60680e1e35976a97f97fdd1e494283c589c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 17:31:34 +0800 Subject: [PATCH 10/38] maimai grade wip --- assets/maimai/grade_info.json | 700 ++++++++++++++++++++++++++++++ modules/maimai/grade_info.json | 0 modules/maimai/libraries/utils.py | 33 +- 3 files changed, 732 insertions(+), 1 deletion(-) create mode 100644 assets/maimai/grade_info.json delete mode 100644 modules/maimai/grade_info.json diff --git a/assets/maimai/grade_info.json b/assets/maimai/grade_info.json new file mode 100644 index 00000000..8c2415dd --- /dev/null +++ b/assets/maimai/grade_info.json @@ -0,0 +1,700 @@ +{ + "grade": { + "grade1": { + "charts": [ + { + "level_index": 0, + "song_id": 10552 + }, + { + "level_index": 0, + "song_id": 322 + }, + { + "level_index": 0, + "song_id": 793 + }, + { + "level_index": 0, + "song_id": 741 + } + ], + "config": [ + "-0", + "-2", + "-5", + "+20" + ], + "life": 350 + }, + "grade10": { + "charts": [ + { + "level_index": 3, + "song_id": 11164 + }, + { + "level_index": 3, + "song_id": 112 + }, + { + "level_index": 3, + "song_id": 11233 + }, + { + "level_index": 3, + "song_id": 11230 + } + ], + "config": [ + "-2", + "-2", + "-5", + "+20" + ], + "life": 900 + }, + "grade2": { + "charts": [ + { + "level_index": 1, + "song_id": 11043 + }, + { + "level_index": 1, + "song_id": 582 + }, + { + "level_index": 1, + "song_id": 725 + }, + { + "level_index": 1, + "song_id": 682 + } + ], + "config": [ + "-0", + "-2", + "-5", + "+20" + ], + "life": 350 + }, + "grade3": { + "charts": [ + { + "level_index": 1, + "song_id": 11187 + }, + { + "level_index": 1, + "song_id": 11325 + }, + { + "level_index": 1, + "song_id": 11049 + }, + { + "level_index": 1, + "song_id": 10593 + } + ], + "config": [ + "-1", + "-2", + "-5", + "+50" + ], + "life": 600 + }, + "grade4": { + "charts": [ + { + "level_index": 2, + "song_id": 311 + }, + { + "level_index": 2, + "song_id": 11260 + }, + { + "level_index": 2, + "song_id": 546 + }, + { + "level_index": 2, + "song_id": 11139 + } + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "life": 700 + }, + "grade5": { + "charts": [ + { + "level_index": 2, + "song_id": 11132 + }, + { + "level_index": 2, + "song_id": 11192 + }, + { + "level_index": 2, + "song_id": 11104 + }, + { + "level_index": 2, + "song_id": 548 + } + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "life": 700 + }, + "grade6": { + "charts": [ + { + "level_index": 2, + "song_id": 699 + }, + { + "level_index": 2, + "song_id": 681 + }, + { + "level_index": 2, + "song_id": 113 + }, + { + "level_index": 2, + "song_id": 11221 + } + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "life": 700 + }, + "grade7": { + "charts": [ + { + "level_index": 3, + "song_id": 11044 + }, + { + "level_index": 3, + "song_id": 242 + }, + { + "level_index": 3, + "song_id": 699 + }, + { + "level_index": 3, + "song_id": 138 + } + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "life": 700 + }, + "grade8": { + "charts": [ + { + "level_index": 3, + "song_id": 11229 + }, + { + "level_index": 3, + "song_id": 713 + }, + { + "level_index": 3, + "song_id": 11091 + }, + { + "level_index": 3, + "song_id": 464 + } + ], + "config": [ + "-2", + "-2", + "-5", + "+20" + ], + "life": 700 + }, + "grade9": { + "charts": [ + { + "level_index": 3, + "song_id": 11092 + }, + { + "level_index": 3, + "song_id": 11141 + }, + { + "level_index": 3, + "song_id": 82 + }, + { + "level_index": 3, + "song_id": 319 + } + ], + "config": [ + "-2", + "-2", + "-5", + "+20" + ], + "life": 800 + } + }, + "rgrade": { + "expert1": { + "base": [ + 7.0, + 9.6 + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "level_index": 2, + "life": 700 + }, + "expert2": { + "base": [ + 9.7, + 11.6 + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "level_index": 2, + "life": 600 + }, + "expert3": { + "base": [ + 11.7, + 13.9 + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "level_index": 2, + "life": 500 + }, + "master1": { + "base": [ + 10.0, + 11.9 + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "level_index": 3, + "life": 700 + }, + "master2": { + "base": [ + 12.0, + 13.2 + ], + "config": [ + "-2", + "-2", + "-5", + "+50" + ], + "level_index": 3, + "life": 500 + }, + "master3": { + "base": [ + 13.3, + 14.4 + ], + "config": [ + "-2", + "-2", + "-5", + "+20" + ], + "level_index": 3, + "life": 300 + }, + "master4": { + "base": [ + 14.5, + 14.9 + ], + "config": [ + "-2", + "-3", + "-5", + "+20" + ], + "level_index": 3, + "life": 100 + } + }, + "tgrade": { + "tgrade1": { + "charts": [ + { + "level_index": 3, + "song_id": 11010 + }, + { + "level_index": 3, + "song_id": 535 + }, + { + "level_index": 3, + "song_id": 11001 + }, + { + "level_index": 2, + "song_id": 136 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade10": { + "charts": [ + { + "level_index": 3, + "song_id": 11295 + }, + { + "level_index": 3, + "song_id": 11302 + }, + { + "level_index": 3, + "song_id": 11106 + }, + { + "level_index": 3, + "song_id": 773 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade11": { + "charts": [ + { + "level_index": 3, + "song_id": 11364 + }, + { + "level_index": 3, + "song_id": 571 + }, + { + "level_index": 3, + "song_id": 11311 + }, + { + "level_index": 3, + "song_id": 834 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+5" + ], + "life": 50 + }, + "tgrade12": { + "charts": [ + { + "level_index": 4, + "song_id": 833 + }, + { + "level_index": 4, + "song_id": 803 + }, + { + "level_index": 4, + "song_id": 799 + }, + { + "level_index": 4, + "song_id": 834 + } + ], + "config": [ + "-1", + "-3", + "-10", + "+0" + ], + "life": 10 + }, + "tgrade2": { + "charts": [ + { + "level_index": 2, + "song_id": 11027 + }, + { + "level_index": 3, + "song_id": 11137 + }, + { + "level_index": 3, + "song_id": 228 + }, + { + "level_index": 3, + "song_id": 313 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade3": { + "charts": [ + { + "level_index": 3, + "song_id": 434 + }, + { + "level_index": 3, + "song_id": 11263 + }, + { + "level_index": 2, + "song_id": 11167 + }, + { + "level_index": 3, + "song_id": 11188 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade4": { + "charts": [ + { + "level_index": 2, + "song_id": 833 + }, + { + "level_index": 3, + "song_id": 218 + }, + { + "level_index": 3, + "song_id": 11153 + }, + { + "level_index": 3, + "song_id": 35 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade5": { + "charts": [ + { + "level_index": 3, + "song_id": 11231 + }, + { + "level_index": 3, + "song_id": 624 + }, + { + "level_index": 3, + "song_id": 11214 + }, + { + "level_index": 3, + "song_id": 454 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade6": { + "charts": [ + { + "level_index": 3, + "song_id": 252 + }, + { + "level_index": 3, + "song_id": 559 + }, + { + "level_index": 3, + "song_id": 11158 + }, + { + "level_index": 3, + "song_id": 422 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade7": { + "charts": [ + { + "level_index": 3, + "song_id": 11334 + }, + { + "level_index": 3, + "song_id": 701 + }, + { + "level_index": 3, + "song_id": 574 + }, + { + "level_index": 3, + "song_id": 141 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade8": { + "charts": [ + { + "level_index": 3, + "song_id": 11237 + }, + { + "level_index": 4, + "song_id": 24 + }, + { + "level_index": 3, + "song_id": 11101 + }, + { + "level_index": 3, + "song_id": 270 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + }, + "tgrade9": { + "charts": [ + { + "level_index": 3, + "song_id": 11093 + }, + { + "level_index": 3, + "song_id": 641 + }, + { + "level_index": 3, + "song_id": 61 + }, + { + "level_index": 3, + "song_id": 348 + } + ], + "config": [ + "-2", + "-3", + "-5", + "+10" + ], + "life": 50 + } + } +} \ No newline at end of file diff --git a/modules/maimai/grade_info.json b/modules/maimai/grade_info.json deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 643bd7d6..799877b8 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -38,6 +38,34 @@ plate_to_version = { '祝': 'maimai でらっくす FESTiVAL' } +grade_conversion = { + '初段': 'grade1', + '二段': 'grade2', + '三段': 'grade3', + '四段': 'grade4', + '五段': 'grade5', + '六段': 'grade6', + '七段': 'grade7', + '八段': 'grade8', + '九段': 'grade9', + '十段': 'grade10', + '真初段': 'tgrade1', + '真二段': 'tgrade2', + '真三段': 'tgrade3', + '真四段': 'tgrade4', + '真五段': 'tgrade5', + '真六段': 'tgrade6', + '真七段': 'tgrade7', + '真八段': 'tgrade8', + '真九段': 'tgrade9', + '真十段': 'tgrade10', + '真皆传': 'tgrade11', + '真皆傳': 'tgrade11', + '里皆传': 'tgrade12', + '裡皆傳': 'tgrade12', + '裏皆傳': 'tgrade12', +} + score_to_rank = { (0.0, 50.0): "D", (50.0, 60.0): "C", @@ -454,4 +482,7 @@ async def get_plate_process(msg, payload, plate): else: output += msg.locale.t('maimai.message.plate.completed', plate=plate) - return output, get_img \ No newline at end of file + return output, get_img + + +async def get_grade_info(msg, payload, process, goal): \ No newline at end of file From 681f8a3a6a00d3684edec53d8efc551d7ee069c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 18:03:55 +0800 Subject: [PATCH 11/38] fix problem --- modules/maimai/libraries/apidata.py | 3 +-- modules/maimai/libraries/utils.py | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/maimai/libraries/apidata.py b/modules/maimai/libraries/apidata.py index 28476a60..52007ff5 100644 --- a/modules/maimai/libraries/apidata.py +++ b/modules/maimai/libraries/apidata.py @@ -1,7 +1,6 @@ import os import shutil import traceback - import ujson as json from core.builtins import Bot, Plain, Image @@ -10,8 +9,8 @@ from core.utils.cache import random_cache_path from core.utils.http import get_url, post_url, download_to_cache from .music import get_cover_len5_id, Music, TotalList -total_list = TotalList() assets_path = os.path.abspath('./assets/maimai') +total_list = TotalList() async def update_alias(): diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 799877b8..1841412f 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -1,3 +1,5 @@ +import os +import ujson as json from datetime import datetime from core.utils.http import get_url @@ -7,6 +9,7 @@ from .music import TotalList JINGLEBELL_SONG_ID = 70 +assets_path = os.path.abspath('./assets/maimai') total_list = TotalList() plate_to_version = { @@ -256,7 +259,7 @@ async def get_level_process(msg, payload, process, goal): elif goal in syncRank: if verlist[record_index]['fs']: self_record = syncRank[sync_rank.index(verlist[record_index]['fs'])] - output += f"{s[0]}\u200B. {s[1]}{msg.locale.t('message.brackets', msg='DX') if s[5] == 'DX' else ''} {s[2]} {s[3]} {self_record}\n" + output += f"{s[0]}\u200B. {s[1]}{' (DX)' if s[5] == 'DX' else ''} {s[2]} {s[3]} {self_record}\n" if len(song_remain) > 10: # 若剩余歌曲大于10个则使用图片形式 get_img = True else: @@ -283,7 +286,7 @@ async def get_score_list(msg, payload, level): output_lines = [] for s in enumerate(sorted(song_list, key=lambda i: i['achievements'], reverse=True)): # 根据成绩排序 music = (await total_list.get()).by_id(str(s[1]['id'])) - output = f"{music.id}\u200B. {music.title}{msg.locale.t('message.brackets', msg='DX') if music.type == 'DX' else ''} {diffs[s[1]['level_index']]} {music.ds[s[1]['level_index']]} {s[1]['achievements']}%" + output = f"{music.id}\u200B. {music.title}{' (DX)' if music.type == 'DX' else ''} {diffs[s[1]['level_index']]} {music.ds[s[1]['level_index']]} {s[1]['achievements']}%" if s[1]["fc"] and s[1]["fs"]: output += f" {combo_conversion.get(s[1]['fc'], '')} {sync_conversion.get(s[1]['fs'], '')}" elif s[1]["fc"] or s[1]["fs"]: @@ -448,7 +451,7 @@ async def get_plate_process(msg, payload, plate): elif goal == '舞舞': if verlist[record_index]['fs']: self_record = syncRank[sync_rank.index(verlist[record_index]['fs'])] - output += f"{s[0]}\u200B. {s[1]}{msg.locale.t('message.brackets', msg='DX') if s[5] == 'DX' else ''} {s[2]} {s[3]} {self_record}".strip() + '\n' + output += f"{s[0]}\u200B. {s[1]}{' (DX)' if s[5] == 'DX' else ''} {s[2]} {s[3]} {self_record}".strip() + '\n' if len(song_remain_difficult) > 10: # 若剩余歌曲大于10个则使用图片形式 get_img = True else: @@ -473,7 +476,7 @@ async def get_plate_process(msg, payload, plate): elif goal == '舞舞': if verlist[record_index]['fs']: self_record = syncRank[sync_rank.index(verlist[record_index]['fs'])] - output += f"{m.id}\u200B. {m.title}{msg.locale.t('message.brackets', msg='DX') if m.type == 'DX' else ''} {diffs[s[1]]} {m.ds[s[1]]} {self_record}".strip( + output += f"{m.id}\u200B. {m.title}{' (DX)' if m.type == 'DX' else ''} {diffs[s[1]]} {m.ds[s[1]]} {self_record}".strip( ) + '\n' if len(song_remain) > 10: # 若剩余歌曲大于10个则使用图片形式 get_img = True @@ -485,4 +488,3 @@ async def get_plate_process(msg, payload, plate): return output, get_img -async def get_grade_info(msg, payload, process, goal): \ No newline at end of file From 7444fe71ed30b34a598cf0ad990f28859a7f2e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 19:05:39 +0800 Subject: [PATCH 12/38] wip --- .../{grade_info.json => mai_grade_info.json} | 58 +++++++++---------- modules/maimai/__init__.py | 6 ++ modules/maimai/libraries/utils.py | 33 +++++++++++ 3 files changed, 68 insertions(+), 29 deletions(-) rename assets/maimai/{grade_info.json => mai_grade_info.json} (91%) diff --git a/assets/maimai/grade_info.json b/assets/maimai/mai_grade_info.json similarity index 91% rename from assets/maimai/grade_info.json rename to assets/maimai/mai_grade_info.json index 8c2415dd..babaa403 100644 --- a/assets/maimai/grade_info.json +++ b/assets/maimai/mai_grade_info.json @@ -19,7 +19,7 @@ "song_id": 741 } ], - "config": [ + "condition": [ "-0", "-2", "-5", @@ -46,7 +46,7 @@ "song_id": 11230 } ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -73,7 +73,7 @@ "song_id": 682 } ], - "config": [ + "condition": [ "-0", "-2", "-5", @@ -100,7 +100,7 @@ "song_id": 10593 } ], - "config": [ + "condition": [ "-1", "-2", "-5", @@ -127,7 +127,7 @@ "song_id": 11139 } ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -154,7 +154,7 @@ "song_id": 548 } ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -181,7 +181,7 @@ "song_id": 11221 } ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -208,7 +208,7 @@ "song_id": 138 } ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -235,7 +235,7 @@ "song_id": 464 } ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -262,7 +262,7 @@ "song_id": 319 } ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -277,7 +277,7 @@ 7.0, 9.6 ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -291,7 +291,7 @@ 9.7, 11.6 ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -305,7 +305,7 @@ 11.7, 13.9 ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -319,7 +319,7 @@ 10.0, 11.9 ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -333,7 +333,7 @@ 12.0, 13.2 ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -347,7 +347,7 @@ 13.3, 14.4 ], - "config": [ + "condition": [ "-2", "-2", "-5", @@ -361,7 +361,7 @@ 14.5, 14.9 ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -391,7 +391,7 @@ "song_id": 136 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -418,7 +418,7 @@ "song_id": 773 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -445,7 +445,7 @@ "song_id": 834 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -472,7 +472,7 @@ "song_id": 834 } ], - "config": [ + "condition": [ "-1", "-3", "-10", @@ -499,7 +499,7 @@ "song_id": 313 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -526,7 +526,7 @@ "song_id": 11188 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -553,7 +553,7 @@ "song_id": 35 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -580,7 +580,7 @@ "song_id": 454 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -607,7 +607,7 @@ "song_id": 422 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -634,7 +634,7 @@ "song_id": 141 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -661,7 +661,7 @@ "song_id": 270 } ], - "config": [ + "condition": [ "-2", "-3", "-5", @@ -688,7 +688,7 @@ "song_id": 348 } ], - "config": [ + "condition": [ "-2", "-3", "-5", diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index 5e7cc49f..10bdaacd 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -445,6 +445,12 @@ async def _(msg: Bot.MessageSession, base: float, score: float): await msg.finish([Plain(max(0, computeRa(base, score)))]) +@mai.command('grade {{maimai.help.grade}}') +async def _(msg: Bot.MessageSession, grade: str): + res = await get_grade_info(msg, grade) + await msg.finish(res) + + @mai.command('update', required_superuser=True) async def _(msg: Bot.MessageSession): if await update_alias() and await update_covers(): diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 1841412f..518dafc4 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -488,3 +488,36 @@ async def get_plate_process(msg, payload, plate): return output, get_img +async def get_grade_info(msg, grade): + file_path = os.path.join(assets_path, "mai_grade_info.json") + with open(file_path, 'r') as file: + data = json.load(file) + + if grade in list(grade_conversion.keys()): + grade_key = grade_conversion[grade] + else: + await msg.finish(无效的段位名称) + + if grade_key.startswith('tgrade'): + grade_type = 'tgrade' + elif grade_key.startswith('grade'): + grade_type = 'grade' + else: + grade_type = 'rgrade' + + chart_info = [] + if grade_type != 'rgrade': + grade_data = data[grade_type].get(grade_key) + charts = grade_data["charts"] + condition = grade_data["condition"] + life = grade_data["life"] + + for chart in charts: + music = total_list.get().by_id(chart['song_id']) + level = chart['level_index'] + chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + + condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" + + res = f"以下为{grade}段位列表:\n{'\n'.join(chart_info)}\n血量上限:{life}\n{condition_info}" + return res From 973ac16ab9a99989483df1baf4e99b2b6dcdc0f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 19:13:56 +0800 Subject: [PATCH 13/38] update --- modules/maimai/libraries/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 518dafc4..547a0602 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -517,7 +517,5 @@ async def get_grade_info(msg, grade): level = chart['level_index'] chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") - condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" - - res = f"以下为{grade}段位列表:\n{'\n'.join(chart_info)}\n血量上限:{life}\n{condition_info}" + res = f"以下为{grade}段位列表:\n{'\n'.join(chart_info)}\n血量上限:{life}\nGREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" return res From 2b01067290dbcd3388cc973d5b58f11c8548e816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 19:18:34 +0800 Subject: [PATCH 14/38] fix --- modules/maimai/libraries/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 547a0602..d7b28807 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -496,7 +496,7 @@ async def get_grade_info(msg, grade): if grade in list(grade_conversion.keys()): grade_key = grade_conversion[grade] else: - await msg.finish(无效的段位名称) + await msg.finish(无效的) if grade_key.startswith('tgrade'): grade_type = 'tgrade' @@ -517,5 +517,7 @@ async def get_grade_info(msg, grade): level = chart['level_index'] chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") - res = f"以下为{grade}段位列表:\n{'\n'.join(chart_info)}\n血量上限:{life}\nGREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" + condition_info = f"GREAT{condition[0]}\/GOOD{condition[1]}\/MISS{condition[2]}\/CLEAR{condition[3]}" + + res = f"以下为{grade}段位列表:\n{'\n'.join(chart_info)}\n血量上限:{life}\n{condition_info}" return res From b0cd2dde6e3f4951cd6cbab2b0f41ecece0876ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 19:27:31 +0800 Subject: [PATCH 15/38] orz --- modules/maimai/libraries/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index d7b28807..91cb336e 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -496,7 +496,7 @@ async def get_grade_info(msg, grade): if grade in list(grade_conversion.keys()): grade_key = grade_conversion[grade] else: - await msg.finish(无效的) + await msg.finish(无效的段位) if grade_key.startswith('tgrade'): grade_type = 'tgrade' @@ -517,7 +517,8 @@ async def get_grade_info(msg, grade): level = chart['level_index'] chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") - condition_info = f"GREAT{condition[0]}\/GOOD{condition[1]}\/MISS{condition[2]}\/CLEAR{condition[3]}" + output_lines = '\n'.join(chart_info) + condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" - res = f"以下为{grade}段位列表:\n{'\n'.join(chart_info)}\n血量上限:{life}\n{condition_info}" + res = f"以下为{grade}段位列表:\n{output_lines}\n血量上限:{life}\n{condition_info}" return res From 25c1ee1c1f8402c5c8e917db0de0bdf86abae56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 19:29:06 +0800 Subject: [PATCH 16/38] . --- modules/maimai/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index 10bdaacd..7fea7f5d 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -8,7 +8,7 @@ from core.utils.image import msgchain2image from modules.maimai.libraries.best50 import computeRa, generate from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias, update_alias, update_covers from modules.maimai.libraries.music import get_cover_len5_id, TotalList -from modules.maimai.libraries.utils import get_level_process, \ +from modules.maimai.libraries.utils import get_grade_info, get_level_process, \ get_plate_process, get_player_score, get_rank, get_score_list from .regex import * From e82064396071e29457fcd59b845c6dddc1e444fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 19:31:27 +0800 Subject: [PATCH 17/38] fix --- modules/maimai/libraries/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 91cb336e..2584f556 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -496,7 +496,7 @@ async def get_grade_info(msg, grade): if grade in list(grade_conversion.keys()): grade_key = grade_conversion[grade] else: - await msg.finish(无效的段位) + await msg.finish("无效的段位") if grade_key.startswith('tgrade'): grade_type = 'tgrade' @@ -513,7 +513,7 @@ async def get_grade_info(msg, grade): life = grade_data["life"] for chart in charts: - music = total_list.get().by_id(chart['song_id']) + music = await total_list.get().by_id(chart['song_id']) level = chart['level_index'] chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") From 4d2a9a6d131991b0eedffeee034d999a28e0ecf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 19:35:20 +0800 Subject: [PATCH 18/38] .. --- modules/maimai/libraries/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 2584f556..548fb086 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -513,7 +513,7 @@ async def get_grade_info(msg, grade): life = grade_data["life"] for chart in charts: - music = await total_list.get().by_id(chart['song_id']) + music = (await total_list.get()).by_id(chart['song_id']) level = chart['level_index'] chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") From 80290b7dccd3c5fa000d2f9b08119dd76a9ce9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Fri, 29 Dec 2023 19:37:13 +0800 Subject: [PATCH 19/38] r --- modules/maimai/libraries/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 548fb086..3c2df33c 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -515,7 +515,7 @@ async def get_grade_info(msg, grade): for chart in charts: music = (await total_list.get()).by_id(chart['song_id']) level = chart['level_index'] - chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + chart_info.append(f"{music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") output_lines = '\n'.join(chart_info) condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" From 61a7544a074220d63fae772dc764f529641d1adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 17:54:59 +0800 Subject: [PATCH 20/38] fix --- modules/maimai/libraries/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 3c2df33c..059ba5cc 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -507,7 +507,7 @@ async def get_grade_info(msg, grade): chart_info = [] if grade_type != 'rgrade': - grade_data = data[grade_type].get(grade_key) + grade_data = data[grade_type][grade_key].get(grade_key) charts = grade_data["charts"] condition = grade_data["condition"] life = grade_data["life"] @@ -515,7 +515,7 @@ async def get_grade_info(msg, grade): for chart in charts: music = (await total_list.get()).by_id(chart['song_id']) level = chart['level_index'] - chart_info.append(f"{music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") output_lines = '\n'.join(chart_info) condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" From da2fa4b874aabaffb54bbe812a02755293033721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 18:41:39 +0800 Subject: [PATCH 21/38] Update utils.py --- modules/maimai/libraries/utils.py | 37 ++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 059ba5cc..eed2a5c2 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -67,6 +67,20 @@ grade_conversion = { '里皆传': 'tgrade12', '裡皆傳': 'tgrade12', '裏皆傳': 'tgrade12', + 'expert初级': 'expert1', + 'expert初級': 'expert1', + 'expert中级': 'expert2', + 'expert中級': 'expert2', + 'expert上级': 'expert3', + 'expert上級': 'expert3', + 'master初级': 'master1', + 'master初級': 'master1', + 'master中级': 'master2', + 'master中級': 'master2', + 'master上级': 'master3', + 'master上級': 'master3', + 'master超上级': 'master4', + 'master超上級': 'master4', } score_to_rank = { @@ -493,7 +507,7 @@ async def get_grade_info(msg, grade): with open(file_path, 'r') as file: data = json.load(file) - if grade in list(grade_conversion.keys()): + if grade.lower() in list(grade_conversion.keys()): grade_key = grade_conversion[grade] else: await msg.finish("无效的段位") @@ -507,7 +521,7 @@ async def get_grade_info(msg, grade): chart_info = [] if grade_type != 'rgrade': - grade_data = data[grade_type][grade_key].get(grade_key) + grade_data = data[grade_type][grade_key] charts = grade_data["charts"] condition = grade_data["condition"] life = grade_data["life"] @@ -516,9 +530,20 @@ async def get_grade_info(msg, grade): music = (await total_list.get()).by_id(chart['song_id']) level = chart['level_index'] chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + + else: + grade_data = data[grade_type][grade_key] + base = grade_data["base"] + condition = grade_data["condition"] + level = grade_data['level_index'] + life = grade_data["life"] - output_lines = '\n'.join(chart_info) - condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" + for i in range(4): + music = (await total_list.get()).filter(ds=(base[0], base[1])) + chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") - res = f"以下为{grade}段位列表:\n{output_lines}\n血量上限:{life}\n{condition_info}" - return res + output_lines = '\n'.join(chart_info) + condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" + + res = f"以下为{grade}段位列表:\n{output_lines}\n血量上限:{life}\n{condition_info}" + return res From 2901dc9697833499d30a34867ecfaa78268539d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 18:50:05 +0800 Subject: [PATCH 22/38] Update utils.py --- modules/maimai/libraries/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index eed2a5c2..ea602d8b 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -527,9 +527,9 @@ async def get_grade_info(msg, grade): life = grade_data["life"] for chart in charts: - music = (await total_list.get()).by_id(chart['song_id']) + music = (await total_list.get()).by_id(str(chart['song_id'])) level = chart['level_index'] - chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + chart_info.append(f"{music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") else: grade_data = data[grade_type][grade_key] @@ -540,7 +540,7 @@ async def get_grade_info(msg, grade): for i in range(4): music = (await total_list.get()).filter(ds=(base[0], base[1])) - chart_info.append(f"{music.title}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + chart_info.append(f"{music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") output_lines = '\n'.join(chart_info) condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" From 74c91aac5e331f1c41e313269d489111ad3b8913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 19:00:28 +0800 Subject: [PATCH 23/38] Update utils.py --- modules/maimai/libraries/utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index ea602d8b..9e5a4799 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -529,18 +529,19 @@ async def get_grade_info(msg, grade): for chart in charts: music = (await total_list.get()).by_id(str(chart['song_id'])) level = chart['level_index'] - chart_info.append(f"{music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + chart_info.append(f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") else: grade_data = data[grade_type][grade_key] base = grade_data["base"] condition = grade_data["condition"] - level = grade_data['level_index'] + level = grade_data["level_index"] life = grade_data["life"] + music_data = (await total_list.get()).filter(ds=(base[0], base[1]), diff=[diffs[level]]) for i in range(4): - music = (await total_list.get()).filter(ds=(base[0], base[1])) - chart_info.append(f"{music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + music = music_data.random() + chart_info.append(f"music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") output_lines = '\n'.join(chart_info) condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" From 677a6777fc1d2cdbdabddb451873278e8bb77c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 19:04:03 +0800 Subject: [PATCH 24/38] fix --- modules/maimai/libraries/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 9e5a4799..d3b55e23 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -541,7 +541,7 @@ async def get_grade_info(msg, grade): for i in range(4): music = music_data.random() - chart_info.append(f"music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") + chart_info.append(f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") output_lines = '\n'.join(chart_info) condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" From 26986e0768900e81c919e2f499a60aaaaf05495e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 19:05:29 +0800 Subject: [PATCH 25/38] Update utils.py --- modules/maimai/libraries/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index d3b55e23..97d627c1 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -537,7 +537,7 @@ async def get_grade_info(msg, grade): condition = grade_data["condition"] level = grade_data["level_index"] life = grade_data["life"] - music_data = (await total_list.get()).filter(ds=(base[0], base[1]), diff=[diffs[level]]) + music_data = (await total_list.get()).filter(ds=(base[0], base[1]), diff=[level]) for i in range(4): music = music_data.random() From 0546572cd4cb3111e4cd4f9e1be420691fc0cc39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 19:17:07 +0800 Subject: [PATCH 26/38] Update utils.py --- modules/maimai/libraries/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 97d627c1..43a9efd6 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -507,7 +507,8 @@ async def get_grade_info(msg, grade): with open(file_path, 'r') as file: data = json.load(file) - if grade.lower() in list(grade_conversion.keys()): + grade = grade.lower() + if grade in list(grade_conversion.keys()): grade_key = grade_conversion[grade] else: await msg.finish("无效的段位") From c978e9bcfcf2cba3e312ef21a33b571d427c02c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 23:22:43 +0800 Subject: [PATCH 27/38] Update maimai grade --- modules/maimai/__init__.py | 3 +- modules/maimai/libraries/utils.py | 49 ++++++++++++++----------------- modules/maimai/locales/zh_cn.json | 7 +++-- modules/maimai/locales/zh_tw.json | 2 +- modules/maimai/regex.py | 8 ++++- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index 7fea7f5d..beca7522 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -447,8 +447,7 @@ async def _(msg: Bot.MessageSession, base: float, score: float): @mai.command('grade {{maimai.help.grade}}') async def _(msg: Bot.MessageSession, grade: str): - res = await get_grade_info(msg, grade) - await msg.finish(res) + await get_grade_info(msg, grade) @mai.command('update', required_superuser=True) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 43a9efd6..b5fc7544 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -67,20 +67,20 @@ grade_conversion = { '里皆传': 'tgrade12', '裡皆傳': 'tgrade12', '裏皆傳': 'tgrade12', - 'expert初级': 'expert1', - 'expert初級': 'expert1', - 'expert中级': 'expert2', - 'expert中級': 'expert2', - 'expert上级': 'expert3', - 'expert上級': 'expert3', - 'master初级': 'master1', - 'master初級': 'master1', - 'master中级': 'master2', - 'master中級': 'master2', - 'master上级': 'master3', - 'master上級': 'master3', - 'master超上级': 'master4', - 'master超上級': 'master4', + 'Expert初级': 'expert1', + 'Expert初級': 'expert1', + 'Expert中级': 'expert2', + 'Expert中級': 'expert2', + 'Expert上级': 'expert3', + 'Expert上級': 'expert3', + 'Master初级': 'master1', + 'Master初級': 'master1', + 'Master中级': 'master2', + 'Master中級': 'master2', + 'Master上级': 'master3', + 'Master上級': 'master3', + 'Master超上级': 'master4', + 'Master超上級': 'master4', } score_to_rank = { @@ -507,11 +507,11 @@ async def get_grade_info(msg, grade): with open(file_path, 'r') as file: data = json.load(file) - grade = grade.lower() - if grade in list(grade_conversion.keys()): - grade_key = grade_conversion[grade] + if grade.lower() in [key.lower() for key in grade_conversion.keys()]: + grade_key = grade_conversion[grade.lower()] + grade = next(k for k, v in grade_conversion.items() if v == grade_key) else: - await msg.finish("无效的段位") + await msg.finish(msg.locale.t('maimai.message.grade.grade_not_found')) if grade_key.startswith('tgrade'): grade_type = 'tgrade' @@ -521,11 +521,10 @@ async def get_grade_info(msg, grade): grade_type = 'rgrade' chart_info = [] + grade_data = data[grade_type][grade_key] + condition = grade_data["condition"] if grade_type != 'rgrade': - grade_data = data[grade_type][grade_key] charts = grade_data["charts"] - condition = grade_data["condition"] - life = grade_data["life"] for chart in charts: music = (await total_list.get()).by_id(str(chart['song_id'])) @@ -533,19 +532,15 @@ async def get_grade_info(msg, grade): chart_info.append(f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") else: - grade_data = data[grade_type][grade_key] base = grade_data["base"] - condition = grade_data["condition"] level = grade_data["level_index"] - life = grade_data["life"] music_data = (await total_list.get()).filter(ds=(base[0], base[1]), diff=[level]) for i in range(4): music = music_data.random() chart_info.append(f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") - output_lines = '\n'.join(chart_info) + content = '\n'.join(chart_info) condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" - res = f"以下为{grade}段位列表:\n{output_lines}\n血量上限:{life}\n{condition_info}" - return res + await msg.finish(msg.locale.t('maimai.message.grade', grade=grade, content=content, life=grade_data["life"], condition=condition_info)) \ No newline at end of file diff --git a/modules/maimai/locales/zh_cn.json b/modules/maimai/locales/zh_cn.json index f4f90ae8..43691d14 100644 --- a/modules/maimai/locales/zh_cn.json +++ b/modules/maimai/locales/zh_cn.json @@ -1,8 +1,9 @@ { "maimai.help.alias": "查询歌曲的别名。", - "maimai.help.b50": "查询 Maimai 用户的 B50 信息。", + "maimai.help.b50": "查询 Maimai 用户的 B50 列表。", "maimai.help.base": "根据定数或定数范围搜索歌曲。", "maimai.help.desc": "查询 Maimai 相关内容。", + "maimai.help.grade": "查询段位认定列表。", "maimai.help.id": "根据 ID 查询歌曲或谱面信息。", "maimai.help.info": "查询歌曲的相关谱面成绩,ID 需要加入前缀“id”,空格用“_”替代。", "maimai.help.level": "根据等级搜索歌曲。", @@ -32,6 +33,8 @@ "maimai.message.error.non_digital": "发生错误:歌曲 ID 必须为数字。", "maimai.message.forbidden": "此用户禁止了其他人获取数据。", "maimai.message.goal_invalid": "无效的目标评级,请检查输入。", + "maimai.message.grade": "以下为${grade}段位列表:\n${content}\n血量上限:${life}\n${condition}", + "maimai.message.grade.grade_not_found": "无效的段位,请检查输入。", "maimai.message.info.no_record": "未游玩过此谱面", "maimai.message.level": "以下为 ${level} 级的曲目列表:", "maimai.message.level_invalid": "无效的等级,请检查输入。", @@ -51,7 +54,7 @@ "maimai.message.process.less_than_8": "歌曲等级必须大于 8 级。", "maimai.message.random.error": "发生错误:随机歌曲失败,请检查输入。", "maimai.message.rank": "截至 ${time},\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}。\n${user} 的分数为 ${rating},排名为 #${rank},\n已经超越了 ${surpassing_rate}% 的玩家。", - "maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%),\nBREAK 2550(一共 ${brk} 个)等价于 ${b2t_2550_great} 个 TAP GREAT(-${b2t_2550_great_prop}%),\nBREAK 2000(一共 ${brk} 个)等价于 ${b2t_2000_great} 个 TAP GREAT(-${b2t_2000_great_prop}%)", + "maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%),\nBREAK 2550(一共 ${brk} 个)相当于 ${b2t_2550_great} 个 TAP GREAT(-${b2t_2550_great_prop}%),\nBREAK 2000(一共 ${brk} 个)相当于 ${b2t_2000_great} 个 TAP GREAT(-${b2t_2000_great_prop}%)", "maimai.message.scoreline.error": "发生错误:计算结果失败,请检查输入。", "maimai.message.scorelist": "以下为 ${user} 的 ${level} 级成绩列表:", "maimai.message.search": "“${keyword}”的搜索结果:", diff --git a/modules/maimai/locales/zh_tw.json b/modules/maimai/locales/zh_tw.json index 40c8dd19..657787f7 100644 --- a/modules/maimai/locales/zh_tw.json +++ b/modules/maimai/locales/zh_tw.json @@ -1,6 +1,6 @@ { "maimai.help.alias": "查詢歌曲的別名。", - "maimai.help.b50": "查詢 Maimai 使用者的 B50 資訊。", + "maimai.help.b50": "查詢 Maimai 使用者的 B50 列表。", "maimai.help.base": "依據定數或定數範圍內搜尋歌曲。", "maimai.help.desc": "查詢 Maimai 相關的內容。", "maimai.help.id": "依據 ID 查詢歌曲或譜面資訊。", diff --git a/modules/maimai/regex.py b/modules/maimai/regex.py index 5a9c57e4..eaf3b07b 100644 --- a/modules/maimai/regex.py +++ b/modules/maimai/regex.py @@ -205,4 +205,10 @@ async def _(msg: Bot.MessageSession): img = await msgchain2image([Plain(output)], msg) await msg.finish([BImage(img)]) else: - await msg.finish(output.strip()) \ No newline at end of file + await msg.finish(output.strip()) + + +@mai_regex.regex(re.compile(r"(.+)\s?段位[认認]定表"), desc='{maimai.help.maimai_regex.grade}') +async def _(msg: Bot.MessageSession): + grade = msg.matched_msg.groups()[0] + await get_grade_info(msg, grade) \ No newline at end of file From adba3132e7aa8bc506afd00c57f033b1ab5852ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sat, 30 Dec 2023 23:40:20 +0800 Subject: [PATCH 28/38] fix --- modules/maimai/libraries/utils.py | 19 ++++++++++--------- modules/maimai/regex.py | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index b5fc7544..4c3bcbf7 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -12,7 +12,7 @@ JINGLEBELL_SONG_ID = 70 assets_path = os.path.abspath('./assets/maimai') total_list = TotalList() -plate_to_version = { +plate_conversion = { '初': 'maimai', '真': 'maimai PLUS', '超': 'maimai GreeN', @@ -168,7 +168,7 @@ async def get_rank(msg, payload): async def get_player_score(msg, payload, input_id): - payload['version'] = list(set(version for version in plate_to_version.values())) # 全版本 + payload['version'] = list(set(version for version in plate_conversion.values())) # 全版本 res = await get_plate(msg, payload) # 获取用户成绩信息 verlist = res["verlist"] @@ -215,7 +215,7 @@ async def get_level_process(msg, payload, process, goal): song_played = [] song_remain = [] - payload['version'] = list(set(version for version in plate_to_version.values())) # 全版本 + payload['version'] = list(set(version for version in plate_conversion.values())) # 全版本 res = await get_plate(msg, payload) # 获取用户成绩信息 verlist = res["verlist"] @@ -290,7 +290,7 @@ async def get_score_list(msg, payload, level): player_data = await get_record(msg, payload) username = player_data['username'] - payload['version'] = list(set(version for version in plate_to_version.values())) # 全版本 + payload['version'] = list(set(version for version in plate_conversion.values())) # 全版本 res = await get_plate(msg, payload) # 获取用户成绩信息 verlist = res["verlist"] @@ -335,9 +335,9 @@ async def get_plate_process(msg, payload, plate): if version == '真': # 真代为无印版本 payload['version'] = ['maimai', 'maimai PLUS'] elif version in ['霸', '舞']: # 霸者和舞牌需要全版本 - payload['version'] = list(set(version for version in list(plate_to_version.values())[:-9])) - elif version in plate_to_version and version != '初': # “初”不是版本名称 - payload['version'] = [plate_to_version[version]] + payload['version'] = list(set(version for version in list(plate_conversion.values())[:-9])) + elif version in plate_conversion and version != '初': # “初”不是版本名称 + payload['version'] = [plate_conversion[version]] else: await msg.finish(msg.locale.t('maimai.message.plate.plate_not_found')) @@ -508,8 +508,9 @@ async def get_grade_info(msg, grade): data = json.load(file) if grade.lower() in [key.lower() for key in grade_conversion.keys()]: - grade_key = grade_conversion[grade.lower()] - grade = next(k for k, v in grade_conversion.items() if v == grade_key) + lowerconv = {k.lower(): v for k, v in grade_conversion.items()} # 将字典的所有键转为小写 + grade_key = lowerconv.get(grade.lower(), None) # 获取json内的键名 + grade = next(k for k, v in grade_conversion.items() if v == grade_key) # 获取原始段位名 else: await msg.finish(msg.locale.t('maimai.message.grade.grade_not_found')) diff --git a/modules/maimai/regex.py b/modules/maimai/regex.py index eaf3b07b..f34a8c44 100644 --- a/modules/maimai/regex.py +++ b/modules/maimai/regex.py @@ -7,7 +7,7 @@ from core.logger import Logger from core.utils.image import msgchain2image from modules.maimai.libraries.apidata import get_alias, get_info, search_by_alias from modules.maimai.libraries.music import get_cover_len5_id, TotalList -from modules.maimai.libraries.utils import get_level_process, get_plate_process, get_player_score +from modules.maimai.libraries.utils import get_grade_info, get_level_process, get_plate_process, get_player_score goal_list = ["A", "AA", "AAA", "S", "S+", "SS", "SS+", "SSS", "SSS+", "FC", "FC+", "AP", "AP+", "FS", "FS+", "FDX", "FDX+"] From 1c412b801cab1fd041d1320128cc6a4f4fdbbb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sun, 31 Dec 2023 00:43:42 +0800 Subject: [PATCH 29/38] update maimai utils --- modules/maimai/libraries/utils.py | 86 +++++++++++++++++++------------ 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 4c3bcbf7..02da8bdb 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -62,25 +62,27 @@ grade_conversion = { '真八段': 'tgrade8', '真九段': 'tgrade9', '真十段': 'tgrade10', + '真皆伝': 'tgrade11', '真皆传': 'tgrade11', '真皆傳': 'tgrade11', '里皆传': 'tgrade12', + '裏皆伝': 'tgrade12', '裡皆傳': 'tgrade12', '裏皆傳': 'tgrade12', - 'Expert初级': 'expert1', - 'Expert初級': 'expert1', - 'Expert中级': 'expert2', - 'Expert中級': 'expert2', - 'Expert上级': 'expert3', - 'Expert上級': 'expert3', - 'Master初级': 'master1', - 'Master初級': 'master1', - 'Master中级': 'master2', - 'Master中級': 'master2', - 'Master上级': 'master3', - 'Master上級': 'master3', - 'Master超上级': 'master4', - 'Master超上級': 'master4', + 'EXPERT初級': 'expert1', + 'EXPERT初级': 'expert1', + 'EXPERT中級': 'expert2', + 'EXPERT中级': 'expert2', + 'EXPERT上級': 'expert3', + 'EXPERT上级': 'expert3', + 'MASTER初級': 'master1', + 'MASTER初级': 'master1', + 'MASTER中級': 'master2', + 'MASTER中级': 'master2', + 'MASTER上級': 'master3', + 'MASTER上级': 'master3', + 'MASTER超上級': 'master4', + 'MASTER超上级': 'master4', } score_to_rank = { @@ -130,6 +132,16 @@ combo_rank = list(combo_conversion.keys()) # Combo字典的键(API内显示 sync_rank = list(sync_conversion.keys()) # Sync字典的键(API内显示) +def key_process(input_key, conv_dict): + key = next((k for k, v in conv_dict.items() if input_key == k), None) + if key is not None: + value = conv_dict[key] + new_key = next((k for k, v in conv_dict.items() if v == value), None) + return value, new_key + else: + return None, input_key + + async def get_rank(msg, payload): time = msg.ts2strftime(datetime.now().timestamp(), timezone=False) @@ -328,14 +340,23 @@ async def get_plate_process(msg, payload, plate): song_remain_remaster = [] song_remain_difficult = [] + version_mapping = {'霸': '覇', '晓': '暁', '樱': '櫻', '堇': '菫', '辉': '輝', '华': '華'} + goal_mapping = {'将': '將', '极': '極'} + version = plate[0] goal = plate[1:] get_img = False + if version in version_mapping: + version = version_mapping[version] + + if goal in goal_mapping: + goal = goal_mapping[goal] + if version == '真': # 真代为无印版本 payload['version'] = ['maimai', 'maimai PLUS'] - elif version in ['霸', '舞']: # 霸者和舞牌需要全版本 - payload['version'] = list(set(version for version in list(plate_conversion.values())[:-9])) + elif version in ['覇', '舞']: # 霸者和舞牌需要全版本 + payload['version'] = list(set(ver for ver in list(plate_conversion.values())[:-9])) elif version in plate_conversion and version != '初': # “初”不是版本名称 payload['version'] = [plate_conversion[version]] else: @@ -344,7 +365,7 @@ async def get_plate_process(msg, payload, plate): res = await get_plate(msg, payload) # 获取用户成绩信息 verlist = res["verlist"] - if goal in ['将', '者']: + if goal in ['將', '者']: for song in verlist: # 将剩余歌曲ID和难度加入目标列表 if song['level_index'] == 0 and song['achievements'] < (100.0 if goal == '将' else 80.0): song_remain_basic.append([song['id'], song['level_index']]) @@ -354,12 +375,11 @@ async def get_plate_process(msg, payload, plate): song_remain_expert.append([song['id'], song['level_index']]) if song['level_index'] == 3 and song['achievements'] < (100.0 if goal == '将' else 80.0): song_remain_master.append([song['id'], song['level_index']]) - if version in [ - '舞', '霸'] and song['level_index'] == 4 and song['achievements'] < ( - 100.0 if goal == '将' else 80.0): + if version in ['舞', '覇'] and song['level_index'] == 4 and song['achievements'] < ( + 100.0 if goal == '將' else 80.0): song_remain_remaster.append([song['id'], song['level_index']]) # 霸者和舞牌需要Re:MASTER难度 song_played.append([song['id'], song['level_index']]) - elif goal in ['極', '极']: + elif goal == '極': for song in verlist: # 将剩余歌曲ID和难度加入目标列表 if song['level_index'] == 0 and not song['fc']: song_remain_basic.append([song['id'], song['level_index']]) @@ -411,7 +431,7 @@ async def get_plate_process(msg, payload, plate): song_remain_expert.append([int(music.id), 2]) if [int(music.id), 3] not in song_played: song_remain_master.append([int(music.id), 3]) - if version in ['舞', '霸'] and len(music.level) == 5 and [int(music.id), 4] not in song_played: + if version in ['舞', '覇'] and len(music.level) == 5 and [int(music.id), 4] not in song_played: song_remain_remaster.append([int(music.id), 4]) song_remain_basic = sorted(song_remain_basic, key=lambda i: int(i[0])) # 根据ID排序结果 song_remain_advanced = sorted(song_remain_advanced, key=lambda i: int(i[0])) @@ -441,7 +461,7 @@ async def get_plate_process(msg, payload, plate): song_remain_expert=len(song_remain_expert), song_remain_master=len(song_remain_master)) - if version in ['舞', '霸']: # 霸者和舞牌需要Re:MASTER难度 + if version in ['舞', '覇']: # 霸者和舞牌需要Re:MASTER难度 prompt += msg.locale.t('maimai.message.plate.remaster', song_remain_remaster=len(song_remain_remaster)) prompt += msg.locale.t('message.end') @@ -457,9 +477,9 @@ async def get_plate_process(msg, payload, plate): self_record = '' if [int(s[0]), s[-2]] in song_record: # 显示剩余13+以上歌曲信息 record_index = song_record.index([int(s[0]), s[-2]]) - if goal in ['将', '者']: + if goal in ['將', '者']: self_record = str(verlist[record_index]['achievements']) + '%' - elif goal in ['極', '极', '神']: + elif goal in ['極', '神']: if verlist[record_index]['fc']: self_record = comboRank[combo_rank.index(verlist[record_index]['fc'])] elif goal == '舞舞': @@ -482,9 +502,9 @@ async def get_plate_process(msg, payload, plate): self_record = '' if [int(s[0]), s[-2]] in song_record: # 显示剩余歌曲信息 record_index = song_record.index([int(s[0]), s[-2]]) - if goal in ['将', '者']: + if goal in ['將', '者']: self_record = str(verlist[record_index]['achievements']) + '%' - elif goal in ['極', '极', '神']: + elif goal in ['極', '神']: if verlist[record_index]['fc']: self_record = comboRank[combo_rank.index(verlist[record_index]['fc'])] elif goal == '舞舞': @@ -507,14 +527,12 @@ async def get_grade_info(msg, grade): with open(file_path, 'r') as file: data = json.load(file) - if grade.lower() in [key.lower() for key in grade_conversion.keys()]: - lowerconv = {k.lower(): v for k, v in grade_conversion.items()} # 将字典的所有键转为小写 - grade_key = lowerconv.get(grade.lower(), None) # 获取json内的键名 - grade = next(k for k, v in grade_conversion.items() if v == grade_key) # 获取原始段位名 - else: - await msg.finish(msg.locale.t('maimai.message.grade.grade_not_found')) + grade = grade.upper() # 输入强制转换为大写以适配字典 + grade_key, grade = key_process(grade, grade_conversion) - if grade_key.startswith('tgrade'): + if not grade_key: + await msg.finish(msg.locale.t('maimai.message.grade.grade_not_found')) + elif grade_key.startswith('tgrade'): grade_type = 'tgrade' elif grade_key.startswith('grade'): grade_type = 'grade' From de831ed0f4df0505aba0633dbd772a292d8d45df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sun, 31 Dec 2023 00:46:51 +0800 Subject: [PATCH 30/38] update --- modules/maimai/libraries/utils.py | 2 +- modules/maimai/locales/zh_cn.json | 4 ++-- modules/maimai/locales/zh_tw.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 02da8bdb..20f7bc1d 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -349,9 +349,9 @@ async def get_plate_process(msg, payload, plate): if version in version_mapping: version = version_mapping[version] - if goal in goal_mapping: goal = goal_mapping[goal] + plate = version + goal if version == '真': # 真代为无印版本 payload['version'] = ['maimai', 'maimai PLUS'] diff --git a/modules/maimai/locales/zh_cn.json b/modules/maimai/locales/zh_cn.json index 43691d14..ba31805f 100644 --- a/modules/maimai/locales/zh_cn.json +++ b/modules/maimai/locales/zh_cn.json @@ -33,14 +33,14 @@ "maimai.message.error.non_digital": "发生错误:歌曲 ID 必须为数字。", "maimai.message.forbidden": "此用户禁止了其他人获取数据。", "maimai.message.goal_invalid": "无效的目标评级,请检查输入。", - "maimai.message.grade": "以下为${grade}段位列表:\n${content}\n血量上限:${life}\n${condition}", + "maimai.message.grade": "以下为 ${grade} 段位列表:\n${content}\n血量上限:${life}\n${condition}", "maimai.message.grade.grade_not_found": "无效的段位,请检查输入。", "maimai.message.info.no_record": "未游玩过此谱面", "maimai.message.level": "以下为 ${level} 级的曲目列表:", "maimai.message.level_invalid": "无效的等级,请检查输入。", "maimai.message.music_not_found": "未找到符合要求的歌曲。", "maimai.message.no_username": "请提供用户名!", - "maimai.message.plate": "您的${plate}剩余进度如下:\nBasic 剩余 ${song_remain_basic} 首,\nAdvanced 剩余 ${song_remain_advanced} 首,\nExpert 剩余 ${song_remain_expert} 首,\nMaster 剩余 ${song_remain_master} 首", + "maimai.message.plate": "您的 ${plate} 剩余进度如下:\nBasic 剩余 ${song_remain_basic} 首,\nAdvanced 剩余 ${song_remain_advanced} 首,\nExpert 剩余 ${song_remain_expert} 首,\nMaster 剩余 ${song_remain_master} 首", "maimai.message.plate.completed": "您已完成${plate}的所有进度。", "maimai.message.plate.difficult": "您还有 ${song_remain} 首等级大于 13+ 的曲目。", "maimai.message.plate.difficult.completed": "您已完成所有等级大于 13+ 的曲目。", diff --git a/modules/maimai/locales/zh_tw.json b/modules/maimai/locales/zh_tw.json index 657787f7..f7994155 100644 --- a/modules/maimai/locales/zh_tw.json +++ b/modules/maimai/locales/zh_tw.json @@ -37,7 +37,7 @@ "maimai.message.level_invalid": "無效的等級,請校對輸入。", "maimai.message.music_not_found": "未找到符合要求的歌曲。", "maimai.message.no_username": "請提供使用者名稱!", - "maimai.message.plate": "您的${plate}剩餘進度如下:\nBasic 剩餘 ${song_remain_basic} 首,\nAdvanced 剩餘 ${song_remain_advanced} 首,\nExpert 剩餘 ${song_remain_expert} 首,\nMaster 剩餘 ${song_remain_master} 首", + "maimai.message.plate": "您的 ${plate} 剩餘進度如下:\nBasic 剩餘 ${song_remain_basic} 首,\nAdvanced 剩餘 ${song_remain_advanced} 首,\nExpert 剩餘 ${song_remain_expert} 首,\nMaster 剩餘 ${song_remain_master} 首", "maimai.message.plate.completed": "您已完成${plate}的所有進度。", "maimai.message.plate.difficult": "您還有 ${song_remain} 首等級大於 13+ 的曲目。", "maimai.message.plate.difficult.completed": "您已完成所有等級大於 13+ 的曲目。", From 2c4c835fd13a8499010e3f534793b875d65ac13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sun, 31 Dec 2023 00:49:48 +0800 Subject: [PATCH 31/38] fix --- modules/maimai/libraries/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 20f7bc1d..364b6526 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -65,8 +65,8 @@ grade_conversion = { '真皆伝': 'tgrade11', '真皆传': 'tgrade11', '真皆傳': 'tgrade11', - '里皆传': 'tgrade12', '裏皆伝': 'tgrade12', + '里皆传': 'tgrade12', '裡皆傳': 'tgrade12', '裏皆傳': 'tgrade12', 'EXPERT初級': 'expert1', From 2484038ffe0d9d991830b24aa1d43c3ae04b0cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sun, 31 Dec 2023 01:12:22 +0800 Subject: [PATCH 32/38] Update locale --- modules/maimai/locales/zh_cn.json | 3 ++- modules/maimai/locales/zh_tw.json | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/maimai/locales/zh_cn.json b/modules/maimai/locales/zh_cn.json index ba31805f..5f4cb2dc 100644 --- a/modules/maimai/locales/zh_cn.json +++ b/modules/maimai/locales/zh_cn.json @@ -13,6 +13,7 @@ "maimai.help.maimai_regex.plate": "<名牌板>进度 [<用户名>] 查看用户的名牌板完成进度。", "maimai.help.maimai_regex.process": "<难度> <目标>进度 [<用户名>] 查看用户在对应等级的评价完成进度。", "maimai.help.maimai_regex.random": "随个[dx|标准][绿黄红紫白]<难度> 随机一首指定条件的歌曲。", + "maimai.help.maimai_regex.grade": "<段位>段位认定表 输入段位名查询段位认定列表。", "maimai.help.maimai_regex.song": "是什么歌 输入 ID 或别名查询歌曲信息,ID 需要加入前缀“id”。", "maimai.help.plate": "查看用户的名牌板完成进度。", "maimai.help.process": "查看用户在对应等级的评价完成进度。", @@ -33,7 +34,7 @@ "maimai.message.error.non_digital": "发生错误:歌曲 ID 必须为数字。", "maimai.message.forbidden": "此用户禁止了其他人获取数据。", "maimai.message.goal_invalid": "无效的目标评级,请检查输入。", - "maimai.message.grade": "以下为 ${grade} 段位列表:\n${content}\n血量上限:${life}\n${condition}", + "maimai.message.grade": "以下为 ${grade} 段位认定列表:\n${content}\n生命上限:${life}\n${condition}", "maimai.message.grade.grade_not_found": "无效的段位,请检查输入。", "maimai.message.info.no_record": "未游玩过此谱面", "maimai.message.level": "以下为 ${level} 级的曲目列表:", diff --git a/modules/maimai/locales/zh_tw.json b/modules/maimai/locales/zh_tw.json index f7994155..7cfa1d8f 100644 --- a/modules/maimai/locales/zh_tw.json +++ b/modules/maimai/locales/zh_tw.json @@ -6,8 +6,10 @@ "maimai.help.id": "依據 ID 查詢歌曲或譜面資訊。", "maimai.help.info": "查詢歌曲的相關譜面成績,ID 需要加入前綴「id」,空白用「_」取代。", "maimai.help.level": "依據等級搜尋歌曲。", + "maimai.help.grade": "查詢段位認定列表。", "maimai.help.maimai_regex.alias": " 有什麼別名 查詢歌曲的別名。", "maimai.help.maimai_regex.desc": "更方便地使用 Maimai 相關指令。", + "maimai.help.maimai_regex.grade": "<段位>段位認定表 輸入段位名查詢段位認定列表。", "maimai.help.maimai_regex.info": "有什麼分 [<使用者名稱>] 輸入 ID 或別名查詢歌曲相關譜面成績,ID 需要加入前綴「id」,空白用「_」取代。", "maimai.help.maimai_regex.plate": "<名牌板>進度 [<使用者名稱>] 查看使用者的名牌板完成進度。", "maimai.help.maimai_regex.process": "<難度> <目標>進度 [<使用者名稱>] 查看使用者在對應等級的評價完成進度。", @@ -32,6 +34,8 @@ "maimai.message.error.non_digital": "發生錯誤:歌曲 ID 必須為數字!", "maimai.message.forbidden": "此使用者禁止了其他人取得資料。", "maimai.message.goal_invalid": "無效的目標評級,請校對輸入。", + "maimai.message.grade": "以下為 ${grade} 段位認定列表:\n${content}\n生命上限:${life}\n${condition}", + "maimai.message.grade.grade_not_found": "無效的段位,請校對輸入。", "maimai.message.info.no_record": "未遊玩過此譜面", "maimai.message.level": "以下為難度 ${level} 的曲目列表:", "maimai.message.level_invalid": "無效的等級,請校對輸入。", From 253d29c4186642e9875992fdc3c1483ba2a1c724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Mon, 1 Jan 2024 10:00:31 +0800 Subject: [PATCH 33/38] Update __init__.py --- modules/maimai/__init__.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index beca7522..4909f766 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -1,4 +1,3 @@ -import math import traceback from config import Config @@ -161,6 +160,11 @@ async def _(msg: Bot.MessageSession, sid: str): await msg.finish([Plain(result.strip())]) +@mai.command('grade {{maimai.help.grade}}') +async def _(msg: Bot.MessageSession, grade: str): + await get_grade_info(msg, grade) + + @mai.command('b50 [] {{maimai.help.b50}}') async def _(msg: Bot.MessageSession, username: str = None): if not username and msg.target.sender_from == "QQ": @@ -445,11 +449,6 @@ async def _(msg: Bot.MessageSession, base: float, score: float): await msg.finish([Plain(max(0, computeRa(base, score)))]) -@mai.command('grade {{maimai.help.grade}}') -async def _(msg: Bot.MessageSession, grade: str): - await get_grade_info(msg, grade) - - @mai.command('update', required_superuser=True) async def _(msg: Bot.MessageSession): if await update_alias() and await update_covers(): @@ -465,4 +464,4 @@ async def _(): await update_alias() except Exception: if Config('debug'): - Logger.error(traceback.format_exc()) \ No newline at end of file + Logger.error(traceback.format_exc()) From b074524467579d00f8a68a461e880c469c2efeb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Mon, 1 Jan 2024 16:32:32 +0800 Subject: [PATCH 34/38] update maimai --- modules/maimai/__init__.py | 2 +- modules/maimai/regex.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/maimai/__init__.py b/modules/maimai/__init__.py index 4909f766..ca9dede7 100644 --- a/modules/maimai/__init__.py +++ b/modules/maimai/__init__.py @@ -285,7 +285,7 @@ async def _(msg: Bot.MessageSession, plate: str, username: str = None): await msg.finish(msg.locale.t("maimai.message.no_username")) payload = {'username': username} - if plate == '真将' or (plate[1] == '者' and plate[0] != '霸'): + if plate in ['真将', '真將'] or (plate[1] == '者' and plate[0] != '霸'): await msg.finish(msg.locale.t('maimai.message.plate.plate_not_found')) output, get_img = await get_plate_process(msg, payload, plate) diff --git a/modules/maimai/regex.py b/modules/maimai/regex.py index f34a8c44..9cf5c4d5 100644 --- a/modules/maimai/regex.py +++ b/modules/maimai/regex.py @@ -163,7 +163,7 @@ async def _(msg: Bot.MessageSession): await msg.finish(msg.locale.t("maimai.message.no_username")) payload = {'username': username} - if plate == '真将' or (plate[1] == '者' and plate[0] != '霸'): + if plate in ['真将', '真將'] or (plate[1] == '者' and plate[0] != '霸'): return output, get_img = await get_plate_process(msg, payload, plate) @@ -208,7 +208,7 @@ async def _(msg: Bot.MessageSession): await msg.finish(output.strip()) -@mai_regex.regex(re.compile(r"(.+)\s?段位[认認]定表"), desc='{maimai.help.maimai_regex.grade}') +@mai_regex.regex(re.compile(r"(.+)\s?段位[认認]定列?表"), desc='{maimai.help.maimai_regex.grade}') async def _(msg: Bot.MessageSession): grade = msg.matched_msg.groups()[0] await get_grade_info(msg, grade) \ No newline at end of file From 92b060fdc7fb1264e317245258bf5e4d60d494e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Mon, 1 Jan 2024 16:50:27 +0800 Subject: [PATCH 35/38] fix mai plate --- modules/maimai/libraries/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/maimai/libraries/utils.py b/modules/maimai/libraries/utils.py index 364b6526..351a671e 100644 --- a/modules/maimai/libraries/utils.py +++ b/modules/maimai/libraries/utils.py @@ -367,13 +367,13 @@ async def get_plate_process(msg, payload, plate): if goal in ['將', '者']: for song in verlist: # 将剩余歌曲ID和难度加入目标列表 - if song['level_index'] == 0 and song['achievements'] < (100.0 if goal == '将' else 80.0): + if song['level_index'] == 0 and song['achievements'] < (100.0 if goal == '將' else 80.0): song_remain_basic.append([song['id'], song['level_index']]) - if song['level_index'] == 1 and song['achievements'] < (100.0 if goal == '将' else 80.0): + if song['level_index'] == 1 and song['achievements'] < (100.0 if goal == '將' else 80.0): song_remain_advanced.append([song['id'], song['level_index']]) - if song['level_index'] == 2 and song['achievements'] < (100.0 if goal == '将' else 80.0): + if song['level_index'] == 2 and song['achievements'] < (100.0 if goal == '將' else 80.0): song_remain_expert.append([song['id'], song['level_index']]) - if song['level_index'] == 3 and song['achievements'] < (100.0 if goal == '将' else 80.0): + if song['level_index'] == 3 and song['achievements'] < (100.0 if goal == '將' else 80.0): song_remain_master.append([song['id'], song['level_index']]) if version in ['舞', '覇'] and song['level_index'] == 4 and song['achievements'] < ( 100.0 if goal == '將' else 80.0): From a7d69391d843de3e23ce44d21758d49b2c1992ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Mon, 1 Jan 2024 17:10:46 +0800 Subject: [PATCH 36/38] update locale --- modules/maimai/libraries/apidata.py | 5 ++++- modules/maimai/locales/zh_cn.json | 1 + modules/maimai/locales/zh_tw.json | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/maimai/libraries/apidata.py b/modules/maimai/libraries/apidata.py index 52007ff5..468de5ac 100644 --- a/modules/maimai/libraries/apidata.py +++ b/modules/maimai/libraries/apidata.py @@ -112,7 +112,10 @@ async def get_record(msg, payload): else: await msg.finish(msg.locale.t("maimai.message.user_not_found")) elif str(e).startswith('403'): - await msg.finish(msg.locale.t("maimai.message.forbidden")) + if "qq" in payload: + await msg.finish(msg.locale.t("maimai.message.forbidden.eula")) + else: + await msg.finish(msg.locale.t("maimai.message.forbidden")) else: traceback.print_exc() diff --git a/modules/maimai/locales/zh_cn.json b/modules/maimai/locales/zh_cn.json index 5f4cb2dc..0df3adad 100644 --- a/modules/maimai/locales/zh_cn.json +++ b/modules/maimai/locales/zh_cn.json @@ -33,6 +33,7 @@ "maimai.message.chart_not_found": "未找到符合要求的谱面。", "maimai.message.error.non_digital": "发生错误:歌曲 ID 必须为数字。", "maimai.message.forbidden": "此用户禁止了其他人获取数据。", + "maimai.message.forbidden.eula": "无法获取数据,请前往查分器并同意用户协议。\n查分器地址:https://www.diving-fish.com/maimaidx/prober", "maimai.message.goal_invalid": "无效的目标评级,请检查输入。", "maimai.message.grade": "以下为 ${grade} 段位认定列表:\n${content}\n生命上限:${life}\n${condition}", "maimai.message.grade.grade_not_found": "无效的段位,请检查输入。", diff --git a/modules/maimai/locales/zh_tw.json b/modules/maimai/locales/zh_tw.json index 7cfa1d8f..46356293 100644 --- a/modules/maimai/locales/zh_tw.json +++ b/modules/maimai/locales/zh_tw.json @@ -32,7 +32,8 @@ "maimai.message.base.range": "以下為定數 ${constant}-${constant_max} 的曲目列表:", "maimai.message.chart_not_found": "未找到符合要求的譜面。", "maimai.message.error.non_digital": "發生錯誤:歌曲 ID 必須為數字!", - "maimai.message.forbidden": "此使用者禁止了其他人取得資料。", + "maimai.message.forbidden": "此使用者禁止了其他人取得資訊。", + "maimai.message.forbidden.eula": "無法取得資訊,請前往查分器並同意使用者協議。\n查分器網址:https://www.diving-fish.com/maimaidx/prober", "maimai.message.goal_invalid": "無效的目標評級,請校對輸入。", "maimai.message.grade": "以下為 ${grade} 段位認定列表:\n${content}\n生命上限:${life}\n${condition}", "maimai.message.grade.grade_not_found": "無效的段位,請校對輸入。", From b37eef5ebd8292564330d3c7c3a4721b97125f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Mon, 1 Jan 2024 19:02:40 +0800 Subject: [PATCH 37/38] fix --- modules/maimai/libraries/apidata.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/maimai/libraries/apidata.py b/modules/maimai/libraries/apidata.py index 468de5ac..e2f71f8d 100644 --- a/modules/maimai/libraries/apidata.py +++ b/modules/maimai/libraries/apidata.py @@ -136,8 +136,9 @@ async def get_plate(msg, payload): else: await msg.finish(msg.locale.t("maimai.message.user_not_found")) elif str(e).startswith('403'): - await msg.finish(msg.locale.t("maimai.message.forbidden")) - else: - traceback.print_exc() + if "qq" in payload: + await msg.finish(msg.locale.t("maimai.message.forbidden.eula")) + else: + await msg.finish(msg.locale.t("maimai.message.forbidden")) return data From 3f28da170d53f489545839849582708cf5322b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Mon, 1 Jan 2024 19:06:33 +0800 Subject: [PATCH 38/38] Update best50.py --- modules/maimai/libraries/best50.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/maimai/libraries/best50.py b/modules/maimai/libraries/best50.py index e92bb349..90c9648a 100644 --- a/modules/maimai/libraries/best50.py +++ b/modules/maimai/libraries/best50.py @@ -411,7 +411,10 @@ async def generate(msg, payload) -> Tuple[Optional[Image.Image], bool]: else: await msg.finish(msg.locale.t("maimai.message.user_not_found")) elif str(e).startswith('403'): - await msg.finish(msg.locale.t("maimai.message.forbidden")) + if "qq" in payload: + await msg.finish(msg.locale.t("maimai.message.forbidden.eula")) + else: + await msg.finish(msg.locale.t("maimai.message.forbidden")) else: raise