mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
🐛 Fix conversation admin check handle
This commit is contained in:
parent
9c343e2e72
commit
d0cf14e4b0
@ -252,6 +252,17 @@ class _Conversation(_Plugin, ConversationFuncs, ABC):
|
||||
|
||||
handlers: List[HandlerType] = []
|
||||
for data in datas:
|
||||
if data.admin:
|
||||
handlers.append(
|
||||
AdminHandler(
|
||||
handler=data.type(
|
||||
callback=func,
|
||||
**data.kwargs,
|
||||
),
|
||||
application=self.application,
|
||||
)
|
||||
)
|
||||
else:
|
||||
handlers.append(
|
||||
data.type(
|
||||
callback=func,
|
||||
|
@ -7,7 +7,7 @@ from modules.gacha.error import GachaIllegalArgument
|
||||
from modules.gacha.utils import lerp
|
||||
|
||||
|
||||
class BannerType(Enum):
|
||||
class GenshinBannerType(Enum):
|
||||
STANDARD = 0
|
||||
EVENT = 1
|
||||
WEAPON = 2
|
||||
@ -35,7 +35,7 @@ class GachaBanner(BaseModel):
|
||||
title: str = ""
|
||||
html_title: str = ""
|
||||
banner_id: str = ""
|
||||
banner_type: BannerType = BannerType.STANDARD
|
||||
banner_type: GenshinBannerType = GenshinBannerType.STANDARD
|
||||
wish_max_progress: int = 0
|
||||
pool_balance_weights4: Tuple[int] = ((1, 255), (17, 255), (21, 10455))
|
||||
pool_balance_weights5: Tuple[int] = ((1, 30), (147, 150), (181, 10230))
|
||||
@ -58,7 +58,7 @@ class GachaBanner(BaseModel):
|
||||
raise GachaIllegalArgument
|
||||
|
||||
def has_epitomized(self):
|
||||
return self.banner_type == BannerType.WEAPON
|
||||
return self.banner_type == GenshinBannerType.WEAPON
|
||||
|
||||
def get_event_chance(self, rarity: int) -> int:
|
||||
if rarity == 4:
|
||||
|
@ -2,7 +2,7 @@ from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from modules.gacha.banner import BannerType, GachaBanner
|
||||
from modules.gacha.banner import GenshinBannerType, GachaBanner
|
||||
from modules.gacha.player.banner import PlayerGachaBannerInfo
|
||||
|
||||
|
||||
@ -23,8 +23,8 @@ class PlayerGachaInfo(BaseModel):
|
||||
self.event_character_banner = PlayerGachaBannerInfo()
|
||||
|
||||
def get_banner_info(self, banner: GachaBanner) -> PlayerGachaBannerInfo:
|
||||
if banner.banner_type == BannerType.EVENT:
|
||||
if banner.banner_type == GenshinBannerType.EVENT:
|
||||
return self.event_character_banner
|
||||
if banner.banner_type == BannerType.WEAPON:
|
||||
if banner.banner_type == GenshinBannerType.WEAPON:
|
||||
return self.event_weapon_banner
|
||||
return self.standard_banner
|
||||
|
@ -1,13 +1,13 @@
|
||||
from genshin.models import BannerType
|
||||
from genshin.models import GenshinBannerType
|
||||
|
||||
PAIMONMOE_VERSION = 3
|
||||
UIGF_VERSION = "v2.2"
|
||||
|
||||
|
||||
GACHA_TYPE_LIST = {
|
||||
BannerType.NOVICE: "新手祈愿",
|
||||
BannerType.PERMANENT: "常驻祈愿",
|
||||
BannerType.WEAPON: "武器祈愿",
|
||||
BannerType.CHARACTER1: "角色祈愿",
|
||||
BannerType.CHARACTER2: "角色祈愿",
|
||||
GenshinBannerType.NOVICE: "新手祈愿",
|
||||
GenshinBannerType.PERMANENT: "常驻祈愿",
|
||||
GenshinBannerType.WEAPON: "武器祈愿",
|
||||
GenshinBannerType.CHARACTER1: "角色祈愿",
|
||||
GenshinBannerType.CHARACTER2: "角色祈愿",
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ from typing import Dict, IO, List, Optional, Tuple, Union
|
||||
|
||||
import aiofiles
|
||||
from genshin import AuthkeyTimeout, Client, InvalidAuthkey
|
||||
from genshin.models import BannerType
|
||||
from genshin.models import GenshinBannerType
|
||||
from openpyxl import load_workbook
|
||||
|
||||
from core.dependence.assets import AssetsService
|
||||
@ -164,7 +164,7 @@ class GachaLog:
|
||||
def import_data_backend(all_items: List[GachaItem], gacha_log: GachaLogInfo, temp_id_data: Dict) -> int:
|
||||
new_num = 0
|
||||
for item_info in all_items:
|
||||
pool_name = GACHA_TYPE_LIST[BannerType(int(item_info.gacha_type))]
|
||||
pool_name = GACHA_TYPE_LIST[GenshinBannerType(int(item_info.gacha_type))]
|
||||
if item_info.id not in temp_id_data[pool_name]:
|
||||
gacha_log.item_list[pool_name].append(item_info)
|
||||
temp_id_data[pool_name].append(item_info.id)
|
||||
@ -482,7 +482,7 @@ class GachaLog:
|
||||
return f"{pool_name} · 非"
|
||||
return pool_name
|
||||
|
||||
async def get_analysis(self, user_id: int, client: Client, pool: BannerType, assets: AssetsService):
|
||||
async def get_analysis(self, user_id: int, client: Client, pool: GenshinBannerType, assets: AssetsService):
|
||||
"""
|
||||
获取抽卡记录分析数据
|
||||
:param user_id: 用户id
|
||||
@ -502,13 +502,13 @@ class GachaLog:
|
||||
all_five, no_five_star = await self.get_all_5_star_items(data, assets, pool_name)
|
||||
all_four, no_four_star = await self.get_all_4_star_items(data, assets)
|
||||
summon_data = None
|
||||
if pool == BannerType.CHARACTER1:
|
||||
if pool == GenshinBannerType.CHARACTER1:
|
||||
summon_data = self.get_301_pool_data(total, all_five, no_five_star, no_four_star)
|
||||
pool_name = self.count_fortune(pool_name, summon_data)
|
||||
elif pool == BannerType.WEAPON:
|
||||
elif pool == GenshinBannerType.WEAPON:
|
||||
summon_data = self.get_302_pool_data(total, all_five, all_four, no_five_star, no_four_star)
|
||||
pool_name = self.count_fortune(pool_name, summon_data, True)
|
||||
elif pool == BannerType.PERMANENT:
|
||||
elif pool == GenshinBannerType.PERMANENT:
|
||||
summon_data = self.get_200_pool_data(total, all_five, all_four, no_five_star, no_four_star)
|
||||
pool_name = self.count_fortune(pool_name, summon_data)
|
||||
last_time = data[0].time.strftime("%Y-%m-%d %H:%M")
|
||||
@ -526,7 +526,7 @@ class GachaLog:
|
||||
}
|
||||
|
||||
async def get_pool_analysis(
|
||||
self, user_id: int, client: Client, pool: BannerType, assets: AssetsService, group: bool
|
||||
self, user_id: int, client: Client, pool: GenshinBannerType, assets: AssetsService, group: bool
|
||||
) -> dict:
|
||||
"""获取抽卡记录分析数据
|
||||
:param user_id: 用户id
|
||||
|
@ -126,7 +126,7 @@ class PayLogPlugin(Plugin.Conversation):
|
||||
@conversation.entry_point
|
||||
@handler(CommandHandler, command="pay_log_delete", filters=filters.ChatType.PRIVATE, block=False)
|
||||
@handler(MessageHandler, filters=filters.Regex("^删除充值记录$") & filters.ChatType.PRIVATE, block=False)
|
||||
async def command_start_delete(self, update: Update, _: CallbackContext) -> int:
|
||||
async def command_start_delete(self, update: Update, context: CallbackContext) -> int:
|
||||
message = update.effective_message
|
||||
user = update.effective_user
|
||||
logger.info("用户 %s[%s] 删除充值记录命令请求", user.full_name, user.id)
|
||||
@ -140,6 +140,7 @@ class PayLogPlugin(Plugin.Conversation):
|
||||
if not status:
|
||||
await message.reply_text("你还没有导入充值记录哦~")
|
||||
return ConversationHandler.END
|
||||
context.chat_data["uid"] = client.uid
|
||||
await message.reply_text("你确定要删除充值记录吗?(此项操作无法恢复),如果确定请发送 ”确定“,发送其他内容取消")
|
||||
return CONFIRM_DELETE
|
||||
|
||||
|
@ -16,7 +16,7 @@ from metadata.genshin import AVATAR_DATA, WEAPON_DATA, avatar_to_game_id, weapon
|
||||
from metadata.shortname import weaponToName
|
||||
from modules.apihelper.client.components.gacha import Gacha as GachaClient
|
||||
from modules.apihelper.models.genshin.gacha import GachaInfo
|
||||
from modules.gacha.banner import BannerType, GachaBanner
|
||||
from modules.gacha.banner import GenshinBannerType, GachaBanner
|
||||
from modules.gacha.player.info import PlayerGachaInfo
|
||||
from modules.gacha.system import BannerSystem
|
||||
from utils.log import logger
|
||||
@ -99,16 +99,16 @@ class WishSimulatorHandle:
|
||||
banner.fallback_items4_pool1.append(weapon_to_game_id(r4_prob["item_name"]))
|
||||
if gacha_type in {301, 400}:
|
||||
banner.wish_max_progress = 1
|
||||
banner.banner_type = BannerType.EVENT
|
||||
banner.banner_type = GenshinBannerType.EVENT
|
||||
banner.weight4 = ((1, 510), (8, 510), (10, 10000))
|
||||
banner.weight5 = ((1, 60), (73, 60), (90, 10000))
|
||||
elif gacha_type == 302:
|
||||
banner.wish_max_progress = 2
|
||||
banner.banner_type = BannerType.WEAPON
|
||||
banner.banner_type = GenshinBannerType.WEAPON
|
||||
banner.weight4 = ((1, 600), (7, 600), (10, 10000))
|
||||
banner.weight5 = ((1, 70), (62, 70), (90, 10000))
|
||||
else:
|
||||
banner.banner_type = BannerType.STANDARD
|
||||
banner.banner_type = GenshinBannerType.STANDARD
|
||||
return banner
|
||||
|
||||
async def gacha_base_info(self, gacha_name: str = "角色活动", default: bool = False) -> GachaInfo:
|
||||
@ -228,7 +228,7 @@ class WishSimulatorPlugin(Plugin):
|
||||
player_gacha_info = await self.gacha_db.get(user.id)
|
||||
# 检查 wish_item_id
|
||||
if (
|
||||
banner.banner_type == BannerType.WEAPON
|
||||
banner.banner_type == GenshinBannerType.WEAPON
|
||||
and player_gacha_info.event_weapon_banner.wish_item_id not in banner.rate_up_items5
|
||||
):
|
||||
player_gacha_info.event_weapon_banner.wish_item_id = 0
|
||||
|
@ -2,7 +2,7 @@ from io import BytesIO
|
||||
|
||||
import genshin
|
||||
from aiofiles import open as async_open
|
||||
from genshin.models import BannerType
|
||||
from genshin.models import GenshinBannerType
|
||||
from telegram import Document, InlineKeyboardButton, InlineKeyboardMarkup, Message, Update, User
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import CallbackContext, CommandHandler, ConversationHandler, MessageHandler, filters
|
||||
@ -304,12 +304,12 @@ class WishLogPlugin(Plugin.Conversation):
|
||||
async def command_start_analysis(self, update: Update, context: CallbackContext) -> None:
|
||||
message = update.effective_message
|
||||
user = update.effective_user
|
||||
pool_type = BannerType.CHARACTER1
|
||||
pool_type = GenshinBannerType.CHARACTER1
|
||||
if args := self.get_args(context):
|
||||
if "武器" in args:
|
||||
pool_type = BannerType.WEAPON
|
||||
pool_type = GenshinBannerType.WEAPON
|
||||
elif "常驻" in args:
|
||||
pool_type = BannerType.STANDARD
|
||||
pool_type = GenshinBannerType.STANDARD
|
||||
logger.info("用户 %s[%s] 抽卡记录命令请求 || 参数 %s", user.full_name, user.id, pool_type.name)
|
||||
try:
|
||||
client = await self.helper.get_genshin_client(user.id, need_cookie=False)
|
||||
@ -358,13 +358,13 @@ class WishLogPlugin(Plugin.Conversation):
|
||||
async def command_start_count(self, update: Update, context: CallbackContext) -> None:
|
||||
message = update.effective_message
|
||||
user = update.effective_user
|
||||
pool_type = BannerType.CHARACTER1
|
||||
pool_type = GenshinBannerType.CHARACTER1
|
||||
all_five = False
|
||||
if args := self.get_args(context):
|
||||
if "武器" in args:
|
||||
pool_type = BannerType.WEAPON
|
||||
pool_type = GenshinBannerType.WEAPON
|
||||
elif "常驻" in args:
|
||||
pool_type = BannerType.STANDARD
|
||||
pool_type = GenshinBannerType.STANDARD
|
||||
elif "仅五星" in args:
|
||||
all_five = True
|
||||
logger.info("用户 %s[%s] 抽卡统计命令请求 || 参数 %s || 仅五星 %s", user.full_name, user.id, pool_type.name, all_five)
|
||||
|
Loading…
Reference in New Issue
Block a user