mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
commit
066a158dba
@ -1 +1 @@
|
||||
from .api import get_card_resources, get_match_card, CARD_API, get_all_specialty, get_match_specialty
|
||||
from .api import get_card_resources, get_match_card, CARD_API, get_all_specialty, get_match_specialty, get_atlas_full_path
|
||||
|
@ -8,7 +8,7 @@ from LittlePaimon.utils.requests import aiorequests
|
||||
|
||||
CARD_RESOURCES_API = '{proxy}https://raw.githubusercontent.com/Nwflower/Atlas/master/resource/text/card.yaml'
|
||||
CARD_API = '{proxy}https://raw.githubusercontent.com/Nwflower/genshin-atlas/master/card/{name}.png'
|
||||
SPECIALTY_RESOURCES_API = '{proxy}https://raw.githubusercontent.com/Nwflower/genshin-atlas/master/path.json'
|
||||
RESOURCES_API = '{proxy}https://raw.githubusercontent.com/Nwflower/genshin-atlas/master/path.json'
|
||||
|
||||
|
||||
async def get_card_resources() -> Optional[dict]:
|
||||
@ -20,6 +20,14 @@ async def get_card_resources() -> Optional[dict]:
|
||||
return None
|
||||
|
||||
|
||||
async def get_atlas_full_path(name: str, type: str) -> str:
|
||||
with contextlib.suppress(Exception):
|
||||
resp = await aiorequests.get(RESOURCES_API.format(proxy=config.github_proxy))
|
||||
data = resp.json()
|
||||
return data[type][name]
|
||||
return name
|
||||
|
||||
|
||||
async def get_match_card(name: str) -> Optional[list]:
|
||||
if not (data := await get_card_resources()):
|
||||
return None
|
||||
@ -33,14 +41,14 @@ async def get_match_card(name: str) -> Optional[list]:
|
||||
|
||||
async def get_all_specialty() -> Optional[list]:
|
||||
with contextlib.suppress(Exception):
|
||||
resp = await aiorequests.get(SPECIALTY_RESOURCES_API.format(proxy=config.github_proxy))
|
||||
resp = await aiorequests.get(RESOURCES_API.format(proxy=config.github_proxy))
|
||||
return resp.json()['specialty'].keys()
|
||||
return None
|
||||
|
||||
|
||||
async def get_match_specialty(name: str) -> Optional[list]:
|
||||
with contextlib.suppress(Exception):
|
||||
resp = await aiorequests.get(SPECIALTY_RESOURCES_API.format(proxy=config.github_proxy))
|
||||
resp = await aiorequests.get(RESOURCES_API.format(proxy=config.github_proxy))
|
||||
data = resp.json()['specialty']
|
||||
return (
|
||||
difflib.get_close_matches(name, list(data.keys()), cutoff=0.6, n=10)
|
||||
|
@ -21,7 +21,7 @@ from LittlePaimon.utils.typing import COMMAND_START_RE
|
||||
from .draw_daily_material import draw_material
|
||||
from .draw_map import init_map, draw_map, get_full_map
|
||||
from .SereniteaPot import draw_pot_materials
|
||||
from .Atlas import get_match_card, get_card_resources, get_match_specialty, get_all_specialty
|
||||
from .Atlas import get_match_card, get_card_resources, get_match_specialty, get_all_specialty, get_atlas_full_path
|
||||
from .wiki_api import API
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
@ -304,6 +304,8 @@ async def _(bot: Bot, event: MessageEvent, state: T_State, type: str = Arg('type
|
||||
temp_type = list(matches.keys())[0]
|
||||
if type in {'材料', '攻略', '图鉴'}:
|
||||
type = f'{temp_type}图鉴' if temp_type != '角色' else f'{temp_type}{type}'
|
||||
if type == '七圣召唤图鉴':
|
||||
final_name = (await get_atlas_full_path(final_name, 'card')).replace('/card/', '').rstrip('.png')
|
||||
try:
|
||||
await total_wiki.finish(
|
||||
MessageSegment.image(API[type].format(proxy=config.github_proxy, name=final_name)))
|
||||
@ -371,6 +373,8 @@ async def _(state: T_State, matches: dict = Arg('matches'), choice: str = ArgPla
|
||||
type = f'{key}图鉴' if key != '角色' else f'{key}{type}'
|
||||
break
|
||||
if final_name:
|
||||
if type == '七圣召唤图鉴':
|
||||
final_name = (await get_atlas_full_path(final_name, 'card')).replace('/card/', '').rstrip('.png')
|
||||
try:
|
||||
await total_wiki.finish(
|
||||
MessageSegment.image(API[type].format(proxy=config.github_proxy, name=final_name)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user