rustplus 6.0.2__tar.gz → 6.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rustplus-6.0.2/rustplus.egg-info → rustplus-6.0.3}/PKG-INFO +1 -1
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/__init__.py +2 -1
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/websocket/ws.py +28 -14
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/rust_api.py +79 -43
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/__init__.py +1 -0
- rustplus-6.0.3/rustplus/structs/rust_error.py +19 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/utils/utils.py +7 -0
- {rustplus-6.0.2 → rustplus-6.0.3/rustplus.egg-info}/PKG-INFO +1 -1
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus.egg-info/SOURCES.txt +1 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/LICENSE +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/MANIFEST.in +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/README.md +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/requirements.txt +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/annotations/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/annotations/chat_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/annotations/command.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/annotations/entity_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/annotations/protobuf_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/annotations/team_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/commands/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/commands/chat_command.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/commands/chat_command_data.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/commands/command_options.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/events/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/events/chat_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/events/entity_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/events/protobuf_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/events/team_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/exceptions/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/exceptions/exceptions.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/airfield.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/arctic_base.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/bandit.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/barn.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/cargo.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/chinook.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/chinook_blades.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/crate.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/desert_base.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/dome.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/excavator.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/explosion.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/ferryterminal.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/fishing.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/harbour.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/icon.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/junkyard.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/large_oil_rig.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/launchsite.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/lighthouse.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/military_tunnels.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/mining_outpost.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/mining_quarry_hqm.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/mining_quarry_stone.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/mining_quarry_sulfur.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/missile_silo.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/outpost.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/oxums.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/patrol.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/power_plant.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/satellite.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/sewer.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/small_oil_rig.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/stables.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/supermarket.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/swamp.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/train.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/train_yard.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/underwater_lab.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/vending_machine.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/icons/water_treatment.png +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/identification/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/identification/handler_list.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/identification/registered_listener.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/identification/server_details.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/camera/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/camera/camera_constants.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/camera/camera_manager.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/camera/camera_parser.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/camera/structures.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/fcm/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/fcm/fcm_listener.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/proxy/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/proxy/proxy_value_grabber.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/ratelimiter/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/rustplus_proto/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/rustplus_proto/rustplus.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/remote/websocket/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_chat_message.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_contents.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_entity_info.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_info.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_item.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_map.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_marker.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_team_info.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/rust_time.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/serialization.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/structs/util.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/utils/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/utils/deprecated.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/utils/emojis.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/utils/fonts/PermanentMarker.ttf +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/utils/fonts/__init__.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/utils/grab_items.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus/utils/yielding_event.py +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus.egg-info/dependency_links.txt +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus.egg-info/requires.txt +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/rustplus.egg-info/top_level.txt +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/setup.cfg +0 -0
- {rustplus-6.0.2 → rustplus-6.0.3}/setup.py +0 -0
|
@@ -9,8 +9,9 @@ from .remote.fcm import FCMListener
|
|
|
9
9
|
from .commands import CommandOptions, ChatCommand
|
|
10
10
|
from .events import ChatEventPayload, TeamEventPayload, EntityEventPayload
|
|
11
11
|
from .utils import convert_event_type_to_name, Emoji
|
|
12
|
+
from .structs import RustError, RustMarker
|
|
12
13
|
|
|
13
14
|
__name__ = "rustplus"
|
|
14
15
|
__author__ = "olijeffers0n"
|
|
15
|
-
__version__ = "6.0.
|
|
16
|
+
__version__ = "6.0.3"
|
|
16
17
|
__support__ = "Discord: https://discord.gg/nQqJe8qvP8"
|
|
@@ -11,7 +11,7 @@ import asyncio
|
|
|
11
11
|
|
|
12
12
|
from ..camera import CameraManager
|
|
13
13
|
from ..proxy import ProxyValueGrabber
|
|
14
|
-
from ..rustplus_proto import AppMessage, AppRequest
|
|
14
|
+
from ..rustplus_proto import AppMessage, AppRequest, AppError
|
|
15
15
|
from ...commands import CommandOptions, ChatCommand, ChatCommandTime
|
|
16
16
|
from ...events import (
|
|
17
17
|
ProtobufEventPayload,
|
|
@@ -19,10 +19,11 @@ from ...events import (
|
|
|
19
19
|
TeamEventPayload,
|
|
20
20
|
ChatEventPayload,
|
|
21
21
|
)
|
|
22
|
-
from ...exceptions import
|
|
22
|
+
from ...exceptions import RequestError
|
|
23
23
|
from ...identification import ServerDetails, RegisteredListener
|
|
24
24
|
from ...structs import RustChatMessage, RustTeamInfo
|
|
25
25
|
from ...utils import YieldingEvent, convert_time
|
|
26
|
+
from ...utils.utils import error_present
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
class RustWebsocket:
|
|
@@ -133,14 +134,21 @@ class RustWebsocket:
|
|
|
133
134
|
)
|
|
134
135
|
|
|
135
136
|
async def send_and_get(self, request: AppRequest) -> AppMessage:
|
|
136
|
-
await self.send_message(request)
|
|
137
|
+
if not await self.send_message(request):
|
|
138
|
+
message = AppMessage()
|
|
139
|
+
error = AppError()
|
|
140
|
+
error.error = "Message Failed to send"
|
|
141
|
+
message.response.seq = request.seq
|
|
142
|
+
message.response.error = error
|
|
143
|
+
return message
|
|
137
144
|
return await self.get_response(request.seq)
|
|
138
145
|
|
|
139
146
|
async def send_message(
|
|
140
147
|
self, request: AppRequest, ignore_response: bool = False
|
|
141
|
-
) ->
|
|
148
|
+
) -> bool:
|
|
142
149
|
if self.connection is None:
|
|
143
|
-
|
|
150
|
+
self.logger.warning("No Current Websocket Connection")
|
|
151
|
+
return False
|
|
144
152
|
|
|
145
153
|
if self.debug:
|
|
146
154
|
self.logger.info(f"Sending Message with seq {request.seq}: {request}")
|
|
@@ -157,6 +165,9 @@ class RustWebsocket:
|
|
|
157
165
|
await self.connection.send(bytes(request))
|
|
158
166
|
except Exception as err:
|
|
159
167
|
self.logger.warning("WebSocket connection error: %s", err)
|
|
168
|
+
return False
|
|
169
|
+
|
|
170
|
+
return True
|
|
160
171
|
|
|
161
172
|
async def get_response(self, seq: int) -> Union[AppMessage, None]:
|
|
162
173
|
|
|
@@ -171,8 +182,18 @@ class RustWebsocket:
|
|
|
171
182
|
f"Received Message with seq {app_message.response.seq}: {app_message}"
|
|
172
183
|
)
|
|
173
184
|
|
|
174
|
-
if
|
|
175
|
-
|
|
185
|
+
if error_present(app_message):
|
|
186
|
+
|
|
187
|
+
event: YieldingEvent = self.responses.get(app_message.response.seq, None)
|
|
188
|
+
if event is not None:
|
|
189
|
+
if self.debug:
|
|
190
|
+
self.logger.info(
|
|
191
|
+
f"Running Response Event With Error: {app_message}"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
event.set_with_value(app_message)
|
|
195
|
+
else:
|
|
196
|
+
raise RequestError(app_message.response.error.error)
|
|
176
197
|
|
|
177
198
|
prefix = self.get_prefix(
|
|
178
199
|
str(app_message.broadcast.team_message.message.message)
|
|
@@ -335,13 +356,6 @@ class RustWebsocket:
|
|
|
335
356
|
|
|
336
357
|
raise ValueError()
|
|
337
358
|
|
|
338
|
-
@staticmethod
|
|
339
|
-
def error_present(message) -> bool:
|
|
340
|
-
"""
|
|
341
|
-
Checks message for error
|
|
342
|
-
"""
|
|
343
|
-
return message != ""
|
|
344
|
-
|
|
345
359
|
@staticmethod
|
|
346
360
|
async def run_coroutine_non_blocking(coroutine: Coroutine) -> Task:
|
|
347
361
|
loop: AbstractEventLoop = asyncio.get_event_loop_policy().get_event_loop()
|
|
@@ -32,6 +32,7 @@ from .structs import (
|
|
|
32
32
|
RustContents,
|
|
33
33
|
RustItem,
|
|
34
34
|
)
|
|
35
|
+
from .structs.rust_error import RustError
|
|
35
36
|
from .utils import (
|
|
36
37
|
convert_time,
|
|
37
38
|
translate_id_to_stack,
|
|
@@ -42,6 +43,7 @@ from .utils import (
|
|
|
42
43
|
convert_monument,
|
|
43
44
|
)
|
|
44
45
|
from .remote.ratelimiter import RateLimiter
|
|
46
|
+
from .utils.utils import error_present
|
|
45
47
|
|
|
46
48
|
|
|
47
49
|
class RustSocket:
|
|
@@ -127,13 +129,13 @@ class RustSocket:
|
|
|
127
129
|
This Will permanently put your script into a state of 'hanging' Cannot be Undone. Only do this in scripts
|
|
128
130
|
using commands
|
|
129
131
|
|
|
130
|
-
|
|
132
|
+
returns Nothing, This will never return
|
|
131
133
|
"""
|
|
132
134
|
|
|
133
135
|
while True:
|
|
134
136
|
await asyncio.sleep(1)
|
|
135
137
|
|
|
136
|
-
async def get_time(self) -> Union[RustTime,
|
|
138
|
+
async def get_time(self) -> Union[RustTime, RustError]:
|
|
137
139
|
"""
|
|
138
140
|
Gets the current in-game time from the server.
|
|
139
141
|
|
|
@@ -142,18 +144,21 @@ class RustSocket:
|
|
|
142
144
|
|
|
143
145
|
packet = await self._generate_request()
|
|
144
146
|
packet.get_time = AppEmpty()
|
|
145
|
-
|
|
147
|
+
response = await self.ws.send_and_get(packet)
|
|
148
|
+
|
|
149
|
+
if response is None:
|
|
150
|
+
return RustError("get_time", "misc")
|
|
146
151
|
|
|
147
|
-
if
|
|
148
|
-
return
|
|
152
|
+
if error_present(response):
|
|
153
|
+
return RustError("get_time", response.response.error.error)
|
|
149
154
|
|
|
150
155
|
return RustTime(
|
|
151
|
-
|
|
152
|
-
convert_time(
|
|
153
|
-
convert_time(
|
|
154
|
-
convert_time(
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
response.response.time.day_length_minutes,
|
|
157
|
+
convert_time(response.response.time.sunrise),
|
|
158
|
+
convert_time(response.response.time.sunset),
|
|
159
|
+
convert_time(response.response.time.time),
|
|
160
|
+
response.response.time.time,
|
|
161
|
+
response.response.time.time_scale,
|
|
157
162
|
)
|
|
158
163
|
|
|
159
164
|
async def send_team_message(self, message: str) -> None:
|
|
@@ -170,21 +175,24 @@ class RustSocket:
|
|
|
170
175
|
|
|
171
176
|
await self.ws.send_message(packet, True)
|
|
172
177
|
|
|
173
|
-
async def get_info(self) -> Union[RustInfo,
|
|
178
|
+
async def get_info(self) -> Union[RustInfo, RustError]:
|
|
174
179
|
"""
|
|
175
180
|
Gets information on the Rust Server
|
|
176
181
|
:return: RustInfo - The info of the server
|
|
177
182
|
"""
|
|
178
183
|
packet = await self._generate_request()
|
|
179
184
|
packet.get_info = AppEmpty()
|
|
180
|
-
|
|
181
185
|
response = await self.ws.send_and_get(packet)
|
|
186
|
+
|
|
182
187
|
if response is None:
|
|
183
|
-
return
|
|
188
|
+
return RustError("get_info", "misc")
|
|
189
|
+
|
|
190
|
+
if error_present(response):
|
|
191
|
+
return RustError("get_info", response.response.error.error)
|
|
184
192
|
|
|
185
193
|
return RustInfo(response.response.info)
|
|
186
194
|
|
|
187
|
-
async def get_team_chat(self) -> Union[List[RustChatMessage],
|
|
195
|
+
async def get_team_chat(self) -> Union[List[RustChatMessage], RustError]:
|
|
188
196
|
"""
|
|
189
197
|
Gets the team chat from the server
|
|
190
198
|
|
|
@@ -192,16 +200,19 @@ class RustSocket:
|
|
|
192
200
|
"""
|
|
193
201
|
packet = await self._generate_request()
|
|
194
202
|
packet.get_team_chat = AppEmpty()
|
|
195
|
-
|
|
196
203
|
response = await self.ws.send_and_get(packet)
|
|
204
|
+
|
|
197
205
|
if response is None:
|
|
198
|
-
return
|
|
206
|
+
return RustError("get_team_chat", "misc")
|
|
207
|
+
|
|
208
|
+
if error_present(response):
|
|
209
|
+
return RustError("get_team_chat", response.response.error.error)
|
|
199
210
|
|
|
200
211
|
return [
|
|
201
212
|
RustChatMessage(message) for message in response.response.team_chat.messages
|
|
202
213
|
]
|
|
203
214
|
|
|
204
|
-
async def get_team_info(self) -> Union[RustTeamInfo,
|
|
215
|
+
async def get_team_info(self) -> Union[RustTeamInfo, RustError]:
|
|
205
216
|
"""
|
|
206
217
|
Gets Information on the members of your team
|
|
207
218
|
|
|
@@ -209,14 +220,17 @@ class RustSocket:
|
|
|
209
220
|
"""
|
|
210
221
|
packet = await self._generate_request()
|
|
211
222
|
packet.get_team_info = AppEmpty()
|
|
212
|
-
|
|
213
223
|
response = await self.ws.send_and_get(packet)
|
|
224
|
+
|
|
214
225
|
if response is None:
|
|
215
|
-
return
|
|
226
|
+
return RustError("get_team_info", "misc")
|
|
227
|
+
|
|
228
|
+
if error_present(response):
|
|
229
|
+
return RustError("get_team_info", response.response.error.error)
|
|
216
230
|
|
|
217
231
|
return RustTeamInfo(response.response.team_info)
|
|
218
232
|
|
|
219
|
-
async def get_markers(self) -> Union[List[RustMarker],
|
|
233
|
+
async def get_markers(self) -> Union[List[RustMarker], RustError]:
|
|
220
234
|
"""
|
|
221
235
|
Gets all the map markers from the server
|
|
222
236
|
|
|
@@ -224,10 +238,13 @@ class RustSocket:
|
|
|
224
238
|
"""
|
|
225
239
|
packet = await self._generate_request()
|
|
226
240
|
packet.get_map_markers = AppEmpty()
|
|
227
|
-
|
|
228
241
|
response = await self.ws.send_and_get(packet)
|
|
242
|
+
|
|
229
243
|
if response is None:
|
|
230
|
-
return
|
|
244
|
+
return RustError("get_markers", "misc")
|
|
245
|
+
|
|
246
|
+
if error_present(response):
|
|
247
|
+
return RustError("get_markers", response.response.error.error)
|
|
231
248
|
|
|
232
249
|
return [RustMarker(marker) for marker in response.response.map_markers.markers]
|
|
233
250
|
|
|
@@ -239,7 +256,7 @@ class RustSocket:
|
|
|
239
256
|
add_team_positions: bool = False,
|
|
240
257
|
override_images: dict = None,
|
|
241
258
|
add_grid: bool = False,
|
|
242
|
-
) -> Union[Image.Image,
|
|
259
|
+
) -> Union[Image.Image, RustError]:
|
|
243
260
|
"""
|
|
244
261
|
Gets an image of the map from the server with the specified additions
|
|
245
262
|
|
|
@@ -256,16 +273,20 @@ class RustSocket:
|
|
|
256
273
|
override_images = {}
|
|
257
274
|
|
|
258
275
|
server_info = await self.get_info()
|
|
259
|
-
if server_info
|
|
260
|
-
return
|
|
276
|
+
if isinstance(server_info, RustError):
|
|
277
|
+
return server_info
|
|
261
278
|
|
|
262
279
|
map_size = server_info.size
|
|
263
280
|
|
|
264
281
|
packet = await self._generate_request(5)
|
|
265
282
|
packet.get_map = AppEmpty()
|
|
266
283
|
response = await self.ws.send_and_get(packet)
|
|
284
|
+
|
|
267
285
|
if response is None:
|
|
268
|
-
return
|
|
286
|
+
return RustError("get_map", "misc")
|
|
287
|
+
|
|
288
|
+
if error_present(response):
|
|
289
|
+
return RustError("get_map", response.response.error.error)
|
|
269
290
|
|
|
270
291
|
map_packet = response.response.map
|
|
271
292
|
monuments: List[AppMapMonument] = map_packet.monuments
|
|
@@ -274,7 +295,7 @@ class RustSocket:
|
|
|
274
295
|
output = Image.open(BytesIO(map_packet.jpg_image))
|
|
275
296
|
except Exception as e:
|
|
276
297
|
self.logger.error(f"Error opening image: {e}")
|
|
277
|
-
return
|
|
298
|
+
return RustError("get_map", str(e))
|
|
278
299
|
|
|
279
300
|
output = output.crop(
|
|
280
301
|
(500, 500, map_packet.height - 500, map_packet.width - 500)
|
|
@@ -349,7 +370,7 @@ class RustSocket:
|
|
|
349
370
|
|
|
350
371
|
return output
|
|
351
372
|
|
|
352
|
-
async def get_map_info(self) -> Union[RustMap,
|
|
373
|
+
async def get_map_info(self) -> Union[RustMap, RustError]:
|
|
353
374
|
"""
|
|
354
375
|
Gets the raw map data from the server
|
|
355
376
|
|
|
@@ -357,14 +378,19 @@ class RustSocket:
|
|
|
357
378
|
"""
|
|
358
379
|
packet = await self._generate_request(tokens=5)
|
|
359
380
|
packet.get_map = AppEmpty()
|
|
360
|
-
|
|
361
381
|
response = await self.ws.send_and_get(packet)
|
|
382
|
+
|
|
362
383
|
if response is None:
|
|
363
|
-
return
|
|
384
|
+
return RustError("get_map_info", "misc")
|
|
385
|
+
|
|
386
|
+
if error_present(response):
|
|
387
|
+
return RustError("get_map_info", response.response.error.error)
|
|
364
388
|
|
|
365
389
|
return RustMap(response.response.map)
|
|
366
390
|
|
|
367
|
-
async def get_entity_info(
|
|
391
|
+
async def get_entity_info(
|
|
392
|
+
self, eid: int = None
|
|
393
|
+
) -> Union[RustEntityInfo, RustError]:
|
|
368
394
|
"""
|
|
369
395
|
Gets entity info from the server
|
|
370
396
|
|
|
@@ -374,10 +400,13 @@ class RustSocket:
|
|
|
374
400
|
packet = await self._generate_request()
|
|
375
401
|
packet.get_entity_info = AppEmpty()
|
|
376
402
|
packet.entity_id = eid
|
|
377
|
-
|
|
378
403
|
response = await self.ws.send_and_get(packet)
|
|
404
|
+
|
|
379
405
|
if response is None:
|
|
380
|
-
return
|
|
406
|
+
return RustError("get_entity_info", "misc")
|
|
407
|
+
|
|
408
|
+
if error_present(response):
|
|
409
|
+
return RustError("get_entity_info", response.response.error.error)
|
|
381
410
|
|
|
382
411
|
return RustEntityInfo(response.response.entity_info)
|
|
383
412
|
|
|
@@ -413,7 +442,7 @@ class RustSocket:
|
|
|
413
442
|
|
|
414
443
|
await self.ws.send_message(packet, True)
|
|
415
444
|
|
|
416
|
-
async def check_subscription_to_entity(self, eid: int) -> Union[bool,
|
|
445
|
+
async def check_subscription_to_entity(self, eid: int) -> Union[bool, RustError]:
|
|
417
446
|
"""
|
|
418
447
|
Checks if you are subscribed to an entity
|
|
419
448
|
|
|
@@ -423,10 +452,15 @@ class RustSocket:
|
|
|
423
452
|
packet = await self._generate_request()
|
|
424
453
|
packet.check_subscription = AppEmpty()
|
|
425
454
|
packet.entity_id = eid
|
|
426
|
-
|
|
427
455
|
response = await self.ws.send_and_get(packet)
|
|
456
|
+
|
|
428
457
|
if response is None:
|
|
429
|
-
return
|
|
458
|
+
return RustError("check_subscription_to_entity", "misc")
|
|
459
|
+
|
|
460
|
+
if error_present(response):
|
|
461
|
+
return RustError(
|
|
462
|
+
"check_subscription_to_entity", response.response.error.error
|
|
463
|
+
)
|
|
430
464
|
|
|
431
465
|
return response.response.flag.value
|
|
432
466
|
|
|
@@ -446,7 +480,7 @@ class RustSocket:
|
|
|
446
480
|
|
|
447
481
|
async def get_contents(
|
|
448
482
|
self, eid: int = None, combine_stacks: bool = False
|
|
449
|
-
) -> Union[RustContents,
|
|
483
|
+
) -> Union[RustContents, RustError]:
|
|
450
484
|
"""
|
|
451
485
|
Gets the contents of a storage monitor-attached container
|
|
452
486
|
|
|
@@ -456,8 +490,8 @@ class RustSocket:
|
|
|
456
490
|
"""
|
|
457
491
|
returned_data = await self.get_entity_info(eid)
|
|
458
492
|
|
|
459
|
-
if returned_data
|
|
460
|
-
return
|
|
493
|
+
if isinstance(returned_data, RustError):
|
|
494
|
+
return returned_data
|
|
461
495
|
|
|
462
496
|
target_time = datetime.utcfromtimestamp(int(returned_data.protection_expiry))
|
|
463
497
|
difference = target_time - datetime.utcnow()
|
|
@@ -501,7 +535,7 @@ class RustSocket:
|
|
|
501
535
|
|
|
502
536
|
return RustContents(difference, bool(returned_data.has_protection), items)
|
|
503
537
|
|
|
504
|
-
async def get_camera_manager(self, cam_id: str) -> Union[CameraManager,
|
|
538
|
+
async def get_camera_manager(self, cam_id: str) -> Union[CameraManager, RustError]:
|
|
505
539
|
"""
|
|
506
540
|
Gets a camera manager for a given camera ID
|
|
507
541
|
|
|
@@ -515,10 +549,12 @@ class RustSocket:
|
|
|
515
549
|
subscribe = AppCameraSubscribe()
|
|
516
550
|
subscribe.camera_id = cam_id
|
|
517
551
|
packet.camera_subscribe = subscribe
|
|
518
|
-
|
|
519
552
|
response = await self.ws.send_and_get(packet)
|
|
520
553
|
|
|
521
554
|
if response is None:
|
|
522
|
-
return
|
|
555
|
+
return RustError("get_camera_manager", "misc")
|
|
556
|
+
|
|
557
|
+
if error_present(response):
|
|
558
|
+
return RustError("get_camera_manager", response.response.error.error)
|
|
523
559
|
|
|
524
560
|
return CameraManager(self, cam_id, response.response.camera_subscribe_info)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .serialization import Serializable
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class RustError(Serializable):
|
|
5
|
+
|
|
6
|
+
def __init__(self, method: str, reason: str) -> None:
|
|
7
|
+
self._method = method
|
|
8
|
+
self._reason = reason
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def method(self) -> str:
|
|
12
|
+
return self._method
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def reason(self) -> str:
|
|
16
|
+
return self._reason
|
|
17
|
+
|
|
18
|
+
def __str__(self) -> str:
|
|
19
|
+
return f"Error Propagating from {self._method}: {self._reason}"
|
|
@@ -13,6 +13,13 @@ PLAYER_MARKER_ONLINE_COLOR = (201, 242, 155, 255)
|
|
|
13
13
|
PLAYER_MARKER_OFFLINE_COLOR = (128, 128, 128, 255)
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
def error_present(app_message) -> bool:
|
|
17
|
+
"""
|
|
18
|
+
Checks message for error
|
|
19
|
+
"""
|
|
20
|
+
return app_message.response.error.error != ""
|
|
21
|
+
|
|
22
|
+
|
|
16
23
|
def convert_time(time) -> str:
|
|
17
24
|
hours, minutes = divmod(time * 60, 60)
|
|
18
25
|
|
|
@@ -93,6 +93,7 @@ rustplus/structs/__init__.py
|
|
|
93
93
|
rustplus/structs/rust_chat_message.py
|
|
94
94
|
rustplus/structs/rust_contents.py
|
|
95
95
|
rustplus/structs/rust_entity_info.py
|
|
96
|
+
rustplus/structs/rust_error.py
|
|
96
97
|
rustplus/structs/rust_info.py
|
|
97
98
|
rustplus/structs/rust_item.py
|
|
98
99
|
rustplus/structs/rust_map.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|