-
Notifications
You must be signed in to change notification settings - Fork 12
Make time errors more explicit when setting the ":next" Testday #77
Make time errors more explicit when setting the ":next" Testday #77
Conversation
Example talk with my testdaybot named xabolcs_tdb:
|
Interestingly there was a message in the channel after setting up a test day. Was it expected?
|
@@ -418,6 +418,11 @@ client.addListener('pm', function(from, message) { // private messages to bot | |||
client.say(from, "Next Test Day's topic is " + testDay.topic); | |||
} else { | |||
client.say(from, "Please use valid dates."); | |||
if (testDay.end < testDay.start) { | |||
client.say(from, "Start time was set after End time."); | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other option here is using if
to print all errors at once.
@whimboo, should I go that way? Currently only one error is printed.
An advanced solution would be to count all the errors and print a it like "Your specified a time interval which has the following 2 errors: the start time is after end time, the start time is in the past."
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use a string variable for the client.say
call in line 420, and then just combine the text for the individual error message like "Please use valid dates: %error%". That way we also only send a single message to the user.
I don't think the extended logic is that more helpful right now. Personally I would move those sanity checks for times up before line 410, so we do not have to check for the dates twice but return early.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I would move those sanity checks for times up before line 410, so we do not have to check for the dates twice but return early.
I happily do this move in this PR, should I?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be perfect.
|
…e error messages
Pushed commits to PR's branch including 45f4fc9. Please see the following conversation!
|
if (timerID !== 0) { | ||
clearTimeout(timerID); | ||
} | ||
testDay.start = new Date(command[1]); | ||
testDay.end = new Date(command[2]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, these should be startTime
and endTime
.
This is ready to review! |
testDay.topic = command.slice(4, cmdLen).join(" "); | ||
// if the start and end dates appear valid, set the test date | ||
if ((testDay.end > testDay.start) && (testDay.start > Date.now())) { | ||
var startTime, endTime, dateErrors = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not declare multiple variables in a single line. So move the declaration for startTime and endTime to the lines 406 and 407.
This is ready to review up to commit b14a8a0. |
This looks fine! I got it merged as 5a749f9. Thanks for your contribution. |
Fix for #74.