diff --git a/modules/gacha_log/log.py b/modules/gacha_log/log.py index 7516efb..6ff5f32 100644 --- a/modules/gacha_log/log.py +++ b/modules/gacha_log/log.py @@ -35,6 +35,7 @@ from modules.gacha_log.models import ( SRGFModel, ) from utils.const import PROJECT_ROOT +from utils.uid import mask_number if TYPE_CHECKING: from core.dependence.assets import AssetsService @@ -527,7 +528,7 @@ class GachaLog: last_time = data[0].time.strftime("%Y-%m-%d %H:%M") first_time = data[-1].time.strftime("%Y-%m-%d %H:%M") return { - "uid": player_id, + "uid": mask_number(player_id), "allNum": total, "type": pool.value, "typeName": pool_name, @@ -579,7 +580,7 @@ class GachaLog: ) pool_data = [i for i in pool_data if i["count"] > 0] return { - "uid": player_id, + "uid": mask_number(player_id), "typeName": pool_name, "pool": pool_data[:6] if group else pool_data, "hasMore": len(pool_data) > 6, @@ -620,7 +621,7 @@ class GachaLog: for up_pool in pools ] return { - "uid": player_id, + "uid": mask_number(player_id), "typeName": "五星列表", "pool": pool_data, "hasMore": False, diff --git a/plugins/starrail/activity.py b/plugins/starrail/activity.py index ce15f64..b9e7b94 100644 --- a/plugins/starrail/activity.py +++ b/plugins/starrail/activity.py @@ -16,6 +16,7 @@ from core.services.template.services import TemplateService from gram_core.services.template.models import RenderResult, RenderGroupResult from plugins.tools.genshin import GenshinHelper from utils.log import logger +from utils.uid import mask_number if TYPE_CHECKING: from simnet import StarRailClient @@ -100,7 +101,7 @@ class PlayerActivityPlugins(Plugin): for avatar in record.lineup: avatar_icons[avatar.id] = self.assets.avatar.square(avatar.id).as_uri() return { - "uid": uid, + "uid": mask_number(uid), "records": data.records, "avatar_icons": avatar_icons, } @@ -156,7 +157,7 @@ class PlayerActivityPlugins(Plugin): for avatar in record.avatars: avatar_icons[avatar.id] = self.assets.avatar.square(avatar.id).as_uri() return { - "uid": uid, + "uid": mask_number(uid), "records": data.records, "avatar_icons": avatar_icons, } @@ -230,7 +231,7 @@ class PlayerActivityPlugins(Plugin): def render(record: StarRailTreasureDungeonRecord) -> Coroutine[Any, Any, RenderResult]: render_data = { - "uid": uid, + "uid": mask_number(uid), "record": record, "avatar_icons": avatar_icons, } diff --git a/plugins/starrail/avatar_list.py b/plugins/starrail/avatar_list.py index f441a2a..fa76375 100644 --- a/plugins/starrail/avatar_list.py +++ b/plugins/starrail/avatar_list.py @@ -13,6 +13,7 @@ from core.services.template.services import TemplateService from core.services.wiki.services import WikiService from plugins.tools.genshin import GenshinHelper from utils.log import logger +from utils.uid import mask_number if TYPE_CHECKING: from simnet import StarRailClient @@ -123,7 +124,7 @@ class AvatarListPlugin(Plugin): avatar_datas = await self.get_final_data(characters) render_data = { - "uid": client.player_id, # 玩家uid + "uid": mask_number(client.player_id), # 玩家uid "nickname": nickname, # 玩家昵称 "avatar_datas": avatar_datas, # 角色数据 "has_more": has_more, # 是否显示了全部角色 diff --git a/plugins/starrail/challenge.py b/plugins/starrail/challenge.py index 561f23e..3a77fdb 100644 --- a/plugins/starrail/challenge.py +++ b/plugins/starrail/challenge.py @@ -18,6 +18,7 @@ from core.services.template.models import RenderGroupResult, RenderResult from core.services.template.services import TemplateService from plugins.tools.genshin import GenshinHelper, CookiesNotFoundError from utils.log import logger +from utils.uid import mask_number try: import ujson as jsonlib @@ -243,7 +244,7 @@ class ChallengePlugin(Plugin): render_data = { "time": time, "stars": total_stars, - "uid": uid, + "uid": mask_number(uid), "max_floor": abyss_data.max_floor, "total_battles": abyss_data.total_battles, "floor_colors": { diff --git a/plugins/starrail/daily_note.py b/plugins/starrail/daily_note.py index 2cb39eb..ba61277 100644 --- a/plugins/starrail/daily_note.py +++ b/plugins/starrail/daily_note.py @@ -12,6 +12,7 @@ from core.services.template.models import RenderResult from core.services.template.services import TemplateService from plugins.tools.genshin import GenshinHelper from utils.log import logger +from utils.uid import mask_number if TYPE_CHECKING: from simnet import StarRailClient @@ -52,7 +53,7 @@ class DailyNotePlugin(Plugin): remained_time = (datetime.now().astimezone() + remained_time).strftime("%m-%d %H:%M") render_data = { - "uid": client.player_id, + "uid": mask_number(client.player_id), "day": day, "resin_recovery_time": resin_recovery_time, "current_resin": daily_info.current_stamina, diff --git a/plugins/starrail/ledger.py b/plugins/starrail/ledger.py index 0b28afb..6b11ee5 100644 --- a/plugins/starrail/ledger.py +++ b/plugins/starrail/ledger.py @@ -15,6 +15,7 @@ from core.services.template.models import RenderResult from core.services.template.services import TemplateService from plugins.tools.genshin import GenshinHelper from utils.log import logger +from utils.uid import mask_number if TYPE_CHECKING: from simnet import StarRailClient @@ -57,7 +58,7 @@ class LedgerPlugin(Plugin): return f"{round(amount / 10000, 2)}w" if amount >= 10000 else amount ledger_data = { - "uid": client.player_id, + "uid": mask_number(client.player_id), "day": month, "current_hcoin": format_amount(diary_info.month_data.current_hcoin), "gacha": int(diary_info.month_data.current_hcoin / 160), diff --git a/plugins/starrail/museum.py b/plugins/starrail/museum.py index 12c1a4c..fb6af1d 100644 --- a/plugins/starrail/museum.py +++ b/plugins/starrail/museum.py @@ -13,6 +13,7 @@ from core.services.template.models import RenderResult from core.services.template.services import TemplateService from plugins.tools.genshin import GenshinHelper, CookiesNotFoundError from utils.log import logger +from utils.uid import mask_number if TYPE_CHECKING: from simnet import StarRailClient @@ -107,7 +108,7 @@ class PlayerMuseumPlugins(Plugin): exhibitions.append(exhibition) all_exhibitions = [exhibitions[i : i + 7] for i in range(0, len(exhibitions), 7)] return { - "uid": uid, + "uid": mask_number(uid), "basic": basic, "all_exhibitions": all_exhibitions, "directors": detail.director, diff --git a/plugins/starrail/player_cards.py b/plugins/starrail/player_cards.py index 01d7ced..426ed6a 100644 --- a/plugins/starrail/player_cards.py +++ b/plugins/starrail/player_cards.py @@ -19,6 +19,7 @@ from modules.apihelper.client.components.player_cards import PlayerCards as Play from modules.playercards.fight_prop import EquipmentsStats from modules.playercards.helpers import ArtifactStatsTheory from utils.log import logger +from utils.uid import mask_number if TYPE_CHECKING: from telegram.ext import ContextTypes @@ -375,7 +376,7 @@ class PlayerCards(Plugin): if idx > 3: break return { - "uid": data.uid, + "uid": mask_number(data.uid), "level": data.level or 0, "signature": data.signature or "", "characters": characters_data, @@ -478,7 +479,7 @@ class RenderTemplate: for index in range(5): skills[index] = self.character.skillTreeList[index].level data = { - "uid": self.uid, + "uid": mask_number(self.uid), "character": self.character, "character_detail": self.wiki_service.character.get_by_id(self.character.avatarId), "weapon": weapon, diff --git a/plugins/starrail/rogue.py b/plugins/starrail/rogue.py index 9301617..0282f10 100644 --- a/plugins/starrail/rogue.py +++ b/plugins/starrail/rogue.py @@ -14,6 +14,7 @@ from core.services.template.models import RenderResult from core.services.template.services import TemplateService from plugins.tools.genshin import GenshinHelper, CookiesNotFoundError from utils.log import logger +from utils.uid import mask_number if TYPE_CHECKING: from simnet import StarRailClient @@ -137,7 +138,7 @@ class PlayerRoguePlugins(Plugin): new_avatars[idx] = RogueCharacter(**old_avatar) return { - "uid": uid, + "uid": mask_number(uid), "basic": data.basic_info, "name": f"{record.name} {luo_ma_bum[record.difficulty]}", "finish_cnt": record_raw.basic.finish_cnt, diff --git a/plugins/starrail/sign.py b/plugins/starrail/sign.py index f97c38f..790acbc 100644 --- a/plugins/starrail/sign.py +++ b/plugins/starrail/sign.py @@ -114,7 +114,7 @@ class Sign(Plugin): not filters.ChatType.PRIVATE.filter(message), ) reply_message = await message.reply_text( - f"UID {exc.uid} 签到失败,触发验证码风控,请尝试点击下方按钮重新签到", allow_sending_without_reply=True, reply_markup=button + "签到失败,触发验证码风控,请尝试点击下方按钮重新签到", allow_sending_without_reply=True, reply_markup=button ) if filters.ChatType.GROUPS.filter(reply_message): self.add_delete_message_job(reply_message) diff --git a/plugins/starrail/stats.py b/plugins/starrail/stats.py index a894e8e..3bcd827 100644 --- a/plugins/starrail/stats.py +++ b/plugins/starrail/stats.py @@ -11,6 +11,7 @@ from core.services.template.models import RenderResult from core.services.template.services import TemplateService from plugins.tools.genshin import GenshinHelper, CookiesNotFoundError from utils.log import logger +from utils.uid import mask_number if TYPE_CHECKING: from simnet import StarRailClient @@ -100,7 +101,7 @@ class PlayerStatsPlugins(Plugin): user_info = user_info.copy(deep=True) data = { - "uid": uid, + "uid": mask_number(uid), "info": user_info.info, "stats": user_info.stats, "stats_labels": [ diff --git a/utils/uid.py b/utils/uid.py new file mode 100644 index 0000000..edbce0f --- /dev/null +++ b/utils/uid.py @@ -0,0 +1,8 @@ +from typing import Union + + +def mask_number(number: int) -> Union[int, str]: + if 100000000 <= number < 1000000000: + number_str = str(number) + return f"{number_str[0:2]}****{number_str[6:9]}" + return number