3
0

🐛 圣遗物评分支持手动补全缺少的参数

This commit is contained in:
xtaodada 2022-01-30 18:17:01 +08:00
parent b134e4fea8
commit 5c56c644f5
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
5 changed files with 40 additions and 8 deletions

1
ci.py
View File

@ -1,4 +1,5 @@
from configparser import RawConfigParser from configparser import RawConfigParser
import pyromod.listen
from pyrogram import Client from pyrogram import Client
from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.schedulers.asyncio import AsyncIOScheduler
from httpx import AsyncClient, get from httpx import AsyncClient, get

View File

@ -5,8 +5,7 @@ from ci import client
ocr_url = "https://api.genshin.pub/api/v1/app/ocr" ocr_url = "https://api.genshin.pub/api/v1/app/ocr"
rate_url = "https://api.genshin.pub/api/v1/relic/rate" rate_url = "https://api.genshin.pub/api/v1/relic/rate"
head = { head = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
"Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67 ",
"Content-Type": "application/json; charset=UTF-8", "Content-Type": "application/json; charset=UTF-8",
"Connection": "close" "Connection": "close"
} }

View File

@ -1,9 +1,11 @@
from base64 import b64encode
import requests import requests
from secrets import choice from secrets import choice
from pyrogram import Client from pyrogram import Client, filters
from pyrogram.types import Message from pyrogram.types import Message
from defs.artifact_rate import * from defs.artifact_rate import get_artifact_attr, rate_artifact
from base64 import b64encode
from os import remove from os import remove
@ -29,7 +31,10 @@ def get_yiyan(get_yiyan_num):
"5": ["多吃点好的,出门注意安全", "晒吧,欧不可耻,只是可恨", "没啥好说的,让我自闭一会", "达成成就“高分圣遗物”", "5": ["多吃点好的,出门注意安全", "晒吧,欧不可耻,只是可恨", "没啥好说的,让我自闭一会", "达成成就“高分圣遗物”",
"怕不是以后开宝箱只能开出卷心菜", "吃了吗?没吃的话,吃我一拳", "我觉得这个游戏有问题", "这合理吗", "怕不是以后开宝箱只能开出卷心菜", "吃了吗?没吃的话,吃我一拳", "我觉得这个游戏有问题", "这合理吗",
"这东西没啥用,给我吧(柠檬)", " "]} "这东西没啥用,给我吧(柠檬)", " "]}
try:
data_ = int(float(get_yiyan_num)) data_ = int(float(get_yiyan_num))
except ValueError:
data_ = 0
if data_ == 100: if data_ == 100:
return choice(data["5"]) return choice(data["5"])
return choice(data[str(data_ // 20 + 1)]) return choice(data[str(data_ // 20 + 1)])
@ -50,6 +55,30 @@ async def artifact_rate_msg(client: Client, message: Message):
if 'err' in artifact_attr.keys(): if 'err' in artifact_attr.keys():
err_msg = artifact_attr["full"]["message"] err_msg = artifact_attr["full"]["message"]
return await msg.edit(f"发生了点小错误:\n{err_msg}") return await msg.edit(f"发生了点小错误:\n{err_msg}")
if 'star' not in artifact_attr:
msg_ = await message.reply('无法识别圣遗物星级请手动输入数字1-5', quote=True)
answer = await client.listen(message.chat.id, filters=filters.user(message.from_user.id)) # noqa
try:
artifact_attr['star'] = int(answer.text)
except ValueError:
artifact_attr['star'] = 4
await msg_.delete()
try:
await answer.delete()
except:
pass
if 'level' not in artifact_attr:
msg_ = await message.reply('无法识别圣遗物等级请手动输入数字1-20', quote=True)
answer = await client.listen(message.chat.id, filters=filters.user(message.from_user.id)) # noqa
try:
artifact_attr['level'] = int(answer.text)
except ValueError:
artifact_attr['level'] = 1
await msg_.delete()
try:
await answer.delete()
except:
pass
await msg.edit("识图成功!\n正在评分中...") await msg.edit("识图成功!\n正在评分中...")
rate_result = await rate_artifact(artifact_attr) rate_result = await rate_artifact(artifact_attr)
if 'err' in rate_result.keys(): if 'err' in rate_result.keys():

View File

@ -225,13 +225,15 @@ async def process_document(client: Client, message: Message):
message.text = text message.text = text
if text.startswith('米游社'): if text.startswith('米游社'):
print(message.document.mime_type)
if message.document.mime_type in ["image/jpeg"]: if message.document.mime_type in ["image/jpeg"]:
await mys2_qun_msg(client, message) await mys2_qun_msg(client, message)
if text.startswith('mihoyo'): if text.startswith('mihoyo'):
print(message.document.mime_type)
if message.document.mime_type in ["image/jpeg"]: if message.document.mime_type in ["image/jpeg"]:
await mihoyo_qun_msg(client, message) await mihoyo_qun_msg(client, message)
if text.startswith('圣遗物评分'):
if message.document.mime_type in ["image/jpeg", "image/png"]:
await artifact_rate_msg(client, message)
await log(client, message, '查询圣遗物详情')
@Client.on_message(Filters.voice & Filters.private & ~Filters.edited) @Client.on_message(Filters.voice & Filters.private & ~Filters.edited)

View File

@ -1,5 +1,6 @@
Pyrogram>=1.3.5 Pyrogram>=1.3.5
Tgcrypto>=1.2.3 Tgcrypto>=1.2.3
pyromod
Pillow>=8.1.0 Pillow>=8.1.0
Redis>=3.5.3 Redis>=3.5.3
bs4>=0.0.1 bs4>=0.0.1