mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 15:36:44 +00:00
✨ Add gacha_count only_five_star support
This commit is contained in:
parent
e18f060a16
commit
463670be69
@ -558,6 +558,47 @@ class GachaLog:
|
|||||||
"hasMore": len(pool_data) > 6,
|
"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
|
@staticmethod
|
||||||
def convert_xlsx_to_uigf(data: BytesIO, zh_dict: dict) -> dict:
|
def convert_xlsx_to_uigf(data: BytesIO, zh_dict: dict) -> dict:
|
||||||
"""转换 paimone.moe 或 非小酋 导出 xlsx 数据为 UIGF 格式
|
"""转换 paimone.moe 或 非小酋 导出 xlsx 数据为 UIGF 格式
|
||||||
|
@ -382,17 +382,23 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
|||||||
message = update.effective_message
|
message = update.effective_message
|
||||||
user = update.effective_user
|
user = update.effective_user
|
||||||
pool_type = BannerType.CHARACTER1
|
pool_type = BannerType.CHARACTER1
|
||||||
|
all_five = False
|
||||||
if args := get_all_args(context):
|
if args := get_all_args(context):
|
||||||
if "武器" in args:
|
if "武器" in args:
|
||||||
pool_type = BannerType.WEAPON
|
pool_type = BannerType.WEAPON
|
||||||
elif "常驻" in args:
|
elif "常驻" in args:
|
||||||
pool_type = BannerType.STANDARD
|
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:
|
try:
|
||||||
client = await get_genshin_client(user.id, need_cookie=False)
|
client = await get_genshin_client(user.id, need_cookie=False)
|
||||||
group = filters.ChatType.GROUPS.filter(message)
|
group = filters.ChatType.GROUPS.filter(message)
|
||||||
await message.reply_chat_action(ChatAction.TYPING)
|
await message.reply_chat_action(ChatAction.TYPING)
|
||||||
data = await self.gacha_log.get_pool_analysis(user.id, client, pool_type, self.assets_service, group)
|
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):
|
if isinstance(data, str):
|
||||||
reply_message = await message.reply_text(data)
|
reply_message = await message.reply_text(data)
|
||||||
if filters.ChatType.GROUPS.filter(message):
|
if filters.ChatType.GROUPS.filter(message):
|
||||||
|
Loading…
Reference in New Issue
Block a user