Skip to content

Commit

Permalink
feat(user): must write client_type in define (#20)
Browse files Browse the repository at this point in the history
* chore(user): update to `2.1.1`

* doc(user): add link of `UserChannel`
  • Loading branch information
GuangChen2333 authored Jun 6, 2024
1 parent 671db57 commit 9fe4202
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
10 changes: 3 additions & 7 deletions docs/api/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ _class mhyy.NotificationType_
## User

_class mhyy.User(combo_token: str, sys_version: str, device_id: str, device_name: str, device_model: str,
*, game_type: Optional[[GameType](#gametype)] = None, client_type: Optional[[UserClientType](#userclienttype)] =
None, channel: Optional[UserChannel] = UserChannel.Official
client_type: [UserClientType](#userclienttype), *, game_type: Optional[[GameType](#gametype)] = None,
channel: Optional[[UserChannel](#userchannel)] = UserChannel.Official
)_

> 用户类。
Expand All @@ -178,14 +178,10 @@ None, channel: Optional[UserChannel] = UserChannel.Official
> - device_id (**str**): 对应 headers 中的 x-rpc-device_id。
> - device_name (**str**): 对应 headers 中的 x-rpc-device_name。
> - device_model (**str**): 对应 headers 中的 x-rpc-device_model。
> - client_type (**[UserClientType](#userclienttype)**): 用户的客户端种类。
> - game_type (**Optional[[GameType](#gametype)]**): 游戏类型,若为空则将会从 combo_token 中自动识别。
> - client_type (**Optional[[UserClientType](#userclienttype)]**): 用户的客户端种类。
> - channel (**Optional[[UserChannel](#userchannel)]**): 用户的游戏渠道。
!!! Warning

在下一次迭代 (v2.1.1) 中,将强制要求指定 `client_type`

!!! Note

这里不提供成员的文档说明,因为他是形参的 Getter。
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "mhyy.py"
version = "2.1.0"
version = "2.1.1"
authors = [
{ name = "GuangChen2333", email = "guangchenworks@outlook.com" },
]
Expand Down
11 changes: 2 additions & 9 deletions src/mhyy/_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(
device_id: str,
device_name: str,
device_model: str,
client_type: UserClientType,
*,
game_type: Optional[GameType] = None,
client_type: Optional[UserClientType] = None,
channel: Optional[UserChannel] = UserChannel.Official
):
"""
Expand All @@ -30,8 +30,8 @@ def __init__(
device_id (str): 对应 headers 中的 x-rpc-device_id。
device_name (str): 对应 headers 中的 x-rpc-device_name。
device_model (str): 对应 headers 中的 x-rpc-device_model。
client_type (UserClientType): 用户的客户端种类。
game_type (Optional[GameType]): 游戏类型,若为空则将会从 combo_token 中自动识别。
client_type (Optional[UserClientType]): 用户的客户端种类。
channel (Optional[UserChannel]): 用户的游戏渠道。
"""
self._combo_token = combo_token
Expand All @@ -58,13 +58,6 @@ def __init__(
"hkrpg_cn": GameType.StarRail
}[bi]

if self._client_type is None:
self._client_type = UserClientType.Android
warnings.warn(
"In future versions, unspecified client_type will no longer be supported.",
UserWarning
)

if self._game_type is None:
self._game_type = detected_game_type
else:
Expand Down

0 comments on commit 9fe4202

Please sign in to comment.