diff --git a/plugin/methods/get_real_uid_or_offset.py b/plugin/methods/get_real_uid_or_offset.py index dc76622..ce67b61 100644 --- a/plugin/methods/get_real_uid_or_offset.py +++ b/plugin/methods/get_real_uid_or_offset.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Optional, Tuple if TYPE_CHECKING: from telegram import Update -REGEX = r"@(\d{10})|@(\d{9})|@(\d)" +REGEX = r"@(\d{10})|@(\d{9})|@(\d{8})|@(\d)" def get_real_uid_or_offset_by_text(text: str) -> Tuple[Optional[int], Optional[int]]: diff --git a/services/players/models.py b/services/players/models.py index a480568..dfedfd4 100644 --- a/services/players/models.py +++ b/services/players/models.py @@ -12,7 +12,7 @@ try: except ImportError: import json as jsonlib -__all__ = ("Player", "PlayersDataBase", "PlayerInfo", "PlayerInfoSQLModel") +__all__ = ("Player", "PlayersDataBase", "PlayerInfo", "PlayerInfoSQLModel", "ExtraPlayerInfo") class Player(SQLModel): @@ -34,10 +34,12 @@ class PlayersDataBase(Player, table=True): class ExtraPlayerInfo(BaseModel): class Config(BaseSettings.Config): + frozen = False json_loads = jsonlib.loads json_dumps = jsonlib.dumps waifu_id: Optional[int] = None + level: Optional[int] = None class ExtraPlayerType(TypeDecorator): # pylint: disable=W0223 diff --git a/services/players/repositories.py b/services/players/repositories.py index c11ca4e..f962f21 100644 --- a/services/players/repositories.py +++ b/services/players/repositories.py @@ -18,7 +18,7 @@ class PlayersRepository(BaseService.Component): async def get( self, - user_id: int, + user_id: Optional[int] = None, player_id: Optional[int] = None, account_id: Optional[int] = None, region: Optional[RegionEnum] = None, @@ -26,7 +26,9 @@ class PlayersRepository(BaseService.Component): offset: int = 0, ) -> Optional[Player]: async with AsyncSession(self.engine) as session: - statement = select(Player).where(Player.user_id == user_id) + statement = select(Player) + if user_id is not None: + statement = statement.where(Player.user_id == user_id) if player_id is not None: statement = statement.where(Player.player_id == player_id) if account_id is not None: diff --git a/services/players/services.py b/services/players/services.py index 93711b2..ebf0626 100644 --- a/services/players/services.py +++ b/services/players/services.py @@ -14,7 +14,7 @@ class PlayersService(BaseService): async def get( self, - user_id: int, + user_id: Optional[int] = None, player_id: Optional[int] = None, account_id: Optional[int] = None, region: Optional[RegionEnum] = None,