🐛 Fix handle CookiesCachePoolExhausted gracefully

This commit is contained in:
Lei Shi 2023-11-23 05:39:33 +01:00 committed by xtaodada
parent f1918e80fb
commit 82b478160c
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

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 = StarRailClient(cookies=cookies.data, region=Region.CHINESE, lang="zh-cn") client = StarRailClient(cookies=cookies.data, region=Region.CHINESE, lang="zh-cn")
elif region == RegionEnum.HOYOLAB: elif region == RegionEnum.HOYOLAB: