修复 gacha 特殊情况下默认无输出的问题

This commit is contained in:
omg-xtao 2022-07-13 21:31:36 +08:00 committed by GitHub
parent 03758998e3
commit f79d8f7ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -40,7 +40,7 @@ class Gacha(BasePlugins):
@conversation_error_handler
@restricts(filters.ChatType.GROUPS, restricts_time=20, try_delete_message=True)
@restricts(filters.ChatType.PRIVATE)
async def command_start(self, update: Update, context: PaimonContext) -> None:
async def command_start(self, update: Update, context: PaimonContext) -> int:
message = update.message
user = update.effective_user
args = context.args
@ -60,11 +60,8 @@ class Gacha(BasePlugins):
if key == gacha_name:
gacha_name = value
break
else:
await message.reply_text(f"没有找到名为 {gacha_name} 的卡池")
return ConversationHandler.END
Log.info(f"用户 {user.full_name}[{user.id}] 抽卡模拟器命令请求 || 参数 {gacha_name}")
gacha_info = await service.gacha.gacha_info(gacha_name)
gacha_info = await service.gacha.gacha_info(gacha_name, default=False if len(args) >= 1 else True)
# 用户数据储存和处理
if gacha_info.get("gacha_id") is None:
await message.reply_text(f"没有找到名为 {gacha_name} 的卡池")

View File

@ -9,11 +9,11 @@ class GachaService:
self.cache = cache
self.gacha = GachaInfo()
async def gacha_info(self, gacha_name: str = "角色活动"):
async def gacha_info(self, gacha_name: str = "角色活动", default: bool = False):
gacha_list_info = await self.gacha.get_gacha_list_info()
gacha_id = ""
for gacha in gacha_list_info.data["list"]:
if gacha["gacha_name"] == gacha_name:
if gacha["gacha_name"] == gacha_name or default:
gacha_id = gacha["gacha_id"]
if gacha_id == "":
return {}