Skip to content

Commit 9fe4202

Browse files
feat(user): must write client_type in define (#20)
* chore(user): update to `2.1.1` * doc(user): add link of `UserChannel`
1 parent 671db57 commit 9fe4202

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

docs/api/interface.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ _class mhyy.NotificationType_
165165
## User
166166

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

172172
> 用户类。
@@ -178,14 +178,10 @@ None, channel: Optional[UserChannel] = UserChannel.Official
178178
> - device_id (**str**): 对应 headers 中的 x-rpc-device_id。
179179
> - device_name (**str**): 对应 headers 中的 x-rpc-device_name。
180180
> - device_model (**str**): 对应 headers 中的 x-rpc-device_model。
181+
> - client_type (**[UserClientType](#userclienttype)**): 用户的客户端种类。
181182
> - game_type (**Optional[[GameType](#gametype)]**): 游戏类型,若为空则将会从 combo_token 中自动识别。
182-
> - client_type (**Optional[[UserClientType](#userclienttype)]**): 用户的客户端种类。
183183
> - channel (**Optional[[UserChannel](#userchannel)]**): 用户的游戏渠道。
184184
185-
!!! Warning
186-
187-
在下一次迭代 (v2.1.1) 中,将强制要求指定 `client_type`
188-
189185
!!! Note
190186

191187
这里不提供成员的文档说明,因为他是形参的 Getter。

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "mhyy.py"
7-
version = "2.1.0"
7+
version = "2.1.1"
88
authors = [
99
{ name = "GuangChen2333", email = "guangchenworks@outlook.com" },
1010
]

src/mhyy/_user.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def __init__(
1616
device_id: str,
1717
device_name: str,
1818
device_model: str,
19+
client_type: UserClientType,
1920
*,
2021
game_type: Optional[GameType] = None,
21-
client_type: Optional[UserClientType] = None,
2222
channel: Optional[UserChannel] = UserChannel.Official
2323
):
2424
"""
@@ -30,8 +30,8 @@ def __init__(
3030
device_id (str): 对应 headers 中的 x-rpc-device_id。
3131
device_name (str): 对应 headers 中的 x-rpc-device_name。
3232
device_model (str): 对应 headers 中的 x-rpc-device_model。
33+
client_type (UserClientType): 用户的客户端种类。
3334
game_type (Optional[GameType]): 游戏类型,若为空则将会从 combo_token 中自动识别。
34-
client_type (Optional[UserClientType]): 用户的客户端种类。
3535
channel (Optional[UserChannel]): 用户的游戏渠道。
3636
"""
3737
self._combo_token = combo_token
@@ -58,13 +58,6 @@ def __init__(
5858
"hkrpg_cn": GameType.StarRail
5959
}[bi]
6060

61-
if self._client_type is None:
62-
self._client_type = UserClientType.Android
63-
warnings.warn(
64-
"In future versions, unspecified client_type will no longer be supported.",
65-
UserWarning
66-
)
67-
6861
if self._game_type is None:
6962
self._game_type = detected_game_type
7063
else:

0 commit comments

Comments
 (0)