mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2025-04-12 23:29:37 +08:00
🐛 修复stoken绑定问题
This commit is contained in:
parent
143b1a3e3d
commit
fb5e409f5d
@ -24,7 +24,8 @@ from .get_data import get_monthinfo_data, get_player_card_data, get_chara_detail
|
||||
from ..utils.alias_handler import get_match_alias
|
||||
from ..utils.auth_util import check_cookie
|
||||
from ..utils.config import config
|
||||
from ..utils.db_util import get_auto_sign, delete_auto_sign, get_last_query, get_private_stoken, update_private_stoken,get_coin_auto_sign
|
||||
from ..utils.db_util import get_auto_sign, delete_auto_sign, get_last_query, get_private_stoken, update_private_stoken, \
|
||||
get_coin_auto_sign
|
||||
from ..utils.db_util import insert_public_cookie, update_private_cookie, delete_cookie_cache, delete_private_cookie, \
|
||||
update_last_query, reset_public_cookie
|
||||
from ..utils.db_util import update_note_remind2, update_note_remind, get_note_remind, delete_note_remind, \
|
||||
@ -663,7 +664,8 @@ async def auto_sign():
|
||||
else:
|
||||
await delete_auto_sign(user_id, uid)
|
||||
if remind_id.startswith('q'):
|
||||
await get_bot().send_private_msg(user_id=remind_id[1:], message=f'你的uid{uid}签到失败,请重新绑定cookie再开启自动签到')
|
||||
await get_bot().send_private_msg(user_id=remind_id[1:],
|
||||
message=f'你的uid{uid}签到失败,请重新绑定cookie再开启自动签到')
|
||||
else:
|
||||
ann[remind_id]['失败'].append(f'.UID{uid}')
|
||||
for group_id, content in ann.items():
|
||||
@ -861,17 +863,17 @@ async def get_mys_coin_auto_handler(event: MessageEvent, msg: Message = CommandA
|
||||
|
||||
|
||||
@add_stoken.handle()
|
||||
@exception_handler()
|
||||
# @exception_handler()
|
||||
async def add_stoken_handler(event: MessageEvent, msg: Message = CommandArg()):
|
||||
stoken = str(msg).strip()
|
||||
stoken = msg.extract_plain_text().strip()
|
||||
if stoken == '':
|
||||
res = '获取stoken的教程:\ndocs.qq.com/doc/DQ3JLWk1vQVllZ2Z1\n获取到后,添加派蒙好友私聊发送ysb接复制到的cookie就行啦~'
|
||||
await add_stoken.finish(res, at_sender=True)
|
||||
else:
|
||||
uid = (await get_private_cookie(event.user_id, key='user_id'))[0][2]
|
||||
stoken, mys_id, stoken_info = await addStoken(stoken,uid)
|
||||
stoken, mys_id, stoken_info, m = await addStoken(stoken, uid)
|
||||
if not stoken_info and not mys_id:
|
||||
await add_stoken.finish('请旅行者先使用ysb添加cookie哦~')
|
||||
await add_stoken.finish(m)
|
||||
if not stoken_info or stoken_info['retcode'] != 0:
|
||||
msg = cookie_error_msg
|
||||
if event.message_type != 'private':
|
||||
@ -879,7 +881,8 @@ async def add_stoken_handler(event: MessageEvent, msg: Message = CommandArg()):
|
||||
await add_stoken.finish(msg, at_sender=True)
|
||||
else:
|
||||
if uid:
|
||||
await update_private_stoken(user_id=str(event.user_id), uid=uid, mys_id=mys_id, cookie='',stoken=stoken)
|
||||
await update_private_stoken(user_id=str(event.user_id), uid=uid, mys_id=mys_id, cookie='',
|
||||
stoken=stoken)
|
||||
await update_last_query(str(event.user_id), uid, 'uid')
|
||||
msg = f'stoken绑定成功啦!'
|
||||
if event.message_type != 'private':
|
||||
|
@ -104,7 +104,7 @@ async def draw_role_card(uid, data):
|
||||
get_font(34, 'number.ttf'))
|
||||
skill_icon = res_path2 / 'skill' / f'{data["天赋"][i]["图标"]}.png'
|
||||
skill_icon = await aiorequests.get_img(url=skill_url.format(data["天赋"][i]["图标"]), size=(57, 57),
|
||||
save_path=skill_icon)
|
||||
save_path=skill_icon, mode='RGBA')
|
||||
bg.alpha_composite(skill_icon, (603, 298 + 147 * i))
|
||||
|
||||
# 命座
|
||||
@ -114,7 +114,7 @@ async def draw_role_card(uid, data):
|
||||
bg.alpha_composite(base_icon.resize((83, 90)), (510 + t * 84, 790))
|
||||
talent_icon = res_path2 / 'skill' / f'{talent["图标"]}.png'
|
||||
talent_icon = await aiorequests.get_img(url=talent_url.format(talent["图标"]), size=(45, 45),
|
||||
save_path=talent_icon)
|
||||
save_path=talent_icon, mode='RGBA')
|
||||
bg.alpha_composite(talent_icon, (529 + t * 84, 813))
|
||||
t += 1
|
||||
for t2 in range(t, 6):
|
||||
@ -126,7 +126,7 @@ async def draw_role_card(uid, data):
|
||||
bg.alpha_composite(weapon_bg, (91, 760))
|
||||
weapon_icon = res_path2 / 'weapon' / f'{data["武器"]["图标"]}.png'
|
||||
weapon_icon = await aiorequests.get_img(url=weapon_url.format(data["武器"]["图标"]), size=(150, 150),
|
||||
save_path=weapon_icon)
|
||||
save_path=weapon_icon, mode='RGBA')
|
||||
bg.alpha_composite(weapon_icon, (91, 760))
|
||||
bg_draw.text((268, 758), data['武器']['名称'], fill='white', font=get_font(34, 'hywh.ttf'))
|
||||
star = load_image(res_path / 'player_card2' / 'star.png')
|
||||
@ -149,7 +149,7 @@ async def draw_role_card(uid, data):
|
||||
bg.alpha_composite(artifact_bg, (587 + 317 * i, 1002))
|
||||
reli_path = res_path2 / 'reli' / f'{artifact["图标"]}.png'
|
||||
reli_path = await aiorequests.get_img(url=artifact_url.format(artifact["图标"]), size=(100, 100),
|
||||
save_path=reli_path)
|
||||
save_path=reli_path, mode='RGBA')
|
||||
bg.alpha_composite(reli_path, (587 + 317 * i, 1002))
|
||||
bg_draw.text((411 + 317 * i, 951), artifact['名称'], fill='white', font=get_font(40))
|
||||
value, score = artifact_total_value(data['属性'], artifact, effective)
|
||||
@ -191,7 +191,7 @@ async def draw_role_card(uid, data):
|
||||
bg.alpha_composite(artifact_bg, (270 + 317 * i, 1439))
|
||||
reli_path = res_path2 / 'reli' / f'{artifact["图标"]}.png'
|
||||
reli_path = await aiorequests.get_img(url=artifact_url.format(artifact["图标"]), size=(100, 100),
|
||||
save_path=reli_path)
|
||||
save_path=reli_path, mode='RGBA')
|
||||
bg.alpha_composite(reli_path, (270 + 317 * i, 1439))
|
||||
bg_draw.text((94 + 317 * i, 1388), artifact['名称'], fill='white', font=get_font(40))
|
||||
value, score = artifact_total_value(data['属性'], artifact, effective)
|
||||
@ -250,7 +250,7 @@ async def draw_role_card(uid, data):
|
||||
elif len(suit) == 1:
|
||||
artifact_path = res_path2 / 'reli' / f'{suit[0][1]}.png'
|
||||
artifact_path = await aiorequests.get_img(url=artifact_url.format(suit[0][1]), size=(110, 110),
|
||||
save_path=artifact_path)
|
||||
save_path=artifact_path, mode='RGBA')
|
||||
bg.alpha_composite(artifact_path, (76, 1130))
|
||||
bg_draw.text((184, 1168), f'{suit[0][0][:2]}二件套', fill='white', font=get_font(36))
|
||||
bg_draw.text((184, 1292), '未激活套装', fill='white', font=get_font(36))
|
||||
@ -259,16 +259,19 @@ async def draw_role_card(uid, data):
|
||||
artifact_path1 = res_path2 / 'reli' / f'{suit[0][1]}.png'
|
||||
artifact_path1 = artifact_path2 = await aiorequests.get_img(url=artifact_url.format(suit[0][1]),
|
||||
size=(110, 110),
|
||||
save_path=artifact_path1)
|
||||
save_path=artifact_path1,
|
||||
mode='RGBA')
|
||||
bg_draw.text((184, 1168), f'{suit[0][0][:2]}四件套', fill='white', font=get_font(36))
|
||||
bg_draw.text((184, 1292), f'{suit[0][0][:2]}四件套', fill='white', font=get_font(36))
|
||||
else:
|
||||
artifact_path1 = res_path2 / 'reli' / f'{suit[0][1]}.png'
|
||||
artifact_path1 = await aiorequests.get_img(url=artifact_url.format(suit[0][1]), size=(110, 110),
|
||||
save_path=artifact_path1)
|
||||
save_path=artifact_path1,
|
||||
mode='RGBA')
|
||||
artifact_path2 = res_path2 / 'reli' / f'{suit[1][1]}.png'
|
||||
artifact_path2 = await aiorequests.get_img(url=artifact_url.format(suit[1][1]), size=(110, 110),
|
||||
save_path=artifact_path2)
|
||||
save_path=artifact_path2,
|
||||
mode='RGBA')
|
||||
bg_draw.text((184, 1168), f'{suit[0][0][:2]}两件套', fill='white', font=get_font(36))
|
||||
bg_draw.text((184, 1292), f'{suit[1][0][:2]}两件套', fill='white', font=get_font(36))
|
||||
bg.alpha_composite(artifact_path1, (76, 1130))
|
||||
|
@ -15,6 +15,7 @@ from nonebot import logger
|
||||
|
||||
o_url = 'https://api-takumi.mihoyo.com'
|
||||
|
||||
|
||||
async def get_abyss_data(user_id, uid, schedule_type="1", use_cache=True):
|
||||
server_id = "cn_qd01" if uid[0] == '5' else "cn_gf01"
|
||||
url = "https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/spiralAbyss"
|
||||
@ -160,27 +161,36 @@ async def get_bind_game(cookie):
|
||||
data = resp.json()
|
||||
return data, uid
|
||||
|
||||
|
||||
# 添加stoken
|
||||
async def addStoken(stoken, uid):
|
||||
login_ticket = re.search(r'login_ticket=([0-9a-zA-Z]+)', stoken).group(0).split('=')[1]
|
||||
logger.info(login_ticket)
|
||||
login_ticket = re.search(r'login_ticket=([0-9a-zA-Z]+)', stoken)
|
||||
if login_ticket:
|
||||
login_ticket = login_ticket.group(0).split('=')[1]
|
||||
else:
|
||||
return None, None, None, '你的cookie中没有login_ticket字段哦,请重新获取'
|
||||
# logger.info(login_ticket)
|
||||
# mys_id = re.search(r'login_uid=([0-9]+)', mes).group(0).split('=')[1]
|
||||
ck = await get_private_cookie(uid, key='uid')
|
||||
logger.info(ck)
|
||||
# logger.info(ck)
|
||||
if not ck:
|
||||
return NULL,NULL
|
||||
return None, None, None, '你还没绑定私人cookie哦,请先用ysb绑定吧'
|
||||
ck = ck[0][1]
|
||||
mys_id = re.search(r'account_id=(\d*)', ck).group(0).split('=')[1]
|
||||
logger.info("run1")
|
||||
logger.info(mys_id)
|
||||
# logger.info("run1")
|
||||
# logger.info(mys_id)
|
||||
raw_data = await get_stoken_by_login_ticket(login_ticket, mys_id)
|
||||
logger.info(raw_data)
|
||||
logger.info("run2")
|
||||
# logger.info(raw_data)
|
||||
# logger.info("run2")
|
||||
try:
|
||||
stoken = raw_data['data']['list'][0]['token']
|
||||
logger.info("run3")
|
||||
except TypeError:
|
||||
return None, None, None, '该stoken无效获取过期了,请重新获取'
|
||||
# logger.info("run3")
|
||||
s_cookies = 'stuid={};stoken={}'.format(mys_id, stoken)
|
||||
logger.info(s_cookies)
|
||||
return s_cookies,mys_id,raw_data
|
||||
# logger.info(s_cookies)
|
||||
return s_cookies, mys_id, raw_data, 'OK'
|
||||
|
||||
|
||||
# 获取今日签到信息
|
||||
async def get_sign_info(uid):
|
||||
@ -264,6 +274,7 @@ async def get_enka_data(uid):
|
||||
except Exception:
|
||||
await sleep(1.5)
|
||||
|
||||
|
||||
async def get_stoken_by_login_ticket(loginticket, mys_id):
|
||||
async with AsyncClient() as client:
|
||||
req = await client.get(
|
||||
|
Loading…
x
Reference in New Issue
Block a user