mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-06 19:53:45 +08:00
🎨 优化今日材料
(#292)
This commit is contained in:
parent
a69638520f
commit
66d84f09b3
@ -19,4 +19,4 @@ async def send_collection_info(bot: Bot, ev: Event):
|
||||
# 每日四点出头执行刷新材料图
|
||||
@scheduler.scheduled_job('cron', hour=4, minute=1)
|
||||
async def refresh_daily_cost():
|
||||
await draw_daily_cost_img()
|
||||
await draw_daily_cost_img(True)
|
||||
|
@ -20,11 +20,21 @@ from ..utils.resource.RESOURCE_PATH import (
|
||||
TEXT_PATH = Path(__file__).parent / 'texture2d'
|
||||
|
||||
|
||||
async def draw_daily_cost_img() -> Union[str, bytes]:
|
||||
path = TEMP_PATH / 'daily_cost.jpg'
|
||||
if path.exists():
|
||||
async def draw_daily_cost_img(is_force: bool = False) -> Union[str, bytes]:
|
||||
weekdays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
|
||||
|
||||
timestamp = time.time()
|
||||
timestamp -= 14400
|
||||
_t = time.localtime(timestamp)
|
||||
wk = time.strftime(weekdays[_t.tm_wday], _t)
|
||||
|
||||
path = TEMP_PATH / f'daily_cost_{wk}.jpg'
|
||||
if not is_force and path.exists():
|
||||
return await convert_img(Image.open(path))
|
||||
|
||||
if wk == '周日':
|
||||
return '今天是周日, 所有材料都能获得噢!'
|
||||
|
||||
data = await generate_daily_data()
|
||||
if data is None:
|
||||
return '获取信息错误...'
|
||||
@ -37,17 +47,11 @@ async def draw_daily_cost_img() -> Union[str, bytes]:
|
||||
|
||||
img = await get_color_bg(w, h)
|
||||
|
||||
weekdays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
|
||||
|
||||
timestamp = time.time()
|
||||
timestamp -= 14400
|
||||
_t = time.localtime(timestamp)
|
||||
|
||||
title = Image.open(TEXT_PATH / 'title.png')
|
||||
title_draw = ImageDraw.Draw(title)
|
||||
title_draw.text(
|
||||
(475, 474),
|
||||
f'今天是{time.strftime(weekdays[_t.tm_wday], _t)}哦!',
|
||||
f'今天是{wk}哦!',
|
||||
'black',
|
||||
gs_font_36,
|
||||
'mm',
|
||||
|
Loading…
x
Reference in New Issue
Block a user