mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-05 03:03:45 +08:00
format 一下
This commit is contained in:
parent
e6a02824ac
commit
a15dea8361
@ -1,60 +1,70 @@
|
||||
# flake8: noqa
|
||||
OLD_URL = "https://api-takumi.mihoyo.com"
|
||||
OS_OLD_URL = "https://api-os-takumi.mihoyo.com"
|
||||
NEW_URL = 'https://api-takumi-record.mihoyo.com'
|
||||
NEW_URL = "https://api-takumi-record.mihoyo.com"
|
||||
OS_URL = "https://sg-public-api.hoyolab.com"
|
||||
OS_INFO_URL = "https://bbs-api-os.hoyolab.com"
|
||||
|
||||
STAR_RAIL_SIGN_INFO_URL = f'{OLD_URL}/event/luna/info'
|
||||
STAR_RAIL_SIGN_INFO_URL_OS = f'{OS_URL}/event/luna/os/info'
|
||||
STAR_RAIL_SIGN_LIST_URL = f'{OLD_URL}/event/luna/home'
|
||||
STAR_RAIL_SIGN_LIST_URL_OS = f'{OS_URL}/event/luna/os/home'
|
||||
STAR_RAIL_SIGN_EXTRA_INFO_URL = f'{OLD_URL}/event/luna/extra_info'
|
||||
STAR_RAIL_SIGN_EXTRA_REWARD_URL = f'{OLD_URL}/event/luna/extra_reward'
|
||||
STAR_RAIL_SIGN_URL = f'{OLD_URL}/event/luna/sign'
|
||||
STAR_RAIL_SIGN_URL_OS = f'{OS_URL}/event/luna/os/sign'
|
||||
STAR_RAIL_MONTH_INFO_URL = f'{OLD_URL}/event/srledger/month_info' # 开拓阅历接口
|
||||
STAR_RAIL_SIGN_INFO_URL = f"{OLD_URL}/event/luna/info"
|
||||
STAR_RAIL_SIGN_INFO_URL_OS = f"{OS_URL}/event/luna/os/info"
|
||||
STAR_RAIL_SIGN_LIST_URL = f"{OLD_URL}/event/luna/home"
|
||||
STAR_RAIL_SIGN_LIST_URL_OS = f"{OS_URL}/event/luna/os/home"
|
||||
STAR_RAIL_SIGN_EXTRA_INFO_URL = f"{OLD_URL}/event/luna/extra_info"
|
||||
STAR_RAIL_SIGN_EXTRA_REWARD_URL = f"{OLD_URL}/event/luna/extra_reward"
|
||||
STAR_RAIL_SIGN_URL = f"{OLD_URL}/event/luna/sign"
|
||||
STAR_RAIL_SIGN_URL_OS = f"{OS_URL}/event/luna/os/sign"
|
||||
STAR_RAIL_MONTH_INFO_URL = (
|
||||
f"{OLD_URL}/event/srledger/month_info"
|
||||
) # 开拓阅历接口
|
||||
STAR_RAIL_MONTH_DETAIL_URL = (
|
||||
f'{OLD_URL}/event/srledger/month_detail' # 开拓阅历详情接口
|
||||
f"{OLD_URL}/event/srledger/month_detail" # 开拓阅历详情接口
|
||||
)
|
||||
|
||||
STAR_RAIL_NOTE_URL = f'{NEW_URL}/game_record/app/hkrpg/api/note' # 实时便签接口
|
||||
STAR_RAIL_NOTE_URL_OS = f'{OS_INFO_URL}/game_record/hkrpg/api/note' # OS实时便签接口
|
||||
STAR_RAIL_INDEX_URL = f'{NEW_URL}/game_record/app/hkrpg/api/index' # 角色橱窗接口
|
||||
STAR_RAIL_NOTE_URL = (
|
||||
f"{NEW_URL}/game_record/app/hkrpg/api/note"
|
||||
) # 实时便签接口
|
||||
STAR_RAIL_NOTE_URL_OS = (
|
||||
f"{OS_INFO_URL}/game_record/hkrpg/api/note"
|
||||
) # OS实时便签接口
|
||||
STAR_RAIL_INDEX_URL = (
|
||||
f"{NEW_URL}/game_record/app/hkrpg/api/index"
|
||||
) # 角色橱窗接口
|
||||
STAR_RAIL_INDEX_URL_OS = (
|
||||
f'{OS_INFO_URL}/game_record/hkrpg/api/index' # OS角色橱窗接口
|
||||
f"{OS_INFO_URL}/game_record/hkrpg/api/index" # OS角色橱窗接口
|
||||
)
|
||||
STAR_RAIL_AVATAR_BASIC_URL = (
|
||||
f'{NEW_URL}/game_record/app/hkrpg/api/avatar/basic' # 全部角色接口
|
||||
f"{NEW_URL}/game_record/app/hkrpg/api/avatar/basic" # 全部角色接口
|
||||
)
|
||||
STAR_RAIL_ROLE_BASIC_INFO_URL = (
|
||||
f'{NEW_URL}/game_record/app/hkrpg/api/role/basicInfo' # 角色基础信息接口
|
||||
f"{NEW_URL}/game_record/app/hkrpg/api/role/basicInfo" # 角色基础信息接口
|
||||
)
|
||||
STAR_RAIL_ROLE_BASIC_INFO_URL_OS = f'{OS_INFO_URL}/game_record/hkrpg/api/index'
|
||||
STAR_RAIL_ROLE_BASIC_INFO_URL_OS = f"{OS_INFO_URL}/game_record/hkrpg/api/index"
|
||||
STAR_RAIL_AVATAR_INFO_URL = (
|
||||
f'{NEW_URL}/game_record/app/hkrpg/api/avatar/info' # 角色详细信息接口
|
||||
f"{NEW_URL}/game_record/app/hkrpg/api/avatar/info" # 角色详细信息接口
|
||||
)
|
||||
STAR_RAIL_AVATAR_INFO_URL_OS = (
|
||||
f'{OS_INFO_URL}/game_record/hkrpg/api/avatar/info' # OS角色详细信息接口
|
||||
f"{OS_INFO_URL}/game_record/hkrpg/api/avatar/info" # OS角色详细信息接口
|
||||
)
|
||||
|
||||
CHALLENGE_INFO_URL = f'{NEW_URL}/game_record/app/hkrpg/api/challenge'
|
||||
CHALLENGE_INFO_URL_OS = f'{OS_INFO_URL}/game_record/hkrpg/api/challenge'
|
||||
CHALLENGE_INFO_URL = f"{NEW_URL}/game_record/app/hkrpg/api/challenge"
|
||||
CHALLENGE_INFO_URL_OS = f"{OS_INFO_URL}/game_record/hkrpg/api/challenge"
|
||||
|
||||
ROGUE_INFO_URL = f'{NEW_URL}/game_record/app/hkrpg/api/rogue' # 角色模拟宇宙信息接口
|
||||
ROGUE_INFO_URL = (
|
||||
f"{NEW_URL}/game_record/app/hkrpg/api/rogue"
|
||||
) # 角色模拟宇宙信息接口
|
||||
ROGUE_LOCUST_INFO_URL = (
|
||||
f'{NEW_URL}/game_record/app/hkrpg/api/rogue_locust' # 角色寰宇蝗灾信息接口
|
||||
f"{NEW_URL}/game_record/app/hkrpg/api/rogue_locust" # 角色寰宇蝗灾信息接口
|
||||
)
|
||||
|
||||
STAR_RAIL_GACHA_LOG_URL = f'{OLD_URL}/common/gacha_record/api/getGachaLog'
|
||||
STAR_RAIL_GACHA_LOG_URL = f"{OLD_URL}/common/gacha_record/api/getGachaLog"
|
||||
STAR_RAIL_GACHA_LOG_URL_OS = (
|
||||
f'{OS_OLD_URL}/common/gacha_record/api/getGachaLog'
|
||||
f"{OS_OLD_URL}/common/gacha_record/api/getGachaLog"
|
||||
)
|
||||
|
||||
GET_FP_URL = 'https://public-data-api.mihoyo.com/device-fp/api/getFp'
|
||||
GET_FP_URL_OS = 'https://sg-public-data-api.hoyoverse.com/device-fp/api/getFp'
|
||||
GET_FP_URL = "https://public-data-api.mihoyo.com/device-fp/api/getFp"
|
||||
GET_FP_URL_OS = "https://sg-public-data-api.hoyoverse.com/device-fp/api/getFp"
|
||||
# CREATE_QRCODE = f'{OLD_URL}/event/bbs_sign_reward/gen_auth_code'
|
||||
|
||||
STAR_RAIL_WIDGRT_URL = f'{NEW_URL}/game_record/app/hkrpg/aapi/widget'
|
||||
STAR_RAIL_WIDGRT_URL = f"{NEW_URL}/game_record/app/hkrpg/aapi/widget"
|
||||
|
||||
_API = locals()
|
||||
|
@ -46,7 +46,16 @@ TEXT_PATH = Path(__file__).parent / 'texture2D'
|
||||
|
||||
bg_img = Image.open(TEXT_PATH / 'bg.png')
|
||||
white_color = (213, 213, 213)
|
||||
NUM_MAP = {0: '零', 1: '一', 2: '二', 3: '三', 4: '四', 5: '五', 6: '六', 7: '七'}
|
||||
NUM_MAP = {
|
||||
0: '零',
|
||||
1: '一',
|
||||
2: '二',
|
||||
3: '三',
|
||||
4: '四',
|
||||
5: '五',
|
||||
6: '六',
|
||||
7: '七',
|
||||
}
|
||||
|
||||
RANK_MAP = {
|
||||
1: '_rank1.png',
|
||||
|
@ -59,7 +59,9 @@ class JingYuan(BaseAvatar):
|
||||
|
||||
def extra_ability(self):
|
||||
logger.info('额外能力')
|
||||
logger.info('【神君】下回合的攻击段数大于等于6段, 则其下回合的暴击伤害提高25%。')
|
||||
logger.info(
|
||||
'【神君】下回合的攻击段数大于等于6段, 则其下回合的暴击伤害提高25%。'
|
||||
)
|
||||
self.extra_ability_attribute['CriticalDamageBase'] = 0.25
|
||||
logger.info('施放战技后, 暴击率提升10%')
|
||||
self.extra_ability_attribute['CriticalChanceBase'] = 0.1
|
||||
@ -118,7 +120,9 @@ class Danhengil(BaseAvatar):
|
||||
|
||||
def extra_ability(self):
|
||||
logger.info('额外能力')
|
||||
logger.info('对拥有虚数属性弱点的敌方目标造成伤害时, 暴击伤害提高24%。')
|
||||
logger.info(
|
||||
'对拥有虚数属性弱点的敌方目标造成伤害时, 暴击伤害提高24%。'
|
||||
)
|
||||
self.extra_ability_attribute['CriticalDamageBase'] = 0.24
|
||||
|
||||
|
||||
@ -316,7 +320,9 @@ class Welt(BaseAvatar):
|
||||
|
||||
def extra_ability(self):
|
||||
logger.info('额外能力')
|
||||
logger.info('施放终结技时, 有100%基础概率使目标受到的伤害提高12%, 持续2回合。')
|
||||
logger.info(
|
||||
'施放终结技时, 有100%基础概率使目标受到的伤害提高12%, 持续2回合。'
|
||||
)
|
||||
logger.info('对被弱点击破的敌方目标造成的伤害提高20')
|
||||
self.extra_ability_attribute['AllDamageAddedRatio'] = 0.32
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -295,7 +295,9 @@ class RoleInstance:
|
||||
# 检查是否有某一属性的抗性穿透
|
||||
attr_name = attr.split('ResistancePenetration')[0]
|
||||
if attr_name in (self.avatar.avatar_element, 'AllDamage'):
|
||||
logger.info(f'{attr_name}属性有{merged_attr[attr]}穿透加成')
|
||||
logger.info(
|
||||
f'{attr_name}属性有{merged_attr[attr]}穿透加成'
|
||||
)
|
||||
enemy_status_resistance += merged_attr[attr]
|
||||
# 检查是否有某一技能属性的抗性穿透
|
||||
if attr_name.__contains__('_'):
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -130,7 +130,9 @@ async def get_char_args(
|
||||
if isinstance(char_data, str):
|
||||
return char_data
|
||||
else:
|
||||
for i, s in enumerate(['头部', '手部', '躯干', '腿部', '位面球', '连结绳']):
|
||||
for i, s in enumerate(
|
||||
['头部', '手部', '躯干', '腿部', '位面球', '连结绳']
|
||||
):
|
||||
if '赤沙' in part:
|
||||
continue
|
||||
if part[-1] in PieceName_ilst[i]:
|
||||
|
@ -54,7 +54,9 @@ async def draw_enka_card(uid: str, char_list: List, showfrom: int = 0):
|
||||
return await convert_img(Image.new('RGBA', (0, 1), (255, 255, 255)))
|
||||
else:
|
||||
line1 = f'UID {uid} 刷新成功'
|
||||
line2 = f'可以使用 sr查询{char_data_list[0]["avatarName"]} 查询详情角色面板'
|
||||
line2 = (
|
||||
f'可以使用 sr查询{char_data_list[0]["avatarName"]} 查询详情角色面板'
|
||||
)
|
||||
char_num = len(char_data_list)
|
||||
if char_num <= 4:
|
||||
based_w, based_h = 1380, 926
|
||||
|
@ -8,7 +8,9 @@ from gsuid_core.utils.plugins_config.models import (
|
||||
)
|
||||
|
||||
CONIFG_DEFAULT: Dict[str, GSC] = {
|
||||
'SignTime': GsListStrConfig('每晚签到时间设置', '每晚米游社签到时间设置(时,分)', ['0', '38']),
|
||||
'SignTime': GsListStrConfig(
|
||||
'每晚签到时间设置', '每晚米游社签到时间设置(时,分)', ['0', '38']
|
||||
),
|
||||
'SignReportSimple': GsBoolConfig(
|
||||
'简洁签到报告',
|
||||
'开启后可以大大减少每日签到报告字数',
|
||||
|
@ -39,6 +39,8 @@ async def get_gachalog_by_link(bot: Bot, ev: Event):
|
||||
if ev.command.startswith('强制'):
|
||||
await bot.logger.info('[WARNING]本次为强制刷新')
|
||||
is_force = True
|
||||
await bot.send(f'UID{uid}开始执行[刷新抽卡记录],需要一定时间...请勿重复触发!')
|
||||
await bot.send(
|
||||
f'UID{uid}开始执行[刷新抽卡记录],需要一定时间...请勿重复触发!'
|
||||
)
|
||||
im = await save_gachalogs(uid, gacha_url, None, is_force)
|
||||
return await bot.send(im)
|
||||
|
@ -112,7 +112,12 @@ async def save_gachalogs(
|
||||
uid, gacha_url, gachalogs_history, is_force
|
||||
)
|
||||
else:
|
||||
new_data = {'始发跃迁': [], '群星跃迁': [], '角色跃迁': [], '光锥跃迁': []}
|
||||
new_data = {
|
||||
'始发跃迁': [],
|
||||
'群星跃迁': [],
|
||||
'角色跃迁': [],
|
||||
'光锥跃迁': [],
|
||||
}
|
||||
if gachalogs_history:
|
||||
for i in ['始发跃迁', '群星跃迁', '角色跃迁', '光锥跃迁']:
|
||||
for item in raw_data[i]:
|
||||
@ -128,7 +133,12 @@ async def save_gachalogs(
|
||||
if raw_data == {} or not raw_data:
|
||||
return '请给出正确的抽卡记录链接或链接已失效'
|
||||
|
||||
temp_data = {'始发跃迁': [], '群星跃迁': [], '角色跃迁': [], '光锥跃迁': []}
|
||||
temp_data = {
|
||||
'始发跃迁': [],
|
||||
'群星跃迁': [],
|
||||
'角色跃迁': [],
|
||||
'光锥跃迁': [],
|
||||
}
|
||||
for i in ['始发跃迁', '群星跃迁', '角色跃迁', '光锥跃迁']:
|
||||
for item in raw_data[i]:
|
||||
if item not in temp_data[i]:
|
||||
|
@ -1,278 +1,279 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
from datetime import datetime
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
from msgspec import json as msgjson
|
||||
from gsuid_core.logger import logger
|
||||
|
||||
from ..utils.mys_api import mys_api
|
||||
from ..utils.error_reply import get_error
|
||||
from ..utils.image.convert import convert_img
|
||||
from ..utils.resource.RESOURCE_PATH import PLAYER_PATH
|
||||
from ..utils.fonts.starrail_fonts import sr_font_20, sr_font_28, sr_font_34
|
||||
|
||||
TEXT_PATH = Path(__file__).parent / 'texture2d'
|
||||
|
||||
monthly_bg = Image.open(TEXT_PATH / 'monthly_bg.png')
|
||||
avatar_default = Image.open(TEXT_PATH / '200101.png')
|
||||
|
||||
first_color = (29, 29, 29)
|
||||
second_color = (67, 61, 56)
|
||||
second_color2 = (98, 98, 98)
|
||||
black_color = (54, 54, 54)
|
||||
white_color = (213, 213, 213)
|
||||
|
||||
COLOR_MAP = {
|
||||
'每日活跃': (248, 227, 157),
|
||||
'活动奖励': (99, 231, 176),
|
||||
'冒险奖励': (114, 205, 251),
|
||||
'模拟宇宙奖励': (160, 149, 248),
|
||||
'忘却之庭奖励': (221, 119, 250),
|
||||
'邮件奖励': (244, 110, 104),
|
||||
'其他': (255, 242, 200),
|
||||
'Daily Activity': (248, 227, 157),
|
||||
'Events': (99, 231, 176),
|
||||
'Adventure': (114, 205, 251),
|
||||
'moni': (160, 149, 248),
|
||||
'Spiral Abyss': (221, 119, 250),
|
||||
'Quests': (244, 110, 104),
|
||||
'Other': (255, 242, 200),
|
||||
}
|
||||
|
||||
|
||||
async def draw_note_img(sr_uid: str) -> Union[bytes, str]:
|
||||
path = PLAYER_PATH / str(sr_uid)
|
||||
if not path.exists():
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 获取当前时间
|
||||
now = datetime.now()
|
||||
current_year_mon = now.strftime('%Y-%m')
|
||||
add_month = ''
|
||||
if int(now.month) < 10:
|
||||
add_month = '0'
|
||||
now_month = str(now.year) + str(add_month) + str(now.month)
|
||||
# 获取数据
|
||||
data = await mys_api.get_award(sr_uid, now_month)
|
||||
if isinstance(data, int):
|
||||
return get_error(data)
|
||||
|
||||
# 保存数据
|
||||
with Path.open(
|
||||
path / f'monthly_{current_year_mon}.json', 'w', encoding='utf-8'
|
||||
) as f:
|
||||
save_json_data = msgjson.format(msgjson.encode(data), indent=4)
|
||||
save_data = json.dumps(
|
||||
{
|
||||
'data_time': now.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'data': save_json_data.decode('utf-8'),
|
||||
},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
f.write(save_data)
|
||||
|
||||
# 获取上月数据
|
||||
last_month = now.month - 1
|
||||
last_year = now.year
|
||||
if last_month == 0:
|
||||
last_month = 12
|
||||
last_year -= 1
|
||||
last_year_mon = f'{last_year}-{last_month:02d}'
|
||||
last_monthly_path = path / f'monthly_{last_year_mon}.json'
|
||||
if last_monthly_path.exists():
|
||||
with Path.open(last_monthly_path, encoding='utf-8') as f:
|
||||
last_monthly_data = json.load(f)
|
||||
last_monthly_data = last_monthly_data['data']
|
||||
else:
|
||||
add_month = ''
|
||||
if int(last_month) < 10:
|
||||
add_month = '0'
|
||||
find_last_month = str(last_year) + str(add_month) + str(last_month)
|
||||
last_monthly_data = await mys_api.get_award(sr_uid, find_last_month)
|
||||
if isinstance(last_monthly_data, int):
|
||||
return get_error(last_monthly_data)
|
||||
|
||||
# nickname and level
|
||||
role_basic_info = await mys_api.get_role_basic_info(sr_uid)
|
||||
if isinstance(role_basic_info, int):
|
||||
return get_error(role_basic_info)
|
||||
nickname = role_basic_info.nickname
|
||||
|
||||
day_hcoin = data.day_data.current_hcoin
|
||||
day_rails_pass = data.day_data.current_rails_pass
|
||||
lastday_hcoin = 0
|
||||
lastday_rails_pass = 0
|
||||
if int(sr_uid[0]) < 6:
|
||||
lastday_hcoin = data.day_data.last_hcoin
|
||||
lastday_rails_pass = data.day_data.last_rails_pass
|
||||
month_hcoin = data.month_data.current_hcoin
|
||||
month_rails_pass = data.month_data.current_rails_pass
|
||||
lastmonth_hcoin = data.month_data.last_hcoin
|
||||
lastmonth_rails_pass = data.month_data.last_rails_pass
|
||||
|
||||
day_hcoin_str = await int_carry(day_hcoin)
|
||||
day_rails_pass_str = await int_carry(day_rails_pass)
|
||||
month_hcoin_str = await int_carry(month_hcoin)
|
||||
month_rails_pass_str = await int_carry(month_rails_pass)
|
||||
lastday_hcoin_str = await int_carry(lastday_hcoin)
|
||||
lastday_rails_pass_str = await int_carry(lastday_rails_pass)
|
||||
lastmonth_hcoin_str = await int_carry(lastmonth_hcoin)
|
||||
lastmonth_rails_pass_str = await int_carry(lastmonth_rails_pass)
|
||||
|
||||
img = monthly_bg.copy()
|
||||
avatar_img = avatar_default.copy()
|
||||
char_pic = avatar_img.convert('RGBA').resize(
|
||||
(125, 125), Image.Resampling.LANCZOS # type: ignore
|
||||
)
|
||||
img.paste(char_pic, (115, 133), char_pic)
|
||||
img_draw = ImageDraw.Draw(img)
|
||||
|
||||
# 写Nickname
|
||||
img_draw.text(
|
||||
(310, 184), nickname, font=sr_font_34, fill=first_color, anchor='lm'
|
||||
)
|
||||
|
||||
# 写UID
|
||||
img_draw.text(
|
||||
(267, 219),
|
||||
f'UID {sr_uid}',
|
||||
font=sr_font_20,
|
||||
fill=second_color2,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写本日星琼
|
||||
img_draw.text(
|
||||
(283, 326),
|
||||
day_hcoin_str,
|
||||
font=sr_font_28,
|
||||
fill=white_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写本月星琼
|
||||
img_draw.text(
|
||||
(513, 326),
|
||||
month_hcoin_str,
|
||||
font=sr_font_28,
|
||||
fill=white_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写昨日星琼
|
||||
img_draw.text(
|
||||
(283, 366),
|
||||
lastday_hcoin_str,
|
||||
font=sr_font_28,
|
||||
fill=black_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写上月星琼
|
||||
img_draw.text(
|
||||
(513, 366),
|
||||
lastmonth_hcoin_str,
|
||||
font=sr_font_28,
|
||||
fill=black_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写本日铁票
|
||||
img_draw.text(
|
||||
(283, 431),
|
||||
day_rails_pass_str,
|
||||
font=sr_font_28,
|
||||
fill=white_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写本月铁票
|
||||
img_draw.text(
|
||||
(513, 431),
|
||||
month_rails_pass_str,
|
||||
font=sr_font_28,
|
||||
fill=white_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写昨日铁票
|
||||
img_draw.text(
|
||||
(283, 473),
|
||||
lastday_rails_pass_str,
|
||||
font=sr_font_28,
|
||||
fill=black_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写上月铁票
|
||||
img_draw.text(
|
||||
(513, 473),
|
||||
lastmonth_rails_pass_str,
|
||||
font=sr_font_28,
|
||||
fill=black_color,
|
||||
anchor='lm',
|
||||
)
|
||||
xy = ((0, 0), (2100, 2100))
|
||||
temp = -90
|
||||
if not data.month_data.group_by:
|
||||
pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw = ImageDraw.Draw(pie_image)
|
||||
pie_image_draw.ellipse(xy, fill=(128, 128, 128))
|
||||
else:
|
||||
pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw = ImageDraw.Draw(pie_image)
|
||||
for _index, i in enumerate(data.month_data.group_by):
|
||||
pie_image_draw.pieslice(
|
||||
xy,
|
||||
temp,
|
||||
temp + (i.percent / 100) * 360,
|
||||
COLOR_MAP[i.action_name],
|
||||
)
|
||||
temp = temp + (i.percent / 100) * 360
|
||||
# 绘制蒙版圆形
|
||||
new_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw.ellipse((150, 150, 1950, 1950), fill=(255, 255, 255, 0))
|
||||
|
||||
position = (1050, 1050)
|
||||
pie_image.paste(new_image, position, mask=new_image)
|
||||
result_pie = pie_image.resize((210, 210))
|
||||
img.paste(result_pie, (138, 618), result_pie)
|
||||
|
||||
if last_monthly_data:
|
||||
pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw = ImageDraw.Draw(pie_image)
|
||||
for _index, i in enumerate(last_monthly_data.month_data.group_by):
|
||||
pie_image_draw.pieslice(
|
||||
xy,
|
||||
temp,
|
||||
temp + (i.percent / 100) * 360,
|
||||
COLOR_MAP[i.action_name],
|
||||
)
|
||||
temp = temp + (i.percent / 100) * 360
|
||||
else:
|
||||
pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw = ImageDraw.Draw(pie_image)
|
||||
pie_image_draw.ellipse(xy, fill=(128, 128, 128))
|
||||
|
||||
# 绘制蒙版圆形
|
||||
new_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw.ellipse((150, 150, 1950, 1950), fill=(255, 255, 255, 0))
|
||||
|
||||
position = (1050, 1050)
|
||||
pie_image.paste(new_image, position, mask=new_image)
|
||||
result_pie = pie_image.resize((210, 210))
|
||||
img.paste(result_pie, (138, 618 + 350), result_pie)
|
||||
|
||||
img = await convert_img(img)
|
||||
logger.info('[开拓月历] 图片绘制完成!等待发送...')
|
||||
return img
|
||||
|
||||
|
||||
async def int_carry(i: int) -> str:
|
||||
if i >= 100000:
|
||||
i_str = f'{i / 10000:.1f}W'
|
||||
else:
|
||||
i_str = str(i)
|
||||
return i_str
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
from datetime import datetime
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
from msgspec import json as msgjson
|
||||
from gsuid_core.logger import logger
|
||||
|
||||
from ..utils.mys_api import mys_api
|
||||
from ..utils.error_reply import get_error
|
||||
from ..utils.image.convert import convert_img
|
||||
from ..utils.resource.RESOURCE_PATH import PLAYER_PATH
|
||||
from ..utils.fonts.starrail_fonts import sr_font_20, sr_font_28, sr_font_34
|
||||
|
||||
TEXT_PATH = Path(__file__).parent / 'texture2d'
|
||||
|
||||
monthly_bg = Image.open(TEXT_PATH / 'monthly_bg.png')
|
||||
avatar_default = Image.open(TEXT_PATH / '200101.png')
|
||||
|
||||
first_color = (29, 29, 29)
|
||||
second_color = (67, 61, 56)
|
||||
second_color2 = (98, 98, 98)
|
||||
black_color = (54, 54, 54)
|
||||
white_color = (213, 213, 213)
|
||||
|
||||
COLOR_MAP = {
|
||||
'每日活跃': (248, 227, 157),
|
||||
'活动奖励': (99, 231, 176),
|
||||
'冒险奖励': (114, 205, 251),
|
||||
'模拟宇宙奖励': (160, 149, 248),
|
||||
'忘却之庭奖励': (221, 119, 250),
|
||||
'邮件奖励': (244, 110, 104),
|
||||
'其他': (255, 242, 200),
|
||||
'Daily Activity': (248, 227, 157),
|
||||
'Events': (99, 231, 176),
|
||||
'Adventure': (114, 205, 251),
|
||||
'moni': (160, 149, 248),
|
||||
'Spiral Abyss': (221, 119, 250),
|
||||
'Quests': (244, 110, 104),
|
||||
'Other': (255, 242, 200),
|
||||
}
|
||||
|
||||
|
||||
async def draw_note_img(sr_uid: str) -> Union[bytes, str]:
|
||||
path = PLAYER_PATH / str(sr_uid)
|
||||
if not path.exists():
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 获取当前时间
|
||||
now = datetime.now()
|
||||
current_year_mon = now.strftime('%Y-%m')
|
||||
add_month = ''
|
||||
if int(now.month) < 10:
|
||||
add_month = '0'
|
||||
now_month = str(now.year) + str(add_month) + str(now.month)
|
||||
# 获取数据
|
||||
data = await mys_api.get_award(sr_uid, now_month)
|
||||
if isinstance(data, int):
|
||||
return get_error(data)
|
||||
|
||||
# 保存数据
|
||||
with Path.open(
|
||||
path / f'monthly_{current_year_mon}.json', 'w', encoding='utf-8'
|
||||
) as f:
|
||||
save_json_data = msgjson.format(msgjson.encode(data), indent=4)
|
||||
save_data = json.dumps(
|
||||
{
|
||||
'data_time': now.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'data': save_json_data.decode('utf-8'),
|
||||
},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
f.write(save_data)
|
||||
|
||||
# 获取上月数据
|
||||
last_month = now.month - 1
|
||||
last_year = now.year
|
||||
if last_month == 0:
|
||||
last_month = 12
|
||||
last_year -= 1
|
||||
last_year_mon = f'{last_year}-{last_month:02d}'
|
||||
last_monthly_path = path / f'monthly_{last_year_mon}.json'
|
||||
if last_monthly_path.exists():
|
||||
with Path.open(last_monthly_path, encoding='utf-8') as f:
|
||||
last_monthly_data = json.load(f)
|
||||
last_monthly_data = last_monthly_data['data']
|
||||
else:
|
||||
add_month = ''
|
||||
if int(last_month) < 10:
|
||||
add_month = '0'
|
||||
find_last_month = str(last_year) + str(add_month) + str(last_month)
|
||||
last_monthly_data = await mys_api.get_award(sr_uid, find_last_month)
|
||||
if isinstance(last_monthly_data, int):
|
||||
return get_error(last_monthly_data)
|
||||
|
||||
# nickname and level
|
||||
role_basic_info = await mys_api.get_role_basic_info(sr_uid)
|
||||
if isinstance(role_basic_info, int):
|
||||
return get_error(role_basic_info)
|
||||
nickname = role_basic_info.nickname
|
||||
|
||||
day_hcoin = data.day_data.current_hcoin
|
||||
day_rails_pass = data.day_data.current_rails_pass
|
||||
lastday_hcoin = 0
|
||||
lastday_rails_pass = 0
|
||||
if int(sr_uid[0]) < 6:
|
||||
lastday_hcoin = data.day_data.last_hcoin
|
||||
lastday_rails_pass = data.day_data.last_rails_pass
|
||||
month_hcoin = data.month_data.current_hcoin
|
||||
month_rails_pass = data.month_data.current_rails_pass
|
||||
lastmonth_hcoin = data.month_data.last_hcoin
|
||||
lastmonth_rails_pass = data.month_data.last_rails_pass
|
||||
|
||||
day_hcoin_str = await int_carry(day_hcoin)
|
||||
day_rails_pass_str = await int_carry(day_rails_pass)
|
||||
month_hcoin_str = await int_carry(month_hcoin)
|
||||
month_rails_pass_str = await int_carry(month_rails_pass)
|
||||
lastday_hcoin_str = await int_carry(lastday_hcoin)
|
||||
lastday_rails_pass_str = await int_carry(lastday_rails_pass)
|
||||
lastmonth_hcoin_str = await int_carry(lastmonth_hcoin)
|
||||
lastmonth_rails_pass_str = await int_carry(lastmonth_rails_pass)
|
||||
|
||||
img = monthly_bg.copy()
|
||||
avatar_img = avatar_default.copy()
|
||||
char_pic = avatar_img.convert('RGBA').resize(
|
||||
(125, 125),
|
||||
Image.Resampling.LANCZOS, # type: ignore
|
||||
)
|
||||
img.paste(char_pic, (115, 133), char_pic)
|
||||
img_draw = ImageDraw.Draw(img)
|
||||
|
||||
# 写Nickname
|
||||
img_draw.text(
|
||||
(310, 184), nickname, font=sr_font_34, fill=first_color, anchor='lm'
|
||||
)
|
||||
|
||||
# 写UID
|
||||
img_draw.text(
|
||||
(267, 219),
|
||||
f'UID {sr_uid}',
|
||||
font=sr_font_20,
|
||||
fill=second_color2,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写本日星琼
|
||||
img_draw.text(
|
||||
(283, 326),
|
||||
day_hcoin_str,
|
||||
font=sr_font_28,
|
||||
fill=white_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写本月星琼
|
||||
img_draw.text(
|
||||
(513, 326),
|
||||
month_hcoin_str,
|
||||
font=sr_font_28,
|
||||
fill=white_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写昨日星琼
|
||||
img_draw.text(
|
||||
(283, 366),
|
||||
lastday_hcoin_str,
|
||||
font=sr_font_28,
|
||||
fill=black_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写上月星琼
|
||||
img_draw.text(
|
||||
(513, 366),
|
||||
lastmonth_hcoin_str,
|
||||
font=sr_font_28,
|
||||
fill=black_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写本日铁票
|
||||
img_draw.text(
|
||||
(283, 431),
|
||||
day_rails_pass_str,
|
||||
font=sr_font_28,
|
||||
fill=white_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写本月铁票
|
||||
img_draw.text(
|
||||
(513, 431),
|
||||
month_rails_pass_str,
|
||||
font=sr_font_28,
|
||||
fill=white_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写昨日铁票
|
||||
img_draw.text(
|
||||
(283, 473),
|
||||
lastday_rails_pass_str,
|
||||
font=sr_font_28,
|
||||
fill=black_color,
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
# 写上月铁票
|
||||
img_draw.text(
|
||||
(513, 473),
|
||||
lastmonth_rails_pass_str,
|
||||
font=sr_font_28,
|
||||
fill=black_color,
|
||||
anchor='lm',
|
||||
)
|
||||
xy = ((0, 0), (2100, 2100))
|
||||
temp = -90
|
||||
if not data.month_data.group_by:
|
||||
pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw = ImageDraw.Draw(pie_image)
|
||||
pie_image_draw.ellipse(xy, fill=(128, 128, 128))
|
||||
else:
|
||||
pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw = ImageDraw.Draw(pie_image)
|
||||
for _index, i in enumerate(data.month_data.group_by):
|
||||
pie_image_draw.pieslice(
|
||||
xy,
|
||||
temp,
|
||||
temp + (i.percent / 100) * 360,
|
||||
COLOR_MAP[i.action_name],
|
||||
)
|
||||
temp = temp + (i.percent / 100) * 360
|
||||
# 绘制蒙版圆形
|
||||
new_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw.ellipse((150, 150, 1950, 1950), fill=(255, 255, 255, 0))
|
||||
|
||||
position = (1050, 1050)
|
||||
pie_image.paste(new_image, position, mask=new_image)
|
||||
result_pie = pie_image.resize((210, 210))
|
||||
img.paste(result_pie, (138, 618), result_pie)
|
||||
|
||||
if last_monthly_data:
|
||||
pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw = ImageDraw.Draw(pie_image)
|
||||
for _index, i in enumerate(last_monthly_data.month_data.group_by):
|
||||
pie_image_draw.pieslice(
|
||||
xy,
|
||||
temp,
|
||||
temp + (i.percent / 100) * 360,
|
||||
COLOR_MAP[i.action_name],
|
||||
)
|
||||
temp = temp + (i.percent / 100) * 360
|
||||
else:
|
||||
pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw = ImageDraw.Draw(pie_image)
|
||||
pie_image_draw.ellipse(xy, fill=(128, 128, 128))
|
||||
|
||||
# 绘制蒙版圆形
|
||||
new_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0))
|
||||
pie_image_draw.ellipse((150, 150, 1950, 1950), fill=(255, 255, 255, 0))
|
||||
|
||||
position = (1050, 1050)
|
||||
pie_image.paste(new_image, position, mask=new_image)
|
||||
result_pie = pie_image.resize((210, 210))
|
||||
img.paste(result_pie, (138, 618 + 350), result_pie)
|
||||
|
||||
img = await convert_img(img)
|
||||
logger.info('[开拓月历] 图片绘制完成!等待发送...')
|
||||
return img
|
||||
|
||||
|
||||
async def int_carry(i: int) -> str:
|
||||
if i >= 100000:
|
||||
i_str = f'{i / 10000:.1f}W'
|
||||
else:
|
||||
i_str = str(i)
|
||||
return i_str
|
||||
|
@ -17,5 +17,7 @@ async def send_download_resource_msg(bot: Bot, ev: Event):
|
||||
|
||||
|
||||
async def startup():
|
||||
logger.info('[sr资源文件下载] 正在检查与下载缺失的资源文件,可能需要较长时间,请稍等')
|
||||
logger.info(
|
||||
'[sr资源文件下载] 正在检查与下载缺失的资源文件,可能需要较长时间,请稍等'
|
||||
)
|
||||
logger.info(f'[sr资源文件下载] {await download_all_resource()}')
|
||||
|
@ -65,7 +65,9 @@ async def send_daily_sign():
|
||||
single['msg'], 'direct', qid, single['bot_id'], '', ''
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f'[SR每日全部签到] QQ {qid} 私聊推送失败!错误信息:{e}')
|
||||
logger.warning(
|
||||
f'[SR每日全部签到] QQ {qid} 私聊推送失败!错误信息:{e}'
|
||||
)
|
||||
await asyncio.sleep(0.5)
|
||||
logger.info('[SR每日全部签到]私聊推送完成')
|
||||
|
||||
@ -74,7 +76,9 @@ async def send_daily_sign():
|
||||
# 根据succee数判断是否为简洁推送
|
||||
if group_msg_list[gid]['success'] >= 0:
|
||||
report = (
|
||||
'以下为签到失败报告:{}'.format(group_msg_list[gid]['push_message'])
|
||||
'以下为签到失败报告:{}'.format(
|
||||
group_msg_list[gid]['push_message']
|
||||
)
|
||||
if group_msg_list[gid]['push_message'] != ''
|
||||
else ''
|
||||
)
|
||||
|
@ -57,11 +57,15 @@ async def sign_in(sr_uid: str) -> str:
|
||||
Header['x-rpc-challenge'] = ch
|
||||
Header['x-rpc-validate'] = vl
|
||||
Header['x-rpc-seccode'] = f'{vl}|jordan'
|
||||
logger.info(f'[SR签到] {sr_uid} 已获取验证码, 等待时间{delay}秒')
|
||||
logger.info(
|
||||
f'[SR签到] {sr_uid} 已获取验证码, 等待时间{delay}秒'
|
||||
)
|
||||
await asyncio.sleep(delay)
|
||||
else:
|
||||
delay = 605 + random.randint(1, 120)
|
||||
logger.info(f'[SR签到] {sr_uid} 未获取验证码,等待{delay}秒后重试...')
|
||||
logger.info(
|
||||
f'[SR签到] {sr_uid} 未获取验证码,等待{delay}秒后重试...'
|
||||
)
|
||||
await asyncio.sleep(delay)
|
||||
continue
|
||||
logger.info('配置文件暂未开启[跳过无感验证],结束本次任务...')
|
||||
@ -70,7 +74,9 @@ async def sign_in(sr_uid: str) -> str:
|
||||
if index == 0:
|
||||
logger.info(f'[SR签到] {sr_uid} 该用户无校验码!')
|
||||
else:
|
||||
logger.info(f'[SR签到] [无感验证] {sr_uid} 该用户重试 {index} 次验证成功!')
|
||||
logger.info(
|
||||
f'[SR签到] [无感验证] {sr_uid} 该用户重试 {index} 次验证成功!'
|
||||
)
|
||||
break
|
||||
if (int(str(sr_uid)[0]) > 5) and (sign_data.code == 'ok'):
|
||||
# 国际服签到无risk_code字段
|
||||
@ -103,7 +109,9 @@ async def sign_in(sr_uid: str) -> str:
|
||||
sign_missed -= 1
|
||||
sign_missed = sign_info.sign_cnt_missed or sign_missed
|
||||
im = f'{mes_im}!\n{get_im}\n本月漏签次数:{sign_missed}'
|
||||
logger.info(f'[SR签到] {sr_uid} 签到完成, 结果: {mes_im}, 漏签次数: {sign_missed}')
|
||||
logger.info(
|
||||
f'[SR签到] {sr_uid} 签到完成, 结果: {mes_im}, 漏签次数: {sign_missed}'
|
||||
)
|
||||
return im
|
||||
|
||||
|
||||
@ -163,7 +171,9 @@ async def daily_sign():
|
||||
delay = 1
|
||||
else:
|
||||
delay = 50 + random.randint(3, 45)
|
||||
logger.info(f'[SR签到] 已签到{len(tasks)}个用户, 等待{delay}秒进行下一次签到')
|
||||
logger.info(
|
||||
f'[SR签到] 已签到{len(tasks)}个用户, 等待{delay}秒进行下一次签到'
|
||||
)
|
||||
tasks.clear()
|
||||
already = 0
|
||||
await asyncio.sleep(delay)
|
||||
|
@ -69,7 +69,8 @@ async def _draw_task_img(
|
||||
avatar_url = char.avatars[i]
|
||||
image = await download_image(avatar_url)
|
||||
char_pic = image.convert('RGBA').resize(
|
||||
(40, 40), Image.Resampling.LANCZOS # type: ignore
|
||||
(40, 40),
|
||||
Image.Resampling.LANCZOS, # type: ignore
|
||||
)
|
||||
note_travel_img.paste(char_pic, (495 + 68 * i, 20), char_pic)
|
||||
img.paste(note_travel_img, (0, 790 + index * 80), note_travel_img)
|
||||
|
@ -27,7 +27,12 @@ async def send_bind_card(bot: Bot, ev: Event):
|
||||
|
||||
|
||||
@sv_user_info.on_command(
|
||||
(f'{PREFIX}绑定uid', f'{PREFIX}切换uid', f'{PREFIX}删除uid', f'{PREFIX}解绑uid')
|
||||
(
|
||||
f'{PREFIX}绑定uid',
|
||||
f'{PREFIX}切换uid',
|
||||
f'{PREFIX}删除uid',
|
||||
f'{PREFIX}解绑uid',
|
||||
)
|
||||
)
|
||||
async def send_link_uid_msg(bot: Bot, ev: Event):
|
||||
await bot.logger.info('sr开始执行[绑定/解绑用户信息]')
|
||||
|
@ -81,7 +81,9 @@ async def download_all_file_from_cos():
|
||||
or not Path.stat(path).st_size
|
||||
or not is_diff
|
||||
):
|
||||
logger.info(f'[cos]开始下载[{resource_type}]_[{name}]...')
|
||||
logger.info(
|
||||
f'[cos]开始下载[{resource_type}]_[{name}]...'
|
||||
)
|
||||
temp_num += 1
|
||||
if isinstance(url, int):
|
||||
logger.error(
|
||||
@ -119,4 +121,6 @@ async def download_all_file_from_cos():
|
||||
await _download(TASKS)
|
||||
await _download(TASKS)
|
||||
if count := len(failed_list):
|
||||
logger.error(f'[cos]仍有{count}个文件未下载,请使用命令 `下载全部资源` 重新下载')
|
||||
logger.error(
|
||||
f'[cos]仍有{count}个文件未下载,请使用命令 `下载全部资源` 重新下载'
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user