Skip to content

Commit

Permalink
Merge branch 'refs/heads/feat/implement_nexus' into feat/clans
Browse files Browse the repository at this point in the history
# Conflicts:
#	rustplus/api/base_rust_api.py
#	rustplus/api/rust_api.py
  • Loading branch information
olijeffers0n committed May 22, 2024
2 parents f24dfc6 + 532755a commit 3966352
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
9 changes: 9 additions & 0 deletions rustplus/api/base_rust_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,3 +683,12 @@ async def set_clan_motd(self, message: str) -> None:
:param message: The message to set
"""
raise NotImplementedError("Not Implemented")

async def get_nexus_player_token(self, app_key: str) -> str:
"""
Gets the Nexus Player Token for the server
:param app_key: The App Key for the server
:return str: The Nexus Player Token
"""
raise NotImplementedError("Not Implemented")
16 changes: 16 additions & 0 deletions rustplus/api/rust_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
AppSendMessage,
AppSetEntityValue,
AppPromoteToLeader,
AppGetNexusAuth,
)
from .remote import HeartBeat, RateLimiter
from ..commands import CommandOptions
Expand Down Expand Up @@ -484,3 +485,18 @@ async def set_clan_motd(self, message: str) -> None:
await self.remote.add_ignored_response(app_request.seq)

await self.remote.send_message(app_request)

async def get_nexus_player_token(self, app_key: str) -> str:
await self._handle_ratelimit()

app_request = self._generate_protobuf()

get_auth = AppGetNexusAuth()
get_auth.app_key = app_key
app_request.get_nexus_auth = get_auth

await self.remote.send_message(app_request)

app_message = await self.remote.get_response(app_request.seq, app_request)

return app_message.response.nexus_auth
20 changes: 19 additions & 1 deletion rustplus/api/structures/rust_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, data: AppInfo) -> None:
self._queued_players: int = data.queued_players
self._seed: int = data.seed
self._logo_image: str = data.logo_image
self._nexus: str = data.nexus
self._nexus_id: int = data.nexus_id
self._nexus_zone: str = data.nexus_zone

@property
def url(self) -> str:
Expand Down Expand Up @@ -60,10 +63,22 @@ def header_image(self) -> str:
def logo_image(self) -> str:
return self._logo_image

@property
def nexus(self) -> str:
return self._nexus

@property
def nexus_id(self) -> int:
return self._nexus_id

@property
def nexus_zone(self) -> str:
return self._nexus_zone

def __str__(self) -> str:
return (
"RustInfo[url={}, name={}, map={}, size={}, players={}, max_players={}, queued_players={}, seed={}, "
"wipe_time={}, header_image={}, logo_image={}]".format(
"wipe_time={}, header_image={}, logo_image={}, nexus={}, nexus_id={}, nexus_zone={}]".format(
self._url,
self._name,
self._map,
Expand All @@ -75,5 +90,8 @@ def __str__(self) -> str:
self._wipe_time,
self._header_image,
self._logo_image,
self._nexus,
self._nexus_id,
self._nexus_zone,
)
)

0 comments on commit 3966352

Please sign in to comment.