aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks123 <[email protected]>2020-03-14 13:42:16 +0200
committerGravatar ks123 <[email protected]>2020-03-14 13:42:16 +0200
commit0745886e7ae62dce8db62bc3d8d8782c86c98652 (patch)
tree746fb8d0a50e244b1ee4128bee74b80822475714
parent(Space Cog): Refactored url query parameters system, apply changes to command... (diff)
(Space Cog): Removed date requirement from `.space mars` command. Now can command used in format `.space mars` and `.space mars <rover>` too.
-rw-r--r--bot/seasons/evergreen/space.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/bot/seasons/evergreen/space.py b/bot/seasons/evergreen/space.py
index fcdda034..968b5ed9 100644
--- a/bot/seasons/evergreen/space.py
+++ b/bot/seasons/evergreen/space.py
@@ -50,7 +50,8 @@ class Space(Cog):
for rover in data["rovers"]:
self.rovers[rover["name"].lower()] = {
"min_date": rover["landing_date"],
- "max_date": rover["max_date"]
+ "max_date": rover["max_date"],
+ "max_sol": rover["max_sol"]
}
@group(name="space", invoke_without_command=True)
@@ -146,7 +147,7 @@ class Space(Cog):
async def mars(
self,
ctx: Context,
- date: DateConverter,
+ date: Optional[DateConverter] = None,
rover: Optional[str] = "curiosity"
) -> None:
"""
@@ -164,6 +165,10 @@ class Space(Cog):
)
return
+ # When date not provided, get random SOL date between 0 and rover's max.
+ if date is None:
+ date = random.randint(0, self.rovers[rover]["max_sol"])
+
params = {}
if isinstance(date, int):
params["sol"] = date