-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9ef94b
commit ea763d7
Showing
5 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
name: Upload Python Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
workflow_dispatch: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'''`bestdori.player` | ||
BanG Dream! 玩家信息相关操作''' | ||
|
||
from typing import Any, Optional | ||
|
||
from .utils.utils import API | ||
from .utils.network import Api | ||
from .exceptions import PlayerNotExistError | ||
|
||
class Player: | ||
'''玩家类 | ||
参数: | ||
id (int): 玩家 ID | ||
server (str): 服务器 | ||
''' | ||
def __init__(self, id: int, server: str) -> None: | ||
self.id: int = id | ||
self.server: str = server | ||
self._info: Optional[dict[str, Any]] = None | ||
|
||
def get(self) -> dict[str, Any]: | ||
'''获取玩家信息 | ||
返回: | ||
dict[str, Any]: 玩家信息 | ||
''' | ||
if self._info is None: | ||
params = { | ||
'mode': 2 | ||
} | ||
_info = Api( | ||
API['player']['info'].format(server=self.server, id=self.id) | ||
).request('get', params=params).json() | ||
if not _info.get('result', False): | ||
raise ValueError(f'Invalid Server: {self.server}') | ||
_data: dict[str, Any] = _info.get('data', {}) | ||
_profile: Optional[dict[str, Any]] = _data.get('profile', None) | ||
if _profile is None: | ||
raise PlayerNotExistError(self.server, self.id) | ||
self._info = _profile | ||
|
||
return self._info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
setup( | ||
name='bestdori-api', | ||
version='0.0.19', | ||
version='0.1.0', | ||
author='WindowsSov8', | ||
author_email='[email protected]', | ||
description='Bestdori 的各种 API 调用整合,另外附带部分功能', | ||
|