mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 12:51:35 +00:00
✨ Use stoken v2 instead of v1
This commit is contained in:
parent
d3f1425d09
commit
8b15e083b7
@ -286,10 +286,22 @@ class AccountCookiesPlugin(Plugin.Conversation):
|
||||
await message.reply_text("检测到缺少 mid,请尝试添加 mid 后重新绑定。", reply_markup=ReplyKeyboardRemove())
|
||||
return ConversationHandler.END
|
||||
try:
|
||||
if region == Region.CHINESE:
|
||||
cookies.stoken, cookies.mid = await client.get_stoken_v2_and_mid_by_by_stoken(
|
||||
cookies.stoken, cookies.account_id
|
||||
)
|
||||
logger.success("用户 %s[%s] 绑定时获取 stoken_v2, mid 成功", user.full_name, user.id)
|
||||
cookies.cookie_token = await client.get_cookie_token_by_stoken(cookies.stoken, mid=cookies.mid)
|
||||
logger.success("用户 %s[%s] 绑定时获取 cookie_token 成功", user.full_name, user.id)
|
||||
cookies.ltoken = await client.get_ltoken_by_stoken()
|
||||
logger.success("用户 %s[%s] 绑定时获取 ltoken 成功", user.full_name, user.id)
|
||||
else:
|
||||
cookies_model = await client.get_all_token_by_stoken(cookies.stoken, cookies.account_id)
|
||||
cookies.stoken = cookies_model.stoken
|
||||
cookies.mid = cookies_model.mid
|
||||
cookies.ltoken = cookies_model.ltoken
|
||||
cookies.cookie_token = cookies_model.cookie_token
|
||||
logger.success("用户 %s[%s] 绑定时获取 stoken_v2, mid, ltoken, cookie_token 成功", user.full_name, user.id)
|
||||
except SimnetBadRequest as exc:
|
||||
logger.warning("用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original)
|
||||
await message.reply_text("Stoken 无效,请重新绑定。", reply_markup=ReplyKeyboardRemove())
|
||||
|
@ -5,8 +5,6 @@ from typing import Tuple, TYPE_CHECKING
|
||||
from simnet import Region, GenshinClient
|
||||
from telegram import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from telegram.ext import filters
|
||||
|
||||
from core.basemodel import RegionEnum
|
||||
from core.plugin import Plugin, handler
|
||||
from core.services.cookies import CookiesService
|
||||
from core.services.players import PlayersService
|
||||
@ -128,15 +126,12 @@ class PlayersManagesPlugin(Plugin):
|
||||
InlineKeyboardButton(
|
||||
"导出 Cookies",
|
||||
callback_data=f"players_manager|export_cookies|{user.id}|{player.player_id}",
|
||||
)
|
||||
]
|
||||
if player.region == RegionEnum.HYPERION:
|
||||
temp_buttons.append(
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
"刷新 Cookies",
|
||||
callback_data=f"players_manager|refresh_cookies|{user.id}|{player.player_id}",
|
||||
)
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
buttons.insert(-1, temp_buttons)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user