修改srmrbug (#26)

* 修改srmrbug

* 修改srmrbug

* 修改srmrbug

* 修改月历上月数据画图

* 🚨 `pre-commit-ci`修复格式错误

* 修改bug

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
季落 2023-05-16 15:55:54 +08:00 committed by GitHub
parent bec0f16fdd
commit 8fd1216652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 298 additions and 273 deletions

View File

@ -49,9 +49,13 @@ async def draw_note_img(sr_uid: str) -> Union[bytes, str]:
# 获取当前时间
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)
print(now_month)
# 获取数据
data = await mys_api.get_award(sr_uid)
data = await mys_api.get_award(sr_uid, now_month)
if isinstance(data, int):
return get_error(data)
@ -79,8 +83,14 @@ async def draw_note_img(sr_uid: str) -> Union[bytes, str]:
if last_monthly_path.exists():
with open(last_monthly_path, 'r', encoding='utf-8') as f:
last_monthly_data = json.load(f)
last_monthly_data = last_monthly_data['data']
else:
last_monthly_data = None
add_month = ''
if int(last_month) < 10:
add_month = '0'
find_last_month = str(last_year) + str(add_month) + str(last_month)
print(find_last_month)
last_monthly_data = await mys_api.get_award(sr_uid, find_last_month)
# nickname and level
role_basic_info = await mys_api.get_role_basic_info(sr_uid)
@ -231,9 +241,7 @@ async def draw_note_img(sr_uid: str) -> Union[bytes, str]:
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['data']['month_data']['group_by']
):
for index, i in enumerate(last_monthly_data['month_data']['group_by']):
pie_image_draw.pieslice(
xy,
temp,

View File

@ -9,7 +9,6 @@ from gsuid_core.logger import logger
from ..utils.api import get_sqla
from ..utils.mys_api import mys_api
from ..utils.error_reply import get_error
from ..utils.image.convert import convert_img
from ..sruid_utils.api.mys.models import Expedition
from ..utils.fonts.starrail_fonts import (
@ -24,6 +23,7 @@ TEXT_PATH = Path(__file__).parent / 'texture2D'
note_bg = Image.open(TEXT_PATH / 'note_bg.png')
note_travel_bg = Image.open(TEXT_PATH / 'note_travel_bg.png')
warn_pic = Image.open(TEXT_PATH / 'warn.png')
based_w = 700
based_h = 1200
@ -148,7 +148,24 @@ async def draw_resin_img(sr_uid: str) -> Image.Image:
img = note_bg.copy()
if isinstance(daily_data, int):
return get_error(daily_data)
img_draw = ImageDraw.Draw(img)
img.paste(warn_pic, (0, 0), warn_pic)
# 写UID
img_draw.text(
(250, 553),
f'UID{sr_uid}',
font=sr_font_26,
fill=first_color,
anchor='mm',
)
img_draw.text(
(250, 518),
f'错误码 {daily_data}',
font=sr_font_26,
fill=red_color,
anchor='mm',
)
return img
# nickname and level
role_basic_info = await mys_api.get_role_basic_info(sr_uid)

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

View File

@ -206,7 +206,7 @@ class MysApi(_MysApi):
data = cast(MysSign, data['data'])
return data
async def get_award(self, sr_uid) -> Union[MonthlyAward, int]:
async def get_award(self, sr_uid, month) -> Union[MonthlyAward, int]:
server_id = RECOGNIZE_SERVER.get(str(sr_uid)[0])
ck = await self.get_ck(sr_uid, 'OWNER')
if ck is None:
@ -220,7 +220,7 @@ class MysApi(_MysApi):
url=_API['STAR_RAIL_MONTH_INFO_URL'],
method='GET',
header=HEADER,
params={'uid': sr_uid, 'region': server_id, 'month': ''},
params={'uid': sr_uid, 'region': server_id, 'month': month},
)
else:
HEADER = copy.deepcopy(self._HEADER_OS)
@ -231,7 +231,7 @@ class MysApi(_MysApi):
url=_API['STAR_RAIL_MONTH_INFO_URL'],
method='GET',
header=HEADER,
params={'uid': sr_uid, 'region': server_id, 'month': ''},
params={'uid': sr_uid, 'region': server_id, 'month': month},
use_proxy=True,
)
if isinstance(data, Dict):