diff --git a/LittlePaimon/manager/plugin_manager/model.py b/LittlePaimon/manager/plugin_manager/model.py index 749a3f2..147affd 100644 --- a/LittlePaimon/manager/plugin_manager/model.py +++ b/LittlePaimon/manager/plugin_manager/model.py @@ -58,4 +58,8 @@ class Config(BaseModel): ssbq_end: int = Field(6, alias='实时便签停止检查结束时间') ssbq_check: int = Field(16, alias='实时便签检查间隔') - AI_voice_cooldown: int = Field(10, alias='原神AI语音合成冷却时间(秒)') + AI_voice_cooldown: int = Field(10, alias='原神语音合成冷却') + + ys_auto_update: int = Field(24, alia='ys自动更新小时') + ysa_auto_update: int = Field(24, alia='ysa自动更新小时') + ysd_auto_update: int = Field(6, alia='ysd自动更新小时') diff --git a/LittlePaimon/plugins/Paimon_DailyNote/draw.py b/LittlePaimon/plugins/Paimon_DailyNote/draw.py index 41563eb..90180d1 100644 --- a/LittlePaimon/plugins/Paimon_DailyNote/draw.py +++ b/LittlePaimon/plugins/Paimon_DailyNote/draw.py @@ -28,7 +28,7 @@ async def draw_daily_note_card(data, uid): # 宝钱文字 await bg_img.text(f"{data['current_home_coin']}/{data['max_home_coin']}", 337, 701, fm.get('number.ttf', 48), 'white') - await bg_img.draw_ring((266, 266), (98, 369), percent=data['current_home_coin'] / data['max_home_coin'] if data['max_home_coin'] != 0 else 1, width=0.18, colors=['#507bd0', '#FFFFFF']) + await bg_img.draw_ring((266, 266), (98, 593), percent=(data['current_home_coin'] / data['max_home_coin']) if data['max_home_coin'] != 0 else 1, width=0.18, colors=['#507bd0', '#FFFFFF']) if data['current_home_coin'] == data['max_home_coin']: await bg_img.text("洞天宝钱满了哦~", 820, 701, fm.get('优设标题黑.ttf', 40), 'white') else: diff --git a/LittlePaimon/plugins/Paimon_Info/__init__.py b/LittlePaimon/plugins/Paimon_Info/__init__.py index c24bec4..a9c8edf 100644 --- a/LittlePaimon/plugins/Paimon_Info/__init__.py +++ b/LittlePaimon/plugins/Paimon_Info/__init__.py @@ -1,6 +1,6 @@ from nonebot import on_command, on_regex from nonebot.adapters.onebot.v11 import Message, MessageEvent, MessageSegment -from nonebot.params import Arg, RegexDict +from nonebot.params import Arg, RegexDict, CommandArg from nonebot.plugin import PluginMetadata from LittlePaimon import NICKNAME @@ -60,15 +60,23 @@ ysd = on_command('ysd', aliases={'角色详情', '角色信息', '角色面板'} }) update_info = on_command('udi', aliases={'更新角色信息', '更新面板', '更新玩家信息'}, priority=10, block=True, state={ 'pm_name': 'udi', - 'pm_description': '更新你的原神玩家和角色数据,绑定cookie后数据更详细', - 'pm_usage': '更新角色信息(uid)', + 'pm_description': '更新你的原神玩家和角色数据,绑定cookie后数据更详细,加上"天赋"可以更新天赋等级', + 'pm_usage': '更新角色信息[天赋](uid)', 'pm_priority': 6 }) -add_alias = on_regex(rf'((?P{CHARA_RE})是[我俺咱]的?(?P\w+))|([我俺咱]的?(?P\w+)[是叫名](?P{CHARA_RE}))', priority=10, block=True, state={ - 'pm_name': '角色别名设置', - 'pm_description': '设置专属于你的角色别名', - 'pm_usage': '<角色名>是我<别名>', - 'pm_priority': 7 +add_alias = on_regex( + rf'((?P{CHARA_RE})是[我俺咱]的?(?P\w+))|([我俺咱]的?(?P\w+)[是叫名](?P{CHARA_RE}))', priority=10, + block=True, state={ + 'pm_name': '角色别名设置', + 'pm_description': '设置专属于你的角色别名', + 'pm_usage': '<角色名>是我<别名>', + 'pm_priority': 7 + }) +delete_alias = on_command('删除别名', priority=10, block=True, state={ + 'pm_name': '角色别名删除', + 'pm_description': '删除你已设置的角色别名', + 'pm_usage': '删除别名<别名>', + 'pm_priority': 8 }) @@ -97,6 +105,7 @@ async def _(event: MessageEvent, players=CommandPlayer()): running_ysa = [] + @ysa.handle() async def _(event: MessageEvent, players=CommandPlayer(2)): logger.info('原神角色背包', '开始执行') @@ -250,3 +259,13 @@ async def _(event: MessageEvent, regex_dict: dict = RegexDict()): alias = regex_dict['alias'] or regex_dict['alias2'] await PlayerAlias.update_or_create(user_id=str(event.user_id), alias=alias, defaults={'character': chara}) await add_alias.finish(f'{NICKNAME}知道{chara}是你的{alias}啦..') + + +@delete_alias.handle() +async def _(event: MessageEvent, msg: Message = CommandArg()): + msg = msg.extract_plain_text().strip() + if alias := await PlayerAlias.get_or_none(user_id=str(event.user_id), alias=msg): + await alias.delete() + await delete_alias.finish(f'别名{msg}删除成功!') + else: + await delete_alias.finish(f'你并没有将{msg}设置为某个角色的别名') diff --git a/LittlePaimon/plugins/Paimon_Info/draw_player_card.py b/LittlePaimon/plugins/Paimon_Info/draw_player_card.py index f159d39..06bfc35 100644 --- a/LittlePaimon/plugins/Paimon_Info/draw_player_card.py +++ b/LittlePaimon/plugins/Paimon_Info/draw_player_card.py @@ -73,18 +73,21 @@ async def draw_world_card(img: PMImage, info: PlayerWorldInfo): pass elif info.name == '蒙德': if info.unlock: + await img.draw_ring((225, 225), (89, 1157), 0.08, info.percent / 1000, ['white', (0, 0, 0, 0)]) await img.text(get_percent_text(info.percent), (110, 301), 1387, fm.get('hywh', 24), 'white', 'center') await img.text(str(info.level) if info.level != 8 else 'Max', 150, 1447, fm.get('hywh', 24), 'white') else: await img.text('未解锁', (110, 301), 1387, fm.get('hywh', 24), 'white', 'center') elif info.name == '璃月': if info.unlock: + await img.draw_ring((225, 225), (313, 1157), 0.08, info.percent / 1000, ['white', (0, 0, 0, 0)]) await img.text(get_percent_text(info.percent), (334, 525), 1387, fm.get('hywh', 24), 'white', 'center') await img.text(str(info.level) if info.level != 8 else 'Max', 374, 1447, fm.get('hywh', 24), 'white') else: await img.text('未解锁', (334, 525), 1387, fm.get('hywh', 24), 'white', 'center') elif info.name == '稻妻': if info.unlock: + await img.draw_ring((225, 225), (537, 1157), 0.08, info.percent / 1000, ['white', (0, 0, 0, 0)]) await img.text(get_percent_text(info.percent), (558, 749), 1387, fm.get('hywh', 24), 'white', 'center') await img.text(str(info.level) if info.level != 10 else 'Max', 598, 1447, fm.get('hywh', 24), 'white') await img.text(str(info.tree_level) if info.tree_level != 50 else 'Max', 710, 1447, fm.get('hywh', 24), @@ -94,6 +97,7 @@ async def draw_world_card(img: PMImage, info: PlayerWorldInfo): await img.text('未解锁', (558, 749), 1387, fm.get('hywh', 24), 'white', 'center') elif info.name == '龙脊雪山': if info.unlock: + await img.draw_ring((225, 225), (89, 1494), 0.08, info.percent / 1000, ['white', (0, 0, 0, 0)]) await img.text(get_percent_text(info.percent), (110, 301), 1724, fm.get('hywh', 24), 'white', 'center') await img.text(str(info.tree_level) if info.tree_level != 12 else 'Max', 150, 1784, fm.get('hywh', 24), 'white') @@ -110,6 +114,7 @@ async def draw_world_card(img: PMImage, info: PlayerWorldInfo): 'center') elif info.name == '层岩巨渊·地下矿区': if info.unlock: + await img.draw_ring((225, 225), (313, 1494), 0.08, info.percent / 1000, ['white', (0, 0, 0, 0)]) await img.text(f'地下{get_percent_text(info.percent)}', (334, 525), 1751, fm.get('hywh', 24), 'white', 'center') else: @@ -117,11 +122,13 @@ async def draw_world_card(img: PMImage, info: PlayerWorldInfo): 'center') elif info.name == '渊下宫': if info.unlock: + await img.draw_ring((225, 225), (537, 1494), 0.08, info.percent / 1000, ['white', (0, 0, 0, 0)]) await img.text(get_percent_text(info.percent), (558, 749), 1724, fm.get('hywh', 24), 'white', 'center') else: await img.text('未解锁', (558, 749), 1724, fm.get('hywh', 24), 'white', 'center') elif info.name == '须弥': if info.unlock: + await img.draw_ring((225, 225), (761, 1157), 0.08, info.percent / 1000, ['white', (0, 0, 0, 0)]) await img.text(get_percent_text(info.percent), (782, 973), 1387, fm.get('hywh', 24), 'white', 'center') await img.text(str(info.level) if info.level != 10 else 'Max', 826, 1447, fm.get('hywh', 24), 'white') await img.text(str(info.tree_level) if info.tree_level != 50 else 'Max', 938, 1447, fm.get('hywh', 24), @@ -166,7 +173,9 @@ async def draw_player_card(player: Player, info: PlayerInfo, characters: List[Ch (0, 0, 0, 153), 'center') for name in home_name]) # 世界探索 - await asyncio.gather(*[draw_world_card(img, w) for w in info.world_explore.list()]) + # await asyncio.gather(*[draw_world_card(img, w) for w in info.world_explore.list()]) + for w in info.world_explore.list(): + await draw_world_card(img, w) # 角色 await asyncio.gather( diff --git a/LittlePaimon/utils/genshin.py b/LittlePaimon/utils/genshin.py index 4b143ba..75e03af 100644 --- a/LittlePaimon/utils/genshin.py +++ b/LittlePaimon/utils/genshin.py @@ -13,6 +13,7 @@ from LittlePaimon.utils.api import get_enka_data, get_mihoyo_public_data, get_mi from LittlePaimon.utils.typing import DataSourceType from LittlePaimon.utils.alias import get_name_by_id from LittlePaimon.utils.typing import CHARACTERS +from LittlePaimon.manager.plugin_manager import plugin_manager as pm ra_score = load_json(JSON_DATA / 'score.json') talent_map = load_json(JSON_DATA / 'role_skill.json') @@ -95,6 +96,8 @@ class GenshinInfoManager: if len(character.constellation) >= 5: data[ra_score['Talent'][cname][1]]['level_current'] += 3 length = 4 if character.name in ['莫娜', '神里绫华'] else 3 + if character.name == '安柏': + data[0], data[2] = data[2], data[0] character.talents = Talents(talent_list=[Talent( name=t['name'], level=t['level_current'], @@ -166,7 +169,7 @@ class GenshinInfoManager: if data_source == 'enka': """如果角色不存在或者角色的更新时间在6小时前,则更新角色信息""" character = await Character.get_or_none(**query, data_source='enka') - if not character or character.update_time < (datetime.datetime.now() - datetime.timedelta(hours=6)).replace( + if not character or character.update_time < (datetime.datetime.now() - datetime.timedelta(hours=pm.config.ysd_auto_update)).replace( tzinfo=pytz.timezone('Asia/Shanghai')): await self.update_from_enka() if character := await Character.get_or_none(**query, data_source='enka'): @@ -179,8 +182,8 @@ class GenshinInfoManager: elif data_source == 'mihoyo': return await Character.get_or_none(**query, data_source='mihoyo') else: - characters = await Character.filter(**query).order_by('update_time') - return characters[-1] if characters else None + characters = await Character.filter(**query).order_by('data_source') + return characters[0] if characters else None async def get_chara_bag(self) -> Tuple[Union[PlayerInfo, str], List[Character]]: """ @@ -190,7 +193,7 @@ class GenshinInfoManager: await self.set_last_query() player_info = await PlayerInfo.get_or_none(user_id=self.user_id, uid=self.uid) if player_info is None or player_info.update_time is None or player_info.update_time < ( - datetime.datetime.now() - datetime.timedelta(days=1)).replace( + datetime.datetime.now() - datetime.timedelta(hours=pm.config.ysa_auto_update)).replace( tzinfo=pytz.timezone('Asia/Shanghai')): result = await self.update_from_mihoyo() if result != '更新成功': @@ -207,7 +210,7 @@ class GenshinInfoManager: await self.set_last_query() player_info = await PlayerInfo.get_or_none(user_id=self.user_id, uid=self.uid) if player_info is None or player_info.update_time is None or player_info.update_time < ( - datetime.datetime.now() - datetime.timedelta(days=1)).replace( + datetime.datetime.now() - datetime.timedelta(hours=pm.config.ys_auto_update)).replace( tzinfo=pytz.timezone('Asia/Shanghai')): result = await self.update_from_mihoyo() if result != '更新成功': @@ -223,6 +226,7 @@ class GenshinInfoManager: async def get_abyss_info(self, abyss_index: int = 1) -> Union[AbyssInfo, str]: await self.set_last_query() + await AbyssInfo.filter(user_id=self.user_id, uid=self.uid).delete() result = await self.update_abyss_info(abyss_index) if result != '更新成功': return result