跳转至

开发人员接口

Client

mhyy.Client()

米哈云游客户端。

versions: dict

所有游戏类型的版本号字典,若只想获取指定游戏类型的版本号,请使用 get_client_version() 方法。

get_wallet_data(self, user: User)

获取指定用户的钱包数据。

形参:

  • user (User): 发起请求的用户。

返回值: WalletData - 该用户的钱包数据。

get_notifications(self, user: User, *, status: Optional[NotificationStatus] = None, type_: Optional[NotificationType] = None, is_sort: Optional[bool] = True)

获取指定用户的通知信息。

形参:

  • user (User): 发起请求的用户。
  • status (Optional[NotificationStatus]): 筛选指定的通知状态。
  • type_ (Optional[NotificationType]): 筛选指定的通知种类。
  • Optional (Optional[bool]): 是否排序。

返回值: List[Notification] - 一个列表,包含了指定用户的通知信息。

get_client_version(self, game_type: GameType)

获取指定游戏类型的版本号,若想获取字典类型的所有版本号,请使用 versions 属性。

形参:

返回值: str - 该游戏类型的版本号。

GameType

class mhyy.GameType

游戏类型。

GenshinImpact = 0

云·原神。

StarRail = 1

云·星穹铁道。

Notification

通知类。

class mhyy.Notification (id_: str, status: NotificationStatus, type_: NotificationType, priority: int, source: str, desc: str, msg: str, created_at: str)

Note

这里不提供构造方法,因为根本没有导出。

id: str

通知 ID。

status: NotificationStatus

通知状态。

type: NotificationType

通知种类。

priority: int

作用未知,根据名称推测是通知的优先级。

source: str

作用未知。

desc: str

作用未知,根据名称推测是通知的描述。

msg: str

一个字符串,包含了 json 文本格式的该通知的内容。

create_at: str

一个字符串,是秒级的时间戳 (10位),描述了该通知何时被创建。

from_data_dict(cls, data: dict)

从特定的数据结构生成 Notification。

形参:

  • data (dict): 消息数据。

返回值: Notification - 包装后的消息数据。

NotificationStatus

class mhyy.NotificationStatus

通知状态。

Read = 'NotificationStatusRead'

已读。

Unread = 'NotificationStatusUnread'

未读。

Undefined = 'NotificationStatusUndefined'

未定义。

get_status_by_name(cls, status: str)

从字符串获取枚举成员。

形参:

  • status (str): 成员字符串。

返回值: NotificationStatus - 枚举成员。

NotificationType

class mhyy.NotificationType

通知种类。

Popup = 'NotificationTypePopup'

弹窗通知。

Undefined = 'NotificationTypeUndefined'

未定义。

get_type_by_name(cls, type_: str)

从字符串获取枚举成员。

形参:

  • status (str): 成员字符串。

返回值: NotificationType - 枚举成员。

User

class mhyy.User(combo_token: str, sys_version: str, device_id: str, device_name: str, device_model: str, *, game_type: Optional[GameType] = None, client_type: Optional[UserClientType] = UserClientType.Android, channel: Optional[UserChannel] = UserChannel.Official )

用户类。

形参:

  • combo_token (str): 对应 headers 中的 x-rpc-combo_token。
  • sys_version (str): 对应 headers 中的 x-rpc-sys_version。
  • device_id (str): 对应 headers 中的 x-rpc-device_id。
  • device_name (str): 对应 headers 中的 x-rpc-device_name。
  • device_model (str): 对应 headers 中的 x-rpc-device_model。
  • game_type (Optional[GameType]): 游戏类型,若为空则将会从 combo_token 中自动识别。
  • client_type (Optional[UserClientType]): 用户的客户端种类。
  • channel (Optional[UserChannel]): 用户的游戏渠道。

Note

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

combo_token: str

sys_version: str

device_id: str

device_name: str

device_model: str

client_type: str

game_type: GameType

channel: UserChannel

get_user_headers(self)

获取该用户的 headers。

返回值: dict - 字典格式的该用户的 headers。

UserChannel

class mhyy.UserChannel

游戏渠道。

Note

目前 mhyy.py 仅支持官方服务器的操作。

Official = 0

官方服。

UserClientType

class mhyy.UserClientType

客户端类型。

Note

目前 mhyy.py 仅支持模拟安卓设备操作。

Android = 2

安卓。

WalletData

class mhyy.WalletData

Info

事实上,mhyy.WalletData包含五个子类,分别是 mhyy.CoinDatamhyy.FreeTimeDatamhyy.StatusDatamhyy.StatDatamhyy.PlayCardData

但这些成员子类都没有导出且mhyy.WalletData与他的成员子类都是 dataclass。 没有构造函数,仅供读取数据。

所以在本文档中不会描述其五个子类,仅当作成员描写。

coin

用户的 原点 / 星云币 时长数据。

coin.coin_num: int

原点 / 星云币 数。

coin.free_coin_num: int

免费 原点 / 星云币 数。

coin.coin_limit: int

原点 / 星云币 的数量上限。

coin.exchange: int

与原点时长的汇率。通常来说,10 原点 / 星云币 = 1 游戏时长。

free_time

用户的免费时长数据。

free_time.send_freetime: int

若该用户是本日第一次登录,那么此处的值为每日赠送的免费时长 (min)。反之,此处恒为 0。

free_time.free_time: int

总免费时长 (min)。

free_time.free_time_limit: int

免费时长上限 (min)。

free_time.over_freetime: int

该用户是本日第一次登录且赠送的时长有一部分超出了免费时长上限,那么此处的值为溢出的免费时长 (min)。

status

未知数据

Warning

这是一条未知的数据,具体内容待补充。

status.status: int

status.msg: str

status.total_time_status: int

status.status_new: int

stat

未知数据

Warning

这是一条未知的数据,具体内容待补充。

vip_point: str

play_card

用户的畅玩卡数据

play_card.expire: str

畅玩卡过期时间(格式未知)

Warning

这是一条未知的数据,请谨慎使用。

play_card.msg: str

畅玩卡信息

play_card.short_msg: str

畅玩卡短信息 / 状态

play_card.play_card_limit: str

未知

Warning

这是一条未知的数据,具体内容待补充。