🐛 修复原神日历权限问题和ysa未知制图问题

This commit is contained in:
CMHopeSunshine 2022-09-08 17:51:51 +08:00
parent f3e7376aa5
commit 198ee3a71f
3 changed files with 29 additions and 26 deletions

View File

@ -1,15 +1,12 @@
from typing import Union
from nonebot import get_bot, on_command from nonebot import get_bot, on_command
from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment, GROUP_ADMIN from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
from nonebot.permission import SUPERUSER
from nonebot.plugin import PluginMetadata from nonebot.plugin import PluginMetadata
from .generate import * from .generate import *
from LittlePaimon.utils.message import CommandObjectID, CommandSwitch, CommandTime from LittlePaimon.utils.message import CommandObjectID, CommandSwitch, CommandTime
from LittlePaimon.utils import scheduler, logger from LittlePaimon.utils import scheduler, logger
from LittlePaimon.database.models import GeneralSub from LittlePaimon.database.models import GeneralSub
from LittlePaimon import DRIVER from LittlePaimon import DRIVER, SUPERUSERS
__plugin_meta__ = PluginMetadata( __plugin_meta__ = PluginMetadata(
name="原神日历", name="原神日历",
@ -26,7 +23,7 @@ __plugin_meta__ = PluginMetadata(
}, },
) )
calendar = on_command('原神日历', aliases={'原神日程', '活动日历'}, permission=SUPERUSER | GROUP_ADMIN, priority=10, block=True) calendar = on_command('原神日历', aliases={'原神日程', '活动日历'}, priority=10, block=True)
@calendar.handle() @calendar.handle()
@ -35,6 +32,8 @@ async def _(event: MessageEvent, sub_id=CommandObjectID(), switch=CommandSwitch(
im = await generate_day_schedule('cn') im = await generate_day_schedule('cn')
await calendar.finish(MessageSegment.image(im)) await calendar.finish(MessageSegment.image(im))
else: else:
if event.sender.role not in ['admin', 'owner'] or event.user_id not in SUPERUSERS:
await calendar.finish('你没有权限管理原神日历订阅')
sub_data = {'sub_id': sub_id, 'sub_type': event.message_type, 'sub_event': '原神日历'} sub_data = {'sub_id': sub_id, 'sub_type': event.message_type, 'sub_event': '原神日历'}
if event.message_type == 'guild': if event.message_type == 'guild':

View File

@ -175,9 +175,9 @@ async def draw_gacha_log(user_id: str, uid: str, nickname: Optional[str], signat
await img.text(str(total_five_star_count), (789, 884), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center') await img.text(str(total_five_star_count), (789, 884), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center')
four_star_detail = await draw_four_star_detail(list(data4.values())) four_star_detail = await draw_four_star_detail(list(data4.values()))
if total_five_star_count: if total_five_star_count:
chara_pool_per = round(len(data5['角色祈愿']) / total_five_star_count * 100, 3) chara_pool_per = round(len(data5['角色祈愿']) / total_five_star_count * 100, 1)
weapon_pool_per = round(len(data5['武器祈愿']) / total_five_star_count * 100, 3) weapon_pool_per = round(len(data5['武器祈愿']) / total_five_star_count * 100, 1)
new_pool_per = round((len(data5['常驻祈愿']) + len(data5['新手祈愿'])) / total_five_star_count * 100, 3) new_pool_per = round((len(data5['常驻祈愿']) + len(data5['新手祈愿'])) / total_five_star_count * 100, 1)
now_used_width = 56 now_used_width = 56
pers = [chara_pool_per, weapon_pool_per, new_pool_per] pers = [chara_pool_per, weapon_pool_per, new_pool_per]
i = 0 i = 0

View File

@ -40,23 +40,27 @@ def sort_characters(characters: List[Character]) -> List[Character]:
圣遗物每级0.5/0.8/1每个两件套20分四件套60分最后按降序排序 圣遗物每级0.5/0.8/1每个两件套20分四件套60分最后按降序排序
""" """
for chara in characters: for chara in characters:
chara.score = chara.level * (0.8 if chara.rarity == 4 else 1) + chara.fetter * 3 try:
if chara.talents: chara.score = chara.level * (0.8 if chara.rarity == 4 else 1) + chara.fetter * 3
for talent in chara.talents: if chara.talents:
chara.score += talent.level * (5 if talent.level <= 6 else 8) for talent in chara.talents:
chara.score += len(chara.constellation) * (15 if chara.rarity == 4 else 50) chara.score += talent.level * (5 if talent.level <= 6 else 8)
if chara.weapon: chara.score += len(chara.constellation) * (15 if chara.rarity == 4 else 50)
chara.score += chara.weapon.level * ( if chara.weapon:
0.6 if chara.weapon.rarity <= 3 else 0.8 if chara.weapon.rarity == 4 else 1) chara.score += chara.weapon.level * (
chara.score += chara.weapon.affix_level * ( 0.6 if chara.weapon.rarity <= 3 else 0.8 if chara.weapon.rarity == 4 else 1)
10 if chara.weapon.rarity <= 3 else 20 if chara.weapon.rarity == 4 else 50) chara.score += chara.weapon.affix_level * (
if chara.artifacts: 10 if chara.weapon.rarity <= 3 else 20 if chara.weapon.rarity == 4 else 50)
suit = GenshinTools.get_artifact_suit(chara.artifacts) if chara.artifacts:
chara.suit = suit suit = GenshinTools.get_artifact_suit(chara.artifacts)
chara.score += 60 if len(suit) == 2 and suit[0] == suit[1] else 20 * len(suit) chara.suit = suit
for artifact in chara.artifacts: chara.score += 60 if len(suit) == 2 and suit[0] == suit[1] else 20 * len(suit)
chara.score += artifact.level * (0.5 if artifact.rarity <= 3 else 0.8 if artifact.rarity == 4 else 1) for artifact in chara.artifacts:
else: chara.score += artifact.level * (0.5 if artifact.rarity <= 3 else 0.8 if artifact.rarity == 4 else 1)
else:
chara.suit = []
except Exception:
chara.score = 0
chara.suit = [] chara.suit = []
return sorted(characters, key=lambda x: x.score, reverse=True) return sorted(characters, key=lambda x: x.score, reverse=True)