From 86503671ede09f1e1967b065ea536f738953ec98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Mon, 5 Sep 2022 10:33:56 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=BB=91=E5=AE=9A=E5=8F=A6=E4=B8=80=E4=B8=AA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8E=E5=AF=BC=E8=87=B4=E7=9A=84=20`cookies`=20?= =?UTF-8?q?=E5=86=99=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/adduser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/genshin/adduser.py b/plugins/genshin/adduser.py index e84917eb..3dcc6d95 100644 --- a/plugins/genshin/adduser.py +++ b/plugins/genshin/adduser.py @@ -3,6 +3,7 @@ from typing import Optional import genshin from genshin import InvalidCookies, GenshinException, DataNotPublic +from sqlalchemy.exc import NoResultFound from telegram import Update, ReplyKeyboardRemove, ReplyKeyboardMarkup, TelegramObject from telegram.ext import CallbackContext, CommandHandler, MessageHandler, filters, ConversationHandler from telegram.helpers import escape_markdown @@ -211,8 +212,13 @@ class AddUser(BasePlugins): await update.message.reply_text("数据错误") return ConversationHandler.END await self.user_service.update_user(user_db) - await self.cookies_service.update_cookies(user.id, add_user_command_data.cookies, - add_user_command_data.region) + # 临时解决错误 + try: + await self.cookies_service.update_cookies(user.id, add_user_command_data.cookies, + add_user_command_data.region) + except NoResultFound: + await self.cookies_service.add_cookies(user.id, add_user_command_data.cookies, + add_user_command_data.region) Log.info(f"用户 {user.full_name}[{user.id}] 绑定账号成功") await update.message.reply_text("保存成功", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END