Fixed single digit second submissions. Covered bases to ensure time format is consistant.
This commit is contained in:
@@ -43,15 +43,14 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
|||||||
)
|
)
|
||||||
|
|
||||||
time_regex = re.search(
|
time_regex = re.search(
|
||||||
"^([0-9]{1,2}:)?[0-9]{2}(\.[0-9])?$", # pylint: disable=anomalous-backslash-in-string
|
"^([0-9]{1,2}:[0-9]|[0-9])?[0-9](\\.[0-9])?$", message.content
|
||||||
message.content,
|
|
||||||
)
|
)
|
||||||
int_regex = re.search("^[0-9]+$", message.content)
|
int_regex = re.search("^[0-9]+$", message.content)
|
||||||
if time_regex is None and is_time_record:
|
if time_regex is None and is_time_record:
|
||||||
embed = submission_message.embeds[0]
|
embed = submission_message.embeds[0]
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Error",
|
name="Error",
|
||||||
value="Time record must follow format MM:SS.ms or SS.ms or SS.",
|
value="Time record must follow format MM:SS.ms, SS.ms, or SS.",
|
||||||
)
|
)
|
||||||
elif int_regex is None and not is_time_record:
|
elif int_regex is None and not is_time_record:
|
||||||
embed = submission_message.embeds[0]
|
embed = submission_message.embeds[0]
|
||||||
@@ -60,11 +59,18 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
|||||||
score = message.content
|
score = message.content
|
||||||
if is_time_record:
|
if is_time_record:
|
||||||
# standardize time score format.
|
# standardize time score format.
|
||||||
# strip leading 0s and colon
|
if re.search("^[1-9]?[0-9]:[0-9]{2}(\\.[0-9])?$", score):
|
||||||
# then add colon if its not there
|
# score is already fine.
|
||||||
score = score.lstrip("0:")
|
pass
|
||||||
if score.find(":") == -1:
|
elif re.search("^[0-9]{2}(\\.[0-9])?$", score):
|
||||||
|
# need to add leading colon and 0
|
||||||
score = "0:" + score
|
score = "0:" + score
|
||||||
|
elif re.search("^[0-9](\\.[0-9])?$", score):
|
||||||
|
# need to add 0 in seconds and leading colon and 0
|
||||||
|
score = "0:0" + score
|
||||||
|
elif re.search("^[0]?[0-9]:[0-9]{2}(\\.[0-9])?$", score):
|
||||||
|
# if there is a minute 10ths place 0, remove
|
||||||
|
score = score.lstrip("0")
|
||||||
submission_objects[message.author.id]["score"] = score
|
submission_objects[message.author.id]["score"] = score
|
||||||
embed = get_submission_embed(message.author.id)
|
embed = get_submission_embed(message.author.id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user