PaiGram/service/gacha.py
洛水.山岭居室 cabf28d0aa 修改模块名称和类名称
已经确认检查单上的内容检查完毕
2022-06-01 11:46:26 +08:00

23 lines
793 B
Python

from model.apihelper import GachaInfo
from service.repository import AsyncRepository
from service.cache import RedisCache
class GachaService:
def __init__(self, repository: AsyncRepository, cache: RedisCache):
self.repository = repository
self.cache = cache
self.gacha = GachaInfo()
async def gacha_info(self, gacha_name: str = "角色活动"):
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:
gacha_id = gacha["gacha_id"]
if gacha_id == "":
return {}
gacha_info = await self.gacha.get_gacha_info(gacha_id)
gacha_info["gacha_id"] = gacha_id
return gacha_info