🐛 Fix handle CookiesCachePoolExhausted gracefully

This commit is contained in:
Lei Shi 2023-11-23 05:39:33 +01:00 committed by GitHub
parent 58f1ecc857
commit 5ea80e0218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,7 +15,7 @@ from telegram.helpers import escape_markdown
from core.basemodel import RegionEnum from core.basemodel import RegionEnum
from core.plugin import Plugin, conversation, handler from core.plugin import Plugin, conversation, handler
from core.services.cookies.error import TooManyRequestPublicCookies from core.services.cookies.error import TooManyRequestPublicCookies, CookiesCachePoolExhausted
from core.services.cookies.services import CookiesService, PublicCookiesService from core.services.cookies.services import CookiesService, PublicCookiesService
from core.services.players.models import PlayersDataBase as Player, PlayerInfoSQLModel from core.services.players.models import PlayersDataBase as Player, PlayerInfoSQLModel
from core.services.players.services import PlayersService, PlayerInfoService from core.services.players.services import PlayersService, PlayerInfoService
@ -137,6 +137,9 @@ class BindAccountPlugin(Plugin.Conversation):
except TooManyRequestPublicCookies: except TooManyRequestPublicCookies:
await message.reply_text("用户查询次数过多,请稍后重试", reply_markup=ReplyKeyboardRemove()) await message.reply_text("用户查询次数过多,请稍后重试", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END
except CookiesCachePoolExhausted:
await message.reply_text("公共Cookies池已经耗尽请稍后重试或者绑定 cookie", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END
if region == RegionEnum.HYPERION: if region == RegionEnum.HYPERION:
client = GenshinClient(cookies=cookies.data, region=Region.CHINESE) client = GenshinClient(cookies=cookies.data, region=Region.CHINESE)
elif region == RegionEnum.HOYOLAB: elif region == RegionEnum.HOYOLAB: