mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 15:36:44 +00:00
♻ 批量优化代码
This commit is contained in:
parent
1181e7233e
commit
91cfcdd0a7
@ -12,9 +12,7 @@ class WikiService:
|
||||
|
||||
def __init__(self, cache: WikiCache):
|
||||
self._cache = cache
|
||||
"""
|
||||
Redis 在这里的作用是作为持久化
|
||||
"""
|
||||
"""Redis 在这里的作用是作为持久化"""
|
||||
self.weapons = Weapons()
|
||||
self.characters = Characters()
|
||||
self._characters_list = []
|
||||
|
@ -79,20 +79,20 @@ class SignJob:
|
||||
text = "签到失败了呜呜呜 ~ 服务器连接超时 服务器熟啦 ~ "
|
||||
sign_db.status = SignStatusEnum.TIMEOUT_ERROR
|
||||
except BaseException as exc:
|
||||
Log.error(f"执行自动签到时发生错误", exc)
|
||||
Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc)
|
||||
continue
|
||||
if sign_db.chat_id < 0:
|
||||
text = f"<a href=\"tg://user?id={sign_db.user_id}\">NOTICE {sign_db.user_id}</a>\n\n{text}"
|
||||
try:
|
||||
await context.bot.send_message(sign_db.chat_id, text, parse_mode=ParseMode.HTML)
|
||||
except BadRequest as exc:
|
||||
Log.error(f"执行自动签到时发生错误", exc)
|
||||
Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc)
|
||||
sign_db.status = SignStatusEnum.BAD_REQUEST
|
||||
except Forbidden as exc:
|
||||
Log.error(f"执行自动签到时发生错误", exc)
|
||||
Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc)
|
||||
sign_db.status = SignStatusEnum.FORBIDDEN
|
||||
except BaseException as exc:
|
||||
Log.error(f"执行自动签到时发生错误", exc)
|
||||
Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc)
|
||||
continue
|
||||
sign_db.time_updated = datetime.datetime.now()
|
||||
await self.sign_service.update(sign_db)
|
||||
|
@ -146,7 +146,7 @@ class PlayerCardsAPI:
|
||||
consts = characters_data["Consts"]
|
||||
if 'talentIdList' in avatar_data:
|
||||
talent_id_list = avatar_data["talentIdList"]
|
||||
for index, value in enumerate(talent_id_list):
|
||||
for index, _ in enumerate(talent_id_list):
|
||||
talent_list.append(Talent(talent_id_list[index], icon=consts[index]))
|
||||
|
||||
element = characters_data["Element"]
|
||||
|
@ -1,67 +0,0 @@
|
||||
from enum import Enum
|
||||
|
||||
from models.gacha.common import ItemParamData
|
||||
|
||||
|
||||
class BannerType(Enum):
|
||||
STANDARD = 1
|
||||
EVENT = 2
|
||||
WEAPON = 3
|
||||
|
||||
|
||||
class GachaBanner:
|
||||
def __init__(self):
|
||||
self.gachaType: int = 0
|
||||
self.scheduleId: int = 0
|
||||
self.prefabPath: str = ""
|
||||
self.previewPrefabPath: str = ""
|
||||
self.titlePath: str = ""
|
||||
self.costItemId = 0
|
||||
self.costItemAmount = 1
|
||||
self.costItemId10 = 0
|
||||
self.costItemAmount10 = 10
|
||||
self.beginTime: int = 0
|
||||
self.endTime: int = 0
|
||||
self.sortId: int = 0
|
||||
self.rateUpItems4 = {}
|
||||
self.rateUpItems5 = {}
|
||||
self.fallbackItems3 = {11301, 11302, 11306, 12301, 12302, 12305, 13303, 14301, 14302, 14304, 15301, 15302,
|
||||
15304}
|
||||
self.fallbackItems4Pool1 = {1014, 1020, 1023, 1024, 1025, 1027, 1031, 1032, 1034, 1036, 1039, 1043, 1044, 1045,
|
||||
1048, 1053, 1055, 1056, 1064}
|
||||
self.fallbackItems4Pool2 = {11401, 11402, 11403, 11405, 12401, 12402, 12403, 12405, 13401, 13407, 14401, 14402,
|
||||
14403, 14409, 15401, 15402, 15403, 15405}
|
||||
self.fallbackItems5Pool1 = {1003, 1016, 1042, 1035, 1041}
|
||||
self.fallbackItems5Pool2 = {11501, 11502, 12501, 12502, 13502, 13505, 14501, 14502, 15501, 15502}
|
||||
self.removeC6FromPool = False
|
||||
self.autoStripRateUpFromFallback = True
|
||||
self.weights4 = {{1, 510}, {8, 510}, {10, 10000}}
|
||||
self.weights5 = {{1, 75}, {73, 150}, {90, 10000}}
|
||||
self.poolBalanceWeights4 = {{1, 255}, {17, 255}, {21, 10455}}
|
||||
self.poolBalanceWeights5 = {{1, 30}, {147, 150}, {181, 10230}}
|
||||
self.eventChance4 = 50
|
||||
self.eventChance5 = 50
|
||||
self.bannerType = BannerType.STANDARD
|
||||
self.rateUpItems1 = {}
|
||||
self.rateUpItems2 = {}
|
||||
self.eventChance = -1
|
||||
self.costItem = 0
|
||||
|
||||
def getGachaType(self):
|
||||
return self.gachaType
|
||||
|
||||
def getCost(self, numRolls: int):
|
||||
"""
|
||||
获取消耗的Item
|
||||
:param numRolls:
|
||||
:return:
|
||||
"""
|
||||
if numRolls == 1:
|
||||
return ItemParamData()
|
||||
elif numRolls == 10:
|
||||
return ItemParamData(self.costItemId10 if self.costItemId10 > 0 else self.getCostItem(),
|
||||
self.costItemAmount10)
|
||||
return ItemParamData()
|
||||
|
||||
def getCostItem(self):
|
||||
return self.costItem if self.costItem > 0 else self.costItemId
|
@ -1,4 +0,0 @@
|
||||
class ItemParamData:
|
||||
def __init__(self, item_id: int = 0, count: int = 0):
|
||||
self.id: int = item_id
|
||||
self.count: int = count
|
@ -1,7 +0,0 @@
|
||||
class GachaManager:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def DoPulls(self, player_id: int, gacha_type: int, times: int):
|
||||
pass
|
@ -19,10 +19,8 @@ except KeyError as error:
|
||||
|
||||
|
||||
async def error_handler(update: object, context: CallbackContext) -> None:
|
||||
"""
|
||||
记录错误并发送消息通知开发人员。
|
||||
Log the error and send a telegram message to notify the developer.
|
||||
"""
|
||||
"""记录错误并发送消息通知开发人员。 Log the error and send a telegram message to notify the developer."""
|
||||
|
||||
Log.error(msg="处理函数时发生异常:", exc_info=context.error)
|
||||
|
||||
if notice_chat_id is None:
|
||||
|
@ -73,9 +73,9 @@ class Post(BasePlugins):
|
||||
if post_handler_data is None:
|
||||
post_handler_data = PostHandlerData()
|
||||
context.chat_data["post_handler_data"] = post_handler_data
|
||||
text = "✿✿ヽ(°▽°)ノ✿ 你好! %s ,\n" \
|
||||
text = f"✿✿ヽ(°▽°)ノ✿ 你好! {user.username} ,\n" \
|
||||
"只需复制URL回复即可 \n" \
|
||||
"退出投稿只需回复退出" % (user["username"])
|
||||
"退出投稿只需回复退出"
|
||||
reply_keyboard = [['退出']]
|
||||
await message.reply_text(text, reply_markup=ReplyKeyboardMarkup(reply_keyboard, True, True))
|
||||
return self.CHECK_POST
|
||||
|
@ -84,7 +84,7 @@ def region_server(uid: Union[int, str]) -> RegionEnum:
|
||||
elif isinstance(uid, str):
|
||||
region = REGION_MAP.get(str(uid)[0])
|
||||
else:
|
||||
raise TypeError(f"UID variable type error")
|
||||
raise TypeError("UID variable type error")
|
||||
if region:
|
||||
return region
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user