mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
✨ 更新角色材料
,修复帮助图缓存不更新、Web UI
部分提示不符以及猜语音
问题
This commit is contained in:
parent
da5b96b625
commit
fab1cc3f85
@ -15,7 +15,7 @@ class ConfigModel(BaseModel):
|
||||
auto_myb_hour: int = Field(8, alias='米游币开始执行时间(小时)')
|
||||
auto_myb_minute: int = Field(0, alias='米游币开始执行时间(分钟)')
|
||||
|
||||
auto_sign_enable: bool = Field(True, alias='米游社自动签到开关')
|
||||
auto_sign_enable: bool = Field(False, alias='米游社自动签到开关')
|
||||
auto_sign_hour: int = Field(0, alias='米游社签到开始时间(小时)')
|
||||
auto_sign_minute: int = Field(5, alias='米游社签到开始时间(分钟)')
|
||||
|
||||
@ -36,7 +36,7 @@ class ConfigModel(BaseModel):
|
||||
auto_add_group: bool = Field(False, alias='自动接受群邀请')
|
||||
notice_event: bool = Field(True, alias='启用好友和群欢迎消息')
|
||||
|
||||
screenshot_enable: bool = Field(True, alias='启用网页截图权限')
|
||||
screenshot_enable: bool = Field(False, alias='启用网页截图权限')
|
||||
|
||||
guess_voice_time: int = Field(30, alias='原神猜语音时间')
|
||||
|
||||
|
@ -90,7 +90,7 @@ def create_guess_matcher(group_id, role_name, game_time):
|
||||
role_name = role_name.replace('旅行者(', '').replace(')', '')
|
||||
alias_list = get_alias_by_name(role_name)
|
||||
re_str = '|'.join(alias_list)
|
||||
guess_matcher = on_regex(re_str, temp=True, rule=Rule(check_group),
|
||||
guess_matcher = on_regex(f'^{re_str}$', temp=True, rule=Rule(check_group),
|
||||
expire_time=datetime.timedelta(seconds=game_time))
|
||||
guess_matcher.plugin_name = "Genshin_Voice"
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
import asyncio
|
||||
import datetime
|
||||
import json
|
||||
import random
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from typing import Tuple, Dict, Any, Optional, Union
|
||||
from typing import Tuple, Union
|
||||
|
||||
from nonebot import get_bot
|
||||
|
||||
@ -26,30 +25,10 @@ GEETEST_HEADER = {"Accept": "*/*",
|
||||
sign_reward_list: dict = {}
|
||||
|
||||
|
||||
async def pass_geetest(data: Dict[str, Any]):
|
||||
if data is not None:
|
||||
url = f'https://api.geetest.com/ajax.php?gt={data["gt"]}&challenge={data["challenge"]}&lang=zh-cn&pt=3&client_type=web_mobile'
|
||||
resp = await aiorequests.get(url, headers=GEETEST_HEADER)
|
||||
if resp.status_code == 200:
|
||||
resp_data = json.loads(resp.text.replace('(', '').replace(')', ''))
|
||||
if 'success' in resp_data['status'] and 'success' in resp_data['data']['result']:
|
||||
return resp_data['data']['validate']
|
||||
return None
|
||||
|
||||
|
||||
async def sign_action(user_id: str, uid: str, validate: Optional[dict] = None, last_data: Optional[dict] = None) -> \
|
||||
Union[dict, str]:
|
||||
async def sign_action(user_id: str, uid: str) -> Union[dict, str]:
|
||||
server_id = 'cn_qd01' if uid[0] == '5' else 'cn_gf01'
|
||||
cookie_info = await PrivateCookie.get_or_none(user_id=user_id, uid=uid)
|
||||
if last_data and validate:
|
||||
extra_headers = {
|
||||
'x-rpc-challenge': last_data['data']['challenge'],
|
||||
'x-rpc-validate': validate,
|
||||
'x-rpc-seccode': f'{validate}|jordan'
|
||||
}
|
||||
else:
|
||||
extra_headers = None
|
||||
resp = await aiorequests.post(SIGN_ACTION_API, headers=mihoyo_sign_headers(cookie_info.cookie, extra_headers),
|
||||
resp = await aiorequests.post(SIGN_ACTION_API, headers=mihoyo_sign_headers(cookie_info.cookie),
|
||||
json={
|
||||
'act_id': 'e202009291139501',
|
||||
'uid': uid,
|
||||
@ -83,11 +62,8 @@ async def mhy_bbs_sign(user_id: str, uid: str) -> Tuple[SignResult, str]:
|
||||
return SignResult.DONE, f'UID{uid}今天已经签过了,获得的奖励为\n{sign_reward_list[signed_days]["name"]}*{sign_reward_list[signed_days]["cnt"]}'
|
||||
else:
|
||||
return SignResult.DONE, f'UID{uid}今天已经签过了'
|
||||
validate = None
|
||||
sign_data = None
|
||||
for i in range(3):
|
||||
sign_data = await sign_action(user_id, uid, validate, sign_data)
|
||||
validate = await pass_geetest(sign_data['data'])
|
||||
sign_data = await sign_action(user_id, uid)
|
||||
if isinstance(sign_data, str):
|
||||
logger.info('米游社原神签到', '➤', {'用户': user_id, 'UID': uid}, f'获取数据失败, {sign_data}', False)
|
||||
return SignResult.FAIL, f'{uid}签到失败,{sign_data}\n'
|
||||
|
@ -140,6 +140,8 @@ async def _(event: MessageEvent, players=CommandPlayer(2)):
|
||||
img = await draw_chara_bag(player, player_info, characters_list)
|
||||
logger.info('原神角色背包', '➤➤➤', {}, '制图完成', True)
|
||||
msg += img
|
||||
except AttributeError:
|
||||
msg += F'UID{player.uid}制图时出错,请尝试使用命令[更新角色信息]后重试\n'
|
||||
except Exception as e:
|
||||
logger.info('原神角色背包', '➤➤➤', {}, f'制图出错:{e}', False)
|
||||
msg += F'UID{player.uid}制图时出错:{e}\n'
|
||||
@ -245,6 +247,8 @@ async def _(event: MessageEvent, state: T_State, uid=CommandUID()):
|
||||
freq_limiter.start(f'udi{uid}', 180)
|
||||
gim = GenshinInfoManager(str(event.user_id), uid)
|
||||
result = await gim.update_all(include_talent)
|
||||
except KeyError as e:
|
||||
result = f'更新失败,缺少{e}的数据,请尝试更新bot版本'
|
||||
except Exception as e:
|
||||
result = f'更新失败,错误信息:{e}'
|
||||
running_udi.remove(f'{event.user_id}-{uid}')
|
||||
|
@ -210,7 +210,8 @@ def create_wiki_matcher(pattern: str, help_fun: str, help_name: str):
|
||||
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/XFGuide/{}.jpg'
|
||||
elif state['type'] == '角色材料':
|
||||
state['type'] = '角色'
|
||||
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/RoleMaterials/{}材料.jpg'
|
||||
# state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/RoleMaterials/{}材料.jpg'
|
||||
state['img_url'] = 'https://ghproxy.com/https://raw.githubusercontent.com/Nwflower/genshin-atlas/master/material%20for%20role/{}.png'
|
||||
elif state['type'] == '收益曲线':
|
||||
state['type'] = '角色'
|
||||
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/blue/{}.jpg'
|
||||
|
@ -373,15 +373,18 @@ async def get_sign_reward_list() -> dict:
|
||||
|
||||
|
||||
async def get_stoken_by_cookie(cookie: str) -> Optional[str]:
|
||||
if login_ticket := re.search('login_ticket=([0-9a-zA-Z]+)', cookie):
|
||||
bbs_cookie_url = 'https://webapi.account.mihoyo.com/Api/cookie_accountinfo_by_loginticket?login_ticket={}'
|
||||
data = (await aiorequests.get(url=bbs_cookie_url.format(login_ticket[0].split('=')[1]))).json()
|
||||
try:
|
||||
if login_ticket := re.search('login_ticket=([0-9a-zA-Z]+)', cookie):
|
||||
bbs_cookie_url = 'https://webapi.account.mihoyo.com/Api/cookie_accountinfo_by_loginticket?login_ticket={}'
|
||||
data = (await aiorequests.get(url=bbs_cookie_url.format(login_ticket[0].split('=')[1]))).json()
|
||||
|
||||
if '成功' in data['data']['msg']:
|
||||
stuid = data['data']['cookie_info']['account_id']
|
||||
bbs_cookie_url2 = 'https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?login_ticket={}&token_types=3&uid={}'
|
||||
data2 = (await aiorequests.get(url=bbs_cookie_url2.format(login_ticket[0].split('=')[1], stuid))).json()
|
||||
return data2['data']['list'][0]['token']
|
||||
if '成功' in data['data']['msg']:
|
||||
stuid = data['data']['cookie_info']['account_id']
|
||||
bbs_cookie_url2 = 'https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?login_ticket={}&token_types=3&uid={}'
|
||||
data2 = (await aiorequests.get(url=bbs_cookie_url2.format(login_ticket[0].split('=')[1], stuid))).json()
|
||||
return data2['data']['list'][0]['token']
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
|
@ -7,11 +7,6 @@ from fastapi.responses import JSONResponse
|
||||
from LittlePaimon.config import ConfigManager, PluginManager, PluginInfo
|
||||
from LittlePaimon.database import PluginPermission
|
||||
|
||||
try:
|
||||
from LittlePaimon.plugins.plugin_manager import cache_help
|
||||
except Exception:
|
||||
cache_help = None
|
||||
|
||||
from .utils import authentication
|
||||
|
||||
route = APIRouter()
|
||||
@ -34,8 +29,11 @@ async def get_plugins():
|
||||
async def set_plugin_status(data: dict):
|
||||
module_name = data.get('plugin')
|
||||
status = data.get('status')
|
||||
if cache_help:
|
||||
try:
|
||||
from LittlePaimon.plugins.plugin_manager import cache_help
|
||||
cache_help.clear()
|
||||
except Exception:
|
||||
pass
|
||||
await PluginPermission.filter(name=module_name).update(status=status)
|
||||
return {'status': 0, 'msg': f'成功设置{module_name}插件状态为{status}'}
|
||||
|
||||
@ -79,8 +77,11 @@ async def set_plugin_bans(data: dict):
|
||||
status=False)
|
||||
else:
|
||||
await PluginPermission.filter(name=name, session_type='user', session_id=int(ban)).update(status=False)
|
||||
if cache_help:
|
||||
try:
|
||||
from LittlePaimon.plugins.plugin_manager import cache_help
|
||||
cache_help.clear()
|
||||
except Exception:
|
||||
pass
|
||||
return {
|
||||
'status': 0,
|
||||
'msg': '插件权限设置成功'
|
||||
@ -91,8 +92,11 @@ async def set_plugin_bans(data: dict):
|
||||
async def set_plugin_detail(plugin_info: PluginInfo):
|
||||
PluginManager.plugins[plugin_info.module_name] = plugin_info
|
||||
PluginManager.save()
|
||||
if cache_help:
|
||||
try:
|
||||
from LittlePaimon.plugins.plugin_manager import cache_help
|
||||
cache_help.clear()
|
||||
except Exception:
|
||||
pass
|
||||
return {
|
||||
'status': 0,
|
||||
'msg': '插件信息设置成功'
|
||||
|
@ -46,11 +46,11 @@ command_form = InputSubForm(name='matchers',
|
||||
InputText(label='命令用法', name='pm_usage', value='${pm_usage}',
|
||||
description='命令的使用方法,建议不要太长'),
|
||||
Textarea(label='命令详细描述', name='pm_description', value='${pm_description}',
|
||||
description='命令的详细描述,可以用\\n强制换行', showCounter=False),
|
||||
description='命令的详细描述,可以用^强制换行', showCounter=False),
|
||||
Switch(label='是否展示', name='pm_show', value='${pm_show}',
|
||||
description='是否在帮助图中展示该命令'),
|
||||
InputNumber(label='展示优先级', name='pm_priority', value='${pm_priority}',
|
||||
description='展示优先级,数字越大越靠前', min=0, max=99,
|
||||
description='在帮助图中展示的优先级,数字越小越靠前', min=0, max=99,
|
||||
displayMode='enhance'),
|
||||
]
|
||||
))
|
||||
|
Loading…
x
Reference in New Issue
Block a user