Add gacha_count only_five_star support

This commit is contained in:
omg-xtao 2022-10-29 18:29:20 +08:00 committed by GitHub
parent e18f060a16
commit 463670be69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 2 deletions

View File

@ -558,6 +558,47 @@ class GachaLog:
"hasMore": len(pool_data) > 6,
}
async def get_all_five_analysis(self, user_id: int, client: Client, assets: AssetsService) -> dict:
"""获取五星抽卡记录分析数据
:param user_id: 用户id
:param client: genshin client
:param assets: 资源服务
:return: 分析数据
"""
gacha_log, status = await self.load_history_info(str(user_id), str(client.uid))
if not status:
raise GachaLogNotFound
pools = []
for pool_name, items in gacha_log.item_list.items():
pool = Pool(
five=[pool_name],
four=[],
name=pool_name,
to=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
**{"from": "2020-09-28 00:00:00"},
)
all_five, _ = await self.get_all_5_star_items(items, assets, pool_name)
for item in all_five:
pool.parse(item)
pool.count_item(items)
pools.append(pool)
pool_data = [
{
"count": up_pool.count,
"list": up_pool.to_list(),
"name": up_pool.name,
"start": up_pool.start.strftime("%Y-%m-%d"),
"end": up_pool.end.strftime("%Y-%m-%d"),
}
for up_pool in pools
]
return {
"uid": client.uid,
"typeName": "五星列表",
"pool": pool_data,
"hasMore": False,
}
@staticmethod
def convert_xlsx_to_uigf(data: BytesIO, zh_dict: dict) -> dict:
"""转换 paimone.moe 或 非小酋 导出 xlsx 数据为 UIGF 格式

View File

@ -382,16 +382,22 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
message = update.effective_message
user = update.effective_user
pool_type = BannerType.CHARACTER1
all_five = False
if args := get_all_args(context):
if "武器" in args:
pool_type = BannerType.WEAPON
elif "常驻" in args:
pool_type = BannerType.STANDARD
logger.info(f"用户 {user.full_name}[{user.id}] 抽卡统计命令请求 || 参数 {pool_type.name}")
elif "仅五星" in args:
all_five = True
logger.info(f"用户 {user.full_name}[{user.id}] 抽卡统计命令请求 || 参数 {pool_type.name} || 仅五星 {all_five}")
try:
client = await get_genshin_client(user.id, need_cookie=False)
group = filters.ChatType.GROUPS.filter(message)
await message.reply_chat_action(ChatAction.TYPING)
if all_five:
data = await self.gacha_log.get_all_five_analysis(user.id, client, self.assets_service)
else:
data = await self.gacha_log.get_pool_analysis(user.id, client, pool_type, self.assets_service, group)
if isinstance(data, str):
reply_message = await message.reply_text(data)