Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added /api/bot/online API #8

Merged
merged 5 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Most of the API is available:
client.board.claim_victory
client.board.go_berserk

client.bots.online
kalpgarg marked this conversation as resolved.
Show resolved Hide resolved
client.bots.stream_incoming_events
client.bots.stream_game_state
client.bots.make_move
Expand Down
11 changes: 11 additions & 0 deletions berserk/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,17 @@ def stream_game_state(self, game_id: str) -> Iterator[Dict[str, Any]]:
path = f"api/bot/game/stream/{game_id}"
yield from self._r.get(path, stream=True, converter=models.GameState.convert)

def get_online_bots(self, limit: int | None = None) -> Iterator[Dict[str, Any]]:
"""
Stream the online bot users.

:param limit: Maximum number of bot users to fetch
kalpgarg marked this conversation as resolved.
Show resolved Hide resolved
:return: Iterator over the results
kalpgarg marked this conversation as resolved.
Show resolved Hide resolved
kalpgarg marked this conversation as resolved.
Show resolved Hide resolved
"""
path = f"api/bot/online"
kalpgarg marked this conversation as resolved.
Show resolved Hide resolved
params = {"nb": limit}
return self._r.get(path, params=params, stream=True)
kalpgarg marked this conversation as resolved.
Show resolved Hide resolved

def make_move(self, game_id: str, move: str) -> None:
"""Make a move in a bot game.

Expand Down