✨ v0.2.4 圣遗物详情
This commit is contained in:
parent
8247c81483
commit
5d93a2bb29
@ -39,6 +39,10 @@ Bot 实例: [@Genshin_All_Info_Bot](https://t.me/Genshin_All_Info_Bot)
|
||||
|
||||
## 特别感谢
|
||||
|
||||
[GenshinUID](https://github.com/KimigaiiWuyi/GenshinUID)
|
||||
|
||||
[Genshin_Impact_bot](https://github.com/H-K-Y/Genshin_Impact_bot)
|
||||
|
||||
[PaimonBot](https://github.com/XiaoMiku01/PaimonBot)
|
||||
|
||||
[YuanShen_User_Info](https://github.com/Womsxd/YuanShen_User_Info)
|
||||
|
60
defs/artifacts.py
Normal file
60
defs/artifacts.py
Normal file
@ -0,0 +1,60 @@
|
||||
from io import BytesIO
|
||||
from os import sep
|
||||
import requests, yaml, re
|
||||
from json.decoder import JSONDecodeError
|
||||
from PIL import Image
|
||||
from defs.character import repl
|
||||
from defs.weapons import headers
|
||||
|
||||
|
||||
def get_url(name: str):
|
||||
res = requests.get(url=f'https://api.minigg.cn/artifacts?query={name}', headers=headers)
|
||||
if res.text == "undefined\n":
|
||||
raise JSONDecodeError("", "", 0)
|
||||
py_dict = yaml.safe_load(re.sub(r'\[? *(, *)+\]?', repl, res.text))
|
||||
return py_dict
|
||||
|
||||
|
||||
def gen_artifacts(data: dict):
|
||||
base_img = Image.new(mode="RGBA", size=(1280, 256), color=(255, 255, 255))
|
||||
for index, value in enumerate(data):
|
||||
img = Image.open(BytesIO(requests.get(data[value]).content))
|
||||
base_img.paste(img, (256 * index, 0))
|
||||
|
||||
jpg_img = Image.new('RGB', size=(1280, 256), color=(255, 255, 255))
|
||||
jpg_img.paste(base_img, (0, 0), mask=base_img)
|
||||
jpg_img.save(f'temp{sep}artifacts.jpg', format='JPEG', subsampling=0, quality=90)
|
||||
|
||||
|
||||
async def get_artifacts(name: str):
|
||||
artifacts_im = '''<b>{}</b>
|
||||
【稀有度】:{}
|
||||
【2件套】:{}
|
||||
【4件套】:{}
|
||||
【{}】:{}
|
||||
【{}】:{}
|
||||
【{}】:{}
|
||||
【{}】:{}
|
||||
【{}】:{}
|
||||
'''
|
||||
try:
|
||||
data = get_url(name)
|
||||
except JSONDecodeError:
|
||||
return f"没有找到该武器,派蒙也米有办法!是不是名字错了?", None
|
||||
try:
|
||||
star = ""
|
||||
for i in data["rarity"]:
|
||||
star = star + i + "星、"
|
||||
star = star[:-1]
|
||||
im = artifacts_im.format(data["name"], star, data["2pc"], data["4pc"], data["flower"]["name"],
|
||||
data["flower"]["description"],
|
||||
data["plume"]["name"], data["plume"]["description"], data["sands"]["name"],
|
||||
data["sands"]["description"],
|
||||
data["goblet"]["name"], data["goblet"]["description"], data["circlet"]["name"],
|
||||
data["circlet"]["description"])
|
||||
gen_artifacts(data['images'])
|
||||
return im, f'temp{sep}artifacts.jpg'
|
||||
except KeyError:
|
||||
return f"没有找到该武器,派蒙也米有办法!是不是名字错了?", None
|
||||
except:
|
||||
return f"没有找到该武器,派蒙也米有办法!是不是名字错了?", None
|
@ -21,7 +21,6 @@ def get_url(name: str):
|
||||
|
||||
|
||||
async def get_weapon(name: str):
|
||||
name = str(name)
|
||||
for i in weapon_all:
|
||||
if name in i['name']:
|
||||
try:
|
||||
|
12
plugins/artifacts.py
Normal file
12
plugins/artifacts.py
Normal file
@ -0,0 +1,12 @@
|
||||
from pyrogram import Client
|
||||
from pyrogram.types import Message
|
||||
from defs.artifacts import get_artifacts
|
||||
|
||||
|
||||
async def artifacts_msg(client: Client, message: Message):
|
||||
name = message.text.replace('圣遗物详情', '').strip()
|
||||
text, url = await get_artifacts(name)
|
||||
if url:
|
||||
await message.reply_photo(photo=url, caption=text, quote=True)
|
||||
else:
|
||||
await message.reply(text, quote=True)
|
@ -8,6 +8,7 @@ from plugins.character import character_msg, mz_msg
|
||||
from plugins.event import event_msg
|
||||
from plugins.weapons import weapon_msg
|
||||
from plugins.fortunate import fortunate_msg, set_fortunate_img
|
||||
from plugins.artifacts import artifacts_msg
|
||||
from plugins.artifact_rate import artifact_rate_msg
|
||||
from plugins.query_resource_points import inquire_resource_points, inquire_resource_list
|
||||
from plugins.mys import mys_msg, promote_command
|
||||
@ -72,6 +73,10 @@ async def process_private_msg(client: Client, message: Message):
|
||||
if '运势' in message.text:
|
||||
await fortunate_msg(client, message)
|
||||
await log(client, message, '查询今日运势')
|
||||
# 圣遗物查询
|
||||
if '圣遗物详情' in message.text:
|
||||
await artifacts_msg(client, message)
|
||||
await log(client, message, '查询圣遗物详情')
|
||||
# 圣遗物评分
|
||||
if '圣遗物评分' in message.text:
|
||||
await message.reply("图呢?\n*请将命令与截图一起发送", quote=True)
|
||||
@ -135,6 +140,10 @@ async def process_group_msg(client: Client, message: Message):
|
||||
if text.startswith('设置运势'):
|
||||
await set_fortunate_img(client, message)
|
||||
await log(client, message, '设置运势角色')
|
||||
# 圣遗物查询
|
||||
if text.startswith('圣遗物详情'):
|
||||
await artifacts_msg(client, message)
|
||||
await log(client, message, '查询圣遗物详情')
|
||||
# 圣遗物评分
|
||||
if text.startswith('圣遗物评分'):
|
||||
await message.reply("图呢?\n*请将命令与截图一起发送")
|
||||
|
Loading…
Reference in New Issue
Block a user