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,11 +24,12 @@ from .get_data import get_monthinfo_data, get_player_card_data, get_chara_detail
|
|||||||
from ..utils.alias_handler import get_match_alias
|
from ..utils.alias_handler import get_match_alias
|
||||||
from ..utils.auth_util import check_cookie
|
from ..utils.auth_util import check_cookie
|
||||||
from ..utils.config import config
|
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, \
|
from ..utils.db_util import insert_public_cookie, update_private_cookie, delete_cookie_cache, delete_private_cookie, \
|
||||||
update_last_query, reset_public_cookie
|
update_last_query, reset_public_cookie
|
||||||
from ..utils.db_util import update_note_remind2, update_note_remind, get_note_remind, delete_note_remind, \
|
from ..utils.db_util import update_note_remind2, update_note_remind, get_note_remind, delete_note_remind, \
|
||||||
update_day_remind_count, get_private_cookie, add_auto_sign, get_all_query,add_coin_auto_sign,delete_coin_auto_sign
|
update_day_remind_count, get_private_cookie, add_auto_sign, get_all_query, add_coin_auto_sign, delete_coin_auto_sign
|
||||||
from ..utils.decorator import exception_handler
|
from ..utils.decorator import exception_handler
|
||||||
from ..utils.enka_util import PlayerInfo
|
from ..utils.enka_util import PlayerInfo
|
||||||
from ..utils.message_util import MessageBuild as MsgBd
|
from ..utils.message_util import MessageBuild as MsgBd
|
||||||
@ -663,7 +664,8 @@ async def auto_sign():
|
|||||||
else:
|
else:
|
||||||
await delete_auto_sign(user_id, uid)
|
await delete_auto_sign(user_id, uid)
|
||||||
if remind_id.startswith('q'):
|
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:
|
else:
|
||||||
ann[remind_id]['失败'].append(f'.UID{uid}')
|
ann[remind_id]['失败'].append(f'.UID{uid}')
|
||||||
for group_id, content in ann.items():
|
for group_id, content in ann.items():
|
||||||
@ -686,8 +688,8 @@ async def coin_auto_sign():
|
|||||||
ann = defaultdict(lambda: defaultdict(list))
|
ann = defaultdict(lambda: defaultdict(list))
|
||||||
if data:
|
if data:
|
||||||
logger.info('---派蒙开始执行米游币自动获取---')
|
logger.info('---派蒙开始执行米游币自动获取---')
|
||||||
for user_id,uid,remind_id in data:
|
for user_id, uid, remind_id in data:
|
||||||
sk = await get_private_stoken(uid,key='uid')
|
sk = await get_private_stoken(uid, key='uid')
|
||||||
stoken = sk[0][4]
|
stoken = sk[0][4]
|
||||||
get_coin_task = MihoyoBBSCoin(stoken)
|
get_coin_task = MihoyoBBSCoin(stoken)
|
||||||
data = await get_coin_task.task_run()
|
data = await get_coin_task.task_run()
|
||||||
@ -811,12 +813,12 @@ async def all_update():
|
|||||||
|
|
||||||
@get_mys_coin.handle()
|
@get_mys_coin.handle()
|
||||||
@exception_handler()
|
@exception_handler()
|
||||||
async def get_mys_coin_handler(event: MessageEvent, msg: Message = CommandArg()):\
|
async def get_mys_coin_handler(event: MessageEvent, msg: Message = CommandArg()): \
|
||||||
#获取UID
|
# 获取UID
|
||||||
uid, msg, user_id, use_cache = await get_uid_in_msg(event, msg)
|
uid, msg, user_id, use_cache = await get_uid_in_msg(event, msg)
|
||||||
if not uid:
|
if not uid:
|
||||||
await get_mys_coin.finish('没有找到你的uid哦')
|
await get_mys_coin.finish('没有找到你的uid哦')
|
||||||
sk = await get_private_stoken(uid,key='uid')
|
sk = await get_private_stoken(uid, key='uid')
|
||||||
if not sk:
|
if not sk:
|
||||||
await get_mys_coin.finish('请旅行者先添加cookie和stoken哦')
|
await get_mys_coin.finish('请旅行者先添加cookie和stoken哦')
|
||||||
cookie = sk[0][1]
|
cookie = sk[0][1]
|
||||||
@ -847,7 +849,7 @@ async def get_mys_coin_auto_handler(event: MessageEvent, msg: Message = CommandA
|
|||||||
find_action = re.search(r'(?P<action>开启|启用|打开|关闭|禁用|on|off)', msg)
|
find_action = re.search(r'(?P<action>开启|启用|打开|关闭|禁用|on|off)', msg)
|
||||||
if find_action:
|
if find_action:
|
||||||
if find_action.group('action') in ['开启', '启用', '打开', 'on']:
|
if find_action.group('action') in ['开启', '启用', '打开', 'on']:
|
||||||
sk= await get_private_stoken(uid, key='uid')
|
sk = await get_private_stoken(uid, key='uid')
|
||||||
stoken = sk[0][4]
|
stoken = sk[0][4]
|
||||||
if not stoken:
|
if not stoken:
|
||||||
await mys_sign_auto.finish('你的该uid还没绑定stoken哦,先用添加stoken绑定吧!', at_sender=True)
|
await mys_sign_auto.finish('你的该uid还没绑定stoken哦,先用添加stoken绑定吧!', at_sender=True)
|
||||||
@ -861,17 +863,17 @@ async def get_mys_coin_auto_handler(event: MessageEvent, msg: Message = CommandA
|
|||||||
|
|
||||||
|
|
||||||
@add_stoken.handle()
|
@add_stoken.handle()
|
||||||
@exception_handler()
|
# @exception_handler()
|
||||||
async def add_stoken_handler(event: MessageEvent, msg: Message = CommandArg()):
|
async def add_stoken_handler(event: MessageEvent, msg: Message = CommandArg()):
|
||||||
stoken = str(msg).strip()
|
stoken = msg.extract_plain_text().strip()
|
||||||
if stoken == '':
|
if stoken == '':
|
||||||
res = '获取stoken的教程:\ndocs.qq.com/doc/DQ3JLWk1vQVllZ2Z1\n获取到后,添加派蒙好友私聊发送ysb接复制到的cookie就行啦~'
|
res = '获取stoken的教程:\ndocs.qq.com/doc/DQ3JLWk1vQVllZ2Z1\n获取到后,添加派蒙好友私聊发送ysb接复制到的cookie就行啦~'
|
||||||
await add_stoken.finish(res, at_sender=True)
|
await add_stoken.finish(res, at_sender=True)
|
||||||
else:
|
else:
|
||||||
uid = (await get_private_cookie(event.user_id,key='user_id'))[0][2]
|
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:
|
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:
|
if not stoken_info or stoken_info['retcode'] != 0:
|
||||||
msg = cookie_error_msg
|
msg = cookie_error_msg
|
||||||
if event.message_type != 'private':
|
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)
|
await add_stoken.finish(msg, at_sender=True)
|
||||||
else:
|
else:
|
||||||
if uid:
|
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')
|
await update_last_query(str(event.user_id), uid, 'uid')
|
||||||
msg = f'stoken绑定成功啦!'
|
msg = f'stoken绑定成功啦!'
|
||||||
if event.message_type != 'private':
|
if event.message_type != 'private':
|
||||||
|
@ -104,7 +104,7 @@ async def draw_role_card(uid, data):
|
|||||||
get_font(34, 'number.ttf'))
|
get_font(34, 'number.ttf'))
|
||||||
skill_icon = res_path2 / 'skill' / f'{data["天赋"][i]["图标"]}.png'
|
skill_icon = res_path2 / 'skill' / f'{data["天赋"][i]["图标"]}.png'
|
||||||
skill_icon = await aiorequests.get_img(url=skill_url.format(data["天赋"][i]["图标"]), size=(57, 57),
|
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))
|
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))
|
bg.alpha_composite(base_icon.resize((83, 90)), (510 + t * 84, 790))
|
||||||
talent_icon = res_path2 / 'skill' / f'{talent["图标"]}.png'
|
talent_icon = res_path2 / 'skill' / f'{talent["图标"]}.png'
|
||||||
talent_icon = await aiorequests.get_img(url=talent_url.format(talent["图标"]), size=(45, 45),
|
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))
|
bg.alpha_composite(talent_icon, (529 + t * 84, 813))
|
||||||
t += 1
|
t += 1
|
||||||
for t2 in range(t, 6):
|
for t2 in range(t, 6):
|
||||||
@ -126,7 +126,7 @@ async def draw_role_card(uid, data):
|
|||||||
bg.alpha_composite(weapon_bg, (91, 760))
|
bg.alpha_composite(weapon_bg, (91, 760))
|
||||||
weapon_icon = res_path2 / 'weapon' / f'{data["武器"]["图标"]}.png'
|
weapon_icon = res_path2 / 'weapon' / f'{data["武器"]["图标"]}.png'
|
||||||
weapon_icon = await aiorequests.get_img(url=weapon_url.format(data["武器"]["图标"]), size=(150, 150),
|
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.alpha_composite(weapon_icon, (91, 760))
|
||||||
bg_draw.text((268, 758), data['武器']['名称'], fill='white', font=get_font(34, 'hywh.ttf'))
|
bg_draw.text((268, 758), data['武器']['名称'], fill='white', font=get_font(34, 'hywh.ttf'))
|
||||||
star = load_image(res_path / 'player_card2' / 'star.png')
|
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))
|
bg.alpha_composite(artifact_bg, (587 + 317 * i, 1002))
|
||||||
reli_path = res_path2 / 'reli' / f'{artifact["图标"]}.png'
|
reli_path = res_path2 / 'reli' / f'{artifact["图标"]}.png'
|
||||||
reli_path = await aiorequests.get_img(url=artifact_url.format(artifact["图标"]), size=(100, 100),
|
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.alpha_composite(reli_path, (587 + 317 * i, 1002))
|
||||||
bg_draw.text((411 + 317 * i, 951), artifact['名称'], fill='white', font=get_font(40))
|
bg_draw.text((411 + 317 * i, 951), artifact['名称'], fill='white', font=get_font(40))
|
||||||
value, score = artifact_total_value(data['属性'], artifact, effective)
|
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))
|
bg.alpha_composite(artifact_bg, (270 + 317 * i, 1439))
|
||||||
reli_path = res_path2 / 'reli' / f'{artifact["图标"]}.png'
|
reli_path = res_path2 / 'reli' / f'{artifact["图标"]}.png'
|
||||||
reli_path = await aiorequests.get_img(url=artifact_url.format(artifact["图标"]), size=(100, 100),
|
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.alpha_composite(reli_path, (270 + 317 * i, 1439))
|
||||||
bg_draw.text((94 + 317 * i, 1388), artifact['名称'], fill='white', font=get_font(40))
|
bg_draw.text((94 + 317 * i, 1388), artifact['名称'], fill='white', font=get_font(40))
|
||||||
value, score = artifact_total_value(data['属性'], artifact, effective)
|
value, score = artifact_total_value(data['属性'], artifact, effective)
|
||||||
@ -250,7 +250,7 @@ async def draw_role_card(uid, data):
|
|||||||
elif len(suit) == 1:
|
elif len(suit) == 1:
|
||||||
artifact_path = res_path2 / 'reli' / f'{suit[0][1]}.png'
|
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),
|
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.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, 1168), f'{suit[0][0][:2]}二件套', fill='white', font=get_font(36))
|
||||||
bg_draw.text((184, 1292), '未激活套装', 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 = res_path2 / 'reli' / f'{suit[0][1]}.png'
|
||||||
artifact_path1 = artifact_path2 = await aiorequests.get_img(url=artifact_url.format(suit[0][1]),
|
artifact_path1 = artifact_path2 = await aiorequests.get_img(url=artifact_url.format(suit[0][1]),
|
||||||
size=(110, 110),
|
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, 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))
|
bg_draw.text((184, 1292), f'{suit[0][0][:2]}四件套', fill='white', font=get_font(36))
|
||||||
else:
|
else:
|
||||||
artifact_path1 = res_path2 / 'reli' / f'{suit[0][1]}.png'
|
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),
|
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 = res_path2 / 'reli' / f'{suit[1][1]}.png'
|
||||||
artifact_path2 = await aiorequests.get_img(url=artifact_url.format(suit[1][1]), size=(110, 110),
|
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, 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_draw.text((184, 1292), f'{suit[1][0][:2]}两件套', fill='white', font=get_font(36))
|
||||||
bg.alpha_composite(artifact_path1, (76, 1130))
|
bg.alpha_composite(artifact_path1, (76, 1130))
|
||||||
|
@ -15,6 +15,7 @@ from nonebot import logger
|
|||||||
|
|
||||||
o_url = 'https://api-takumi.mihoyo.com'
|
o_url = 'https://api-takumi.mihoyo.com'
|
||||||
|
|
||||||
|
|
||||||
async def get_abyss_data(user_id, uid, schedule_type="1", use_cache=True):
|
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"
|
server_id = "cn_qd01" if uid[0] == '5' else "cn_gf01"
|
||||||
url = "https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/spiralAbyss"
|
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()
|
data = resp.json()
|
||||||
return data, uid
|
return data, uid
|
||||||
|
|
||||||
#添加stoken
|
|
||||||
async def addStoken(stoken,uid):
|
# 添加stoken
|
||||||
login_ticket = re.search(r'login_ticket=([0-9a-zA-Z]+)', stoken).group(0).split('=')[1]
|
async def addStoken(stoken, uid):
|
||||||
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]
|
# mys_id = re.search(r'login_uid=([0-9]+)', mes).group(0).split('=')[1]
|
||||||
ck = await get_private_cookie(uid,key='uid')
|
ck = await get_private_cookie(uid, key='uid')
|
||||||
logger.info(ck)
|
# logger.info(ck)
|
||||||
if not ck:
|
if not ck:
|
||||||
return NULL,NULL
|
return None, None, None, '你还没绑定私人cookie哦,请先用ysb绑定吧'
|
||||||
ck = ck[0][1]
|
ck = ck[0][1]
|
||||||
mys_id = re.search(r'account_id=(\d*)', ck).group(0).split('=')[1]
|
mys_id = re.search(r'account_id=(\d*)', ck).group(0).split('=')[1]
|
||||||
logger.info("run1")
|
# logger.info("run1")
|
||||||
logger.info(mys_id)
|
# logger.info(mys_id)
|
||||||
raw_data = await get_stoken_by_login_ticket(login_ticket, mys_id)
|
raw_data = await get_stoken_by_login_ticket(login_ticket, mys_id)
|
||||||
logger.info(raw_data)
|
# logger.info(raw_data)
|
||||||
logger.info("run2")
|
# logger.info("run2")
|
||||||
stoken = raw_data['data']['list'][0]['token']
|
try:
|
||||||
logger.info("run3")
|
stoken = raw_data['data']['list'][0]['token']
|
||||||
|
except TypeError:
|
||||||
|
return None, None, None, '该stoken无效获取过期了,请重新获取'
|
||||||
|
# logger.info("run3")
|
||||||
s_cookies = 'stuid={};stoken={}'.format(mys_id, stoken)
|
s_cookies = 'stuid={};stoken={}'.format(mys_id, stoken)
|
||||||
logger.info(s_cookies)
|
# logger.info(s_cookies)
|
||||||
return s_cookies,mys_id,raw_data
|
return s_cookies, mys_id, raw_data, 'OK'
|
||||||
|
|
||||||
|
|
||||||
# 获取今日签到信息
|
# 获取今日签到信息
|
||||||
async def get_sign_info(uid):
|
async def get_sign_info(uid):
|
||||||
@ -264,14 +274,15 @@ async def get_enka_data(uid):
|
|||||||
except Exception:
|
except Exception:
|
||||||
await sleep(1.5)
|
await sleep(1.5)
|
||||||
|
|
||||||
|
|
||||||
async def get_stoken_by_login_ticket(loginticket, mys_id):
|
async def get_stoken_by_login_ticket(loginticket, mys_id):
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url= o_url + '/auth/api/getMultiTokenByLoginTicket',
|
url=o_url + '/auth/api/getMultiTokenByLoginTicket',
|
||||||
params={
|
params={
|
||||||
'login_ticket': loginticket,
|
'login_ticket': loginticket,
|
||||||
'token_types' : '3',
|
'token_types': '3',
|
||||||
'uid' : mys_id
|
'uid': mys_id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return req.json()
|
return req.json()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user