From d35575bcabe796f6547244965603d96daf5f26a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Tue, 9 Aug 2022 23:36:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A7=E6=80=A5=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/cookies.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/cookies.py b/plugins/cookies.py index ac277068..108833cc 100644 --- a/plugins/cookies.py +++ b/plugins/cookies.py @@ -2,7 +2,7 @@ from http.cookies import SimpleCookie, CookieError import genshin import ujson -from genshin import InvalidCookies, GenshinException, DataNotPublic +from genshin import InvalidCookies, GenshinException, DataNotPublic, types from telegram import Update, ReplyKeyboardRemove, ReplyKeyboardMarkup from telegram.ext import CallbackContext, CommandHandler, MessageHandler, filters, ConversationHandler from telegram.helpers import escape_markdown @@ -135,14 +135,15 @@ class Cookies(BasePlugins): await update.message.reply_text("Cookies格式有误,请检查", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END if cookies_command_data.service == ServiceEnum.HYPERION: - client = genshin.ChineseClient(cookies=cookies) + client = genshin.Client(cookies=cookies, game=types.Game.GENSHIN, region=types.Region.CHINESE) elif cookies_command_data.service == ServiceEnum.HOYOLAB: - client = genshin.GenshinClient(cookies=cookies) + client = genshin.Client(cookies=cookies, + game=types.Game.GENSHIN, region=types.Region.OVERSEAS, lang="zh-cn") else: await update.message.reply_text("数据错误", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END try: - user_info = await client.get_record_card() + game_accounts = await client.get_game_accounts() except DataNotPublic: await update.message.reply_text("账号疑似被注销,请检查账号状态", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END @@ -159,6 +160,13 @@ class Cookies(BasePlugins): except ValueError: await update.message.reply_text("Cookies错误,请检查是否正确", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END + for game_account in game_accounts: + if game_account.game == types.Game.GENSHIN: + user_info = game_account + break + else: + await update.message.reply_text("未找到原神账号", reply_markup=ReplyKeyboardRemove()) + return ConversationHandler.END cookies_command_data.cookies = cookies cookies_command_data.game_uid = user_info.uid reply_keyboard = [['确认', '退出']]