mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-08 21:15:52 +08:00
✨ 新增材料路线图, 可用类似树王圣体菇路线
命令触发
This commit is contained in:
parent
cda8a68c81
commit
1e162d58fd
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -31,5 +31,6 @@
|
|||||||
],
|
],
|
||||||
"python.analysis.include": [
|
"python.analysis.include": [
|
||||||
"${workspaceFolder}/../../../"
|
"${workspaceFolder}/../../../"
|
||||||
]
|
],
|
||||||
|
"python.analysis.autoImportCompletions": true
|
||||||
}
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 814 KiB After Width: | Height: | Size: 865 KiB |
Binary file not shown.
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 133 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
@ -3,6 +3,7 @@ from re import findall
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Literal
|
from typing import List, Literal
|
||||||
|
|
||||||
|
import aiofiles
|
||||||
from httpx import get
|
from httpx import get
|
||||||
from PIL import Image, ImageDraw
|
from PIL import Image, ImageDraw
|
||||||
from gsuid_core.utils.api.ambr.request import get_ambr_event_info
|
from gsuid_core.utils.api.ambr.request import get_ambr_event_info
|
||||||
@ -10,11 +11,12 @@ from gsuid_core.utils.api.ambr.request import get_ambr_event_info
|
|||||||
from ..version import Genshin_version
|
from ..version import Genshin_version
|
||||||
from ..utils.image.convert import convert_img
|
from ..utils.image.convert import convert_img
|
||||||
from ..utils.image.image_tools import get_color_bg
|
from ..utils.image.image_tools import get_color_bg
|
||||||
from ..utils.fonts.genshin_fonts import genshin_font_origin
|
from ..utils.resource.RESOURCE_PATH import TEMP_PATH
|
||||||
|
from ..utils.fonts.genshin_fonts import gs_font_26, gs_font_62
|
||||||
|
|
||||||
TEXT_PATH = Path(__file__).parent / 'texture2d'
|
TEXT_PATH = Path(__file__).parent / 'texture2d'
|
||||||
EVENT_IMG_PATH = Path(__file__).parent / 'event.jpg'
|
EVENT_IMG_PATH = TEMP_PATH / 'event.jpg'
|
||||||
GACHA_IMG_PATH = Path(__file__).parent / 'gacha.jpg'
|
GACHA_IMG_PATH = TEMP_PATH / 'gacha.jpg'
|
||||||
|
|
||||||
PATTERN = r'<[a-zA-Z]+.*?>([\s\S]*?)</[a-zA-Z]*?>'
|
PATTERN = r'<[a-zA-Z]+.*?>([\s\S]*?)</[a-zA-Z]*?>'
|
||||||
|
|
||||||
@ -105,11 +107,6 @@ class DrawEventList:
|
|||||||
base_h = 100 + len(self.normal_event) * 380
|
base_h = 100 + len(self.normal_event) * 380
|
||||||
base_img = await get_color_bg(950, base_h)
|
base_img = await get_color_bg(950, base_h)
|
||||||
|
|
||||||
font_l = genshin_font_origin(62)
|
|
||||||
# font_m = genshin_font_origin(34)
|
|
||||||
font_s = genshin_font_origin(26)
|
|
||||||
|
|
||||||
# now_time = datetime.now().strftime('%Y/%m/%d')
|
|
||||||
event_cover = Image.open(TEXT_PATH / 'normal_event_cover.png')
|
event_cover = Image.open(TEXT_PATH / 'normal_event_cover.png')
|
||||||
|
|
||||||
for index, value in enumerate(self.normal_event):
|
for index, value in enumerate(self.normal_event):
|
||||||
@ -123,7 +120,11 @@ class DrawEventList:
|
|||||||
|
|
||||||
# 写标题
|
# 写标题
|
||||||
event_img_draw.text(
|
event_img_draw.text(
|
||||||
(475, 47), value['full_name'], text_color, font_s, 'mm'
|
(475, 47),
|
||||||
|
value['full_name'],
|
||||||
|
text_color,
|
||||||
|
gs_font_26,
|
||||||
|
'mm',
|
||||||
)
|
)
|
||||||
# 纠错
|
# 纠错
|
||||||
if isinstance(value['start_time'], str):
|
if isinstance(value['start_time'], str):
|
||||||
@ -143,28 +144,28 @@ class DrawEventList:
|
|||||||
(74, 149),
|
(74, 149),
|
||||||
value['start_time'][0],
|
value['start_time'][0],
|
||||||
text_color,
|
text_color,
|
||||||
font_l,
|
gs_font_62,
|
||||||
anchor='lm',
|
anchor='lm',
|
||||||
)
|
)
|
||||||
event_img_draw.text(
|
event_img_draw.text(
|
||||||
(74, 191),
|
(74, 191),
|
||||||
value['start_time'][1],
|
value['start_time'][1],
|
||||||
text_color,
|
text_color,
|
||||||
font_s,
|
gs_font_26,
|
||||||
anchor='lm',
|
anchor='lm',
|
||||||
)
|
)
|
||||||
event_img_draw.text(
|
event_img_draw.text(
|
||||||
(115, 275),
|
(115, 275),
|
||||||
value['end_time'][0],
|
value['end_time'][0],
|
||||||
text_color,
|
text_color,
|
||||||
font_l,
|
gs_font_62,
|
||||||
anchor='lm',
|
anchor='lm',
|
||||||
)
|
)
|
||||||
event_img_draw.text(
|
event_img_draw.text(
|
||||||
(115, 318),
|
(115, 318),
|
||||||
value['end_time'][1],
|
value['end_time'][1],
|
||||||
text_color,
|
text_color,
|
||||||
font_s,
|
gs_font_26,
|
||||||
anchor='lm',
|
anchor='lm',
|
||||||
)
|
)
|
||||||
event_img.paste(event_cover, (0, 0), event_cover)
|
event_img.paste(event_cover, (0, 0), event_cover)
|
||||||
@ -182,11 +183,6 @@ class DrawEventList:
|
|||||||
base_h = 100 + len(self.gacha_event) * 480
|
base_h = 100 + len(self.gacha_event) * 480
|
||||||
base_img = await get_color_bg(950, base_h)
|
base_img = await get_color_bg(950, base_h)
|
||||||
|
|
||||||
font_l = genshin_font_origin(62)
|
|
||||||
# font_m = genshin_font_origin(34)
|
|
||||||
font_s = genshin_font_origin(26)
|
|
||||||
|
|
||||||
# now_time = datetime.now().strftime('%Y/%m/%d')
|
|
||||||
gacha_cover = Image.open(TEXT_PATH / 'gacha_event_cover.png')
|
gacha_cover = Image.open(TEXT_PATH / 'gacha_event_cover.png')
|
||||||
|
|
||||||
for index, value in enumerate(self.gacha_event):
|
for index, value in enumerate(self.gacha_event):
|
||||||
@ -200,7 +196,11 @@ class DrawEventList:
|
|||||||
|
|
||||||
# 写标题
|
# 写标题
|
||||||
gacha_img_draw.text(
|
gacha_img_draw.text(
|
||||||
(475, 47), value['full_name'], text_color, font_s, 'mm'
|
(475, 47),
|
||||||
|
value['full_name'],
|
||||||
|
text_color,
|
||||||
|
gs_font_26,
|
||||||
|
'mm',
|
||||||
)
|
)
|
||||||
# 纠错
|
# 纠错
|
||||||
if isinstance(value['start_time'], str):
|
if isinstance(value['start_time'], str):
|
||||||
@ -220,28 +220,28 @@ class DrawEventList:
|
|||||||
(74, 199),
|
(74, 199),
|
||||||
value['start_time'][0],
|
value['start_time'][0],
|
||||||
text_color,
|
text_color,
|
||||||
font_l,
|
gs_font_62,
|
||||||
anchor='lm',
|
anchor='lm',
|
||||||
)
|
)
|
||||||
gacha_img_draw.text(
|
gacha_img_draw.text(
|
||||||
(74, 241),
|
(74, 241),
|
||||||
value['start_time'][1],
|
value['start_time'][1],
|
||||||
text_color,
|
text_color,
|
||||||
font_s,
|
gs_font_26,
|
||||||
anchor='lm',
|
anchor='lm',
|
||||||
)
|
)
|
||||||
gacha_img_draw.text(
|
gacha_img_draw.text(
|
||||||
(115, 325),
|
(115, 325),
|
||||||
value['end_time'][0],
|
value['end_time'][0],
|
||||||
text_color,
|
text_color,
|
||||||
font_l,
|
gs_font_62,
|
||||||
anchor='lm',
|
anchor='lm',
|
||||||
)
|
)
|
||||||
gacha_img_draw.text(
|
gacha_img_draw.text(
|
||||||
(115, 368),
|
(115, 368),
|
||||||
value['end_time'][1],
|
value['end_time'][1],
|
||||||
text_color,
|
text_color,
|
||||||
font_s,
|
gs_font_26,
|
||||||
anchor='lm',
|
anchor='lm',
|
||||||
)
|
)
|
||||||
gacha_img.paste(gacha_cover, (0, 0), gacha_cover)
|
gacha_img.paste(gacha_cover, (0, 0), gacha_cover)
|
||||||
@ -266,12 +266,12 @@ async def get_all_event_img():
|
|||||||
async def get_event_img(event_type: Literal['EVENT', 'GACHA']) -> bytes:
|
async def get_event_img(event_type: Literal['EVENT', 'GACHA']) -> bytes:
|
||||||
if event_type == 'EVENT':
|
if event_type == 'EVENT':
|
||||||
if EVENT_IMG_PATH.exists():
|
if EVENT_IMG_PATH.exists():
|
||||||
with open(EVENT_IMG_PATH, 'rb') as f:
|
async with aiofiles.open(EVENT_IMG_PATH, 'rb') as f:
|
||||||
return f.read()
|
return await f.read()
|
||||||
else:
|
else:
|
||||||
if GACHA_IMG_PATH.exists():
|
if GACHA_IMG_PATH.exists():
|
||||||
with open(GACHA_IMG_PATH, 'rb') as f:
|
async with aiofiles.open(GACHA_IMG_PATH, 'rb') as f:
|
||||||
return f.read()
|
return await f.read()
|
||||||
|
|
||||||
event_list = DrawEventList()
|
event_list = DrawEventList()
|
||||||
await event_list.get_event_data()
|
await event_list.get_event_data()
|
||||||
|
@ -7,7 +7,7 @@ from gsuid_core.logger import logger
|
|||||||
from urllib3 import encode_multipart_formdata
|
from urllib3 import encode_multipart_formdata
|
||||||
from gsuid_core.utils.error_reply import get_error_img
|
from gsuid_core.utils.error_reply import get_error_img
|
||||||
from gsuid_core.utils.api.mys.api import GET_GACHA_LOG_URL
|
from gsuid_core.utils.api.mys.api import GET_GACHA_LOG_URL
|
||||||
from gsuid_core.utils.api.mys.request import RECOGNIZE_SERVER
|
from gsuid_core.utils.api.mys.base_request import RECOGNIZE_SERVER
|
||||||
|
|
||||||
from ..utils.mys_api import mys_api
|
from ..utils.mys_api import mys_api
|
||||||
from .export_and_import import export_gachalogs, import_gachalogs
|
from .export_and_import import export_gachalogs, import_gachalogs
|
||||||
|
@ -14,10 +14,18 @@ from ..version import Genshin_version
|
|||||||
from ..utils.image.convert import convert_img
|
from ..utils.image.convert import convert_img
|
||||||
from .get_new_abyss_data import get_review_data
|
from .get_new_abyss_data import get_review_data
|
||||||
from ..utils.resource.RESOURCE_PATH import REF_PATH
|
from ..utils.resource.RESOURCE_PATH import REF_PATH
|
||||||
|
from .get_bbs_post_guide import get_material_way_post
|
||||||
from ..utils.map.name_covert import alias_to_char_name
|
from ..utils.map.name_covert import alias_to_char_name
|
||||||
|
|
||||||
sv_char_guide = SV('查询角色攻略')
|
sv_char_guide = SV('查询角色攻略')
|
||||||
sv_abyss_review = SV('查询深渊阵容')
|
sv_abyss_review = SV('查询深渊阵容')
|
||||||
|
sv_bbs_post_guide = SV('查询BBS攻略')
|
||||||
|
|
||||||
|
|
||||||
|
@sv_bbs_post_guide.on_suffix(('路线'))
|
||||||
|
async def send_bbs_post_guide(bot: Bot, ev: Event):
|
||||||
|
name = ev.text.strip().replace('材料', '').replace('采集', '')
|
||||||
|
await bot.send(await get_material_way_post(name))
|
||||||
|
|
||||||
|
|
||||||
@sv_char_guide.on_prefix(('参考攻略', '攻略', '推荐'))
|
@sv_char_guide.on_prefix(('参考攻略', '攻略', '推荐'))
|
||||||
|
33
GenshinUID/genshinuid_guide/get_bbs_post_guide.py
Normal file
33
GenshinUID/genshinuid_guide/get_bbs_post_guide.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from gsuid_core.logger import logger
|
||||||
|
from gsuid_core.utils.cache import gs_cache
|
||||||
|
from gsuid_core.utils.error_reply import get_error
|
||||||
|
from gsuid_core.utils.image.mys.bbs import get_post_img
|
||||||
|
|
||||||
|
from ..utils.mys_api import mys_api
|
||||||
|
|
||||||
|
CID = '1386819'
|
||||||
|
colloctions = []
|
||||||
|
|
||||||
|
|
||||||
|
@gs_cache(14200)
|
||||||
|
async def get_material_way_post(name: str):
|
||||||
|
global colloctions
|
||||||
|
if not colloctions:
|
||||||
|
colloctions = await mys_api.get_bbs_collection(CID)
|
||||||
|
|
||||||
|
if isinstance(colloctions, int):
|
||||||
|
error = get_error(colloctions)
|
||||||
|
colloctions = []
|
||||||
|
return error
|
||||||
|
|
||||||
|
logger.info(f'[BBS_Guide] 合集存在, 开始获取攻略: {name}')
|
||||||
|
|
||||||
|
for c in colloctions:
|
||||||
|
post = c['post']
|
||||||
|
if name in post['subject']:
|
||||||
|
post_id = post['post_id']
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return '未找到该攻略, 等待补充, 或请检查输入材料名是否正确。'
|
||||||
|
|
||||||
|
return await get_post_img(post_id)
|
@ -30,6 +30,7 @@
|
|||||||
- [@Asgater](https://www.miyoushe.com/ys/accountCenter/postList?id=79695828) - 原牌图鉴的**授权**使用
|
- [@Asgater](https://www.miyoushe.com/ys/accountCenter/postList?id=79695828) - 原牌图鉴的**授权**使用
|
||||||
- [虚空数据库](https://akashadata.com/) - 深渊出场数据的**授权**使用
|
- [虚空数据库](https://akashadata.com/) - 深渊出场数据的**授权**使用
|
||||||
- [@祈鸢ya](https://www.miyoushe.com/ys/accountCenter/postList?id=137101761) - 「4.6~」原石预估数据图片的**授权**使用
|
- [@祈鸢ya](https://www.miyoushe.com/ys/accountCenter/postList?id=137101761) - 「4.6~」原石预估数据图片的**授权**使用
|
||||||
|
- [@燕返晓归](https://www.miyoushe.com/ys/accountCenter/postList?id=184505932) - 材料收集路线图的**授权**使用
|
||||||
- [@七月的休](https://www.miyoushe.com/ys/accountCenter/postList?id=218945821) - 「~4.5」原石预估数据图片的**授权**使用
|
- [@七月的休](https://www.miyoushe.com/ys/accountCenter/postList?id=218945821) - 「~4.5」原石预估数据图片的**授权**使用
|
||||||
- [玉衡杯深渊数据库](http://www.yuhengcup.top/abyss) - `版本深渊`功能数据提供
|
- [玉衡杯深渊数据库](http://www.yuhengcup.top/abyss) - `版本深渊`功能数据提供
|
||||||
- [@lgc233](https://github.com/lgc2333) - 众多优秀PR贡献
|
- [@lgc233](https://github.com/lgc2333) - 众多优秀PR贡献
|
||||||
|
Loading…
x
Reference in New Issue
Block a user