Be less strict about exact order for setting reminders

This commit is contained in:
Deukhoofd 2018-10-27 14:12:11 +02:00
parent a242f2756e
commit 0a71e6d6ce
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 5 additions and 3 deletions

View File

@ -11,7 +11,7 @@ namespace DeukBot4.MessageHandlers
{
private static readonly Regex ReminderMatcher =
new Regex(
@".*(remind\s*((?<recipient>me)|<@!*(?<recipient>\d*)>)\s*to)(?<action>.*)(in\s+)(?<time>.*)",
@".*(remind\s*((?<recipient>me)|<@!*(?<recipient>\d*)>)\s*)(\s+to(?<action>.+)|\s+in\s+(?<time>.+)){2}",
RegexOptions.IgnoreCase);
public static async Task HandleReminder(SocketMessage message)
@ -23,10 +23,12 @@ namespace DeukBot4.MessageHandlers
}
var recipient = match.Groups["recipient"].Captures[0].Value;
var action = match.Groups["action"].Value.Trim();
var action = match.Groups["action"]?.Value.Trim();
if (string.IsNullOrWhiteSpace(action))
return;
var time = match.Groups["time"].Value;
var time = match.Groups["time"]?.Value;
if (string.IsNullOrWhiteSpace(time))
return;
var timespan = ParseTime(time);
if (!timespan.HasValue)
return;